render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
d76c62
From f9fdeb29a61a98868d1a9f5284a85c57f826d6d1 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <f9fdeb29a61a98868d1a9f5284a85c57f826d6d1@dist-git>
d76c62
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
d76c62
Date: Fri, 13 Mar 2020 13:08:08 +0100
d76c62
Subject: [PATCH] conf: do not generate machine names ending with a dash
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
As of systemd commit:
d76c62
d76c62
commit d65652f1f21a4b0c59711320f34266c635393c89
d76c62
Author:     Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
d76c62
CommitDate: 2018-12-10 09:56:56 +0100
d76c62
d76c62
    Partially unify hostname_is_valid() and dns_name_is_valid()
d76c62
d76c62
Dashes are no longer allowed at the end of machine names.
d76c62
d76c62
Trim the trailing dashes from the generated name before passing
d76c62
it to machined.
d76c62
d76c62
Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1790409
d76c62
d76c62
Signed-off-by: Ján Tomko <jtomko@redhat.com>
d76c62
Reviewed-by: Erik Skultety <eskultet@redhat.com>
d76c62
(cherry picked from commit 45464db8ba502764cf37ec9335770248bdb3d9a8)
d76c62
d76c62
Prerequisite for: https://bugzilla.redhat.com/show_bug.cgi?id=1808499
d76c62
d76c62
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
d76c62
Message-Id: <ae17f80d69ee7772d32dd5c34c332be6b77e7afb.1584101247.git.mprivozn@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/conf/domain_conf.c | 3 +++
d76c62
 tests/virsystemdtest.c | 4 ++++
d76c62
 2 files changed, 7 insertions(+)
d76c62
d76c62
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
d76c62
index 77e3d25a2d..4b297c96bc 100644
d76c62
--- a/src/conf/domain_conf.c
d76c62
+++ b/src/conf/domain_conf.c
d76c62
@@ -30708,6 +30708,9 @@ virDomainMachineNameAppendValid(virBufferPtr buf,
d76c62
 
d76c62
         virBufferAddChar(buf, *name);
d76c62
     }
d76c62
+
d76c62
+    /* trailing dashes are not allowed */
d76c62
+    virBufferTrimChars(buf, "-");
d76c62
 }
d76c62
 
d76c62
 #undef HOSTNAME_CHARS
d76c62
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
d76c62
index 9b95ca6789..26876850b8 100644
d76c62
--- a/tests/virsystemdtest.c
d76c62
+++ b/tests/virsystemdtest.c
d76c62
@@ -740,6 +740,10 @@ mymain(void)
d76c62
                  "qemu-7-123456789012345678901234567890123456789012345678901234567");
d76c62
     TEST_MACHINE("123456789012345678901234567890123456789012345678901234567890", 8,
d76c62
                  "qemu-8-123456789012345678901234567890123456789012345678901234567");
d76c62
+    TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec-acdc-56b3f8c5f678)", 100,
d76c62
+                 "qemu-100-kstest-network-device-default-httpksc9eed63e-981e-48ec");
d76c62
+    TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec--cdc-56b3f8c5f678)", 10,
d76c62
+                 "qemu-10-kstest-network-device-default-httpksc9eed63e-981e-48ec");
d76c62
 
d76c62
 # define TESTS_PM_SUPPORT_HELPER(name, function) \
d76c62
     do { \
d76c62
-- 
d76c62
2.25.1
d76c62