[PATCH] conf: Don't generate machine names with a dot

Michal Privoznik mprivozn at redhat.com
Fri Feb 28 16:22:58 UTC 2020


According to the linked BZ, machined expects either valid
hostname or valid FQDN. While in case of multiple dots, a
trailing one doesn't violate FQDN, it does violate the rule in
case of something simple, like "domain.". But it's safe to remove
it in both cases.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1721804

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/conf/domain_conf.c | 4 ++--
 tests/virsystemdtest.c | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 17867eeece..9371153618 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30838,8 +30838,8 @@ virDomainMachineNameAppendValid(virBufferPtr buf,
         virBufferAddChar(buf, *name);
     }
 
-    /* trailing dashes are not allowed */
-    virBufferTrimChars(buf, "-");
+    /* trailing dashes or dots are not allowed */
+    virBufferTrimChars(buf, "-.");
 }
 
 #undef HOSTNAME_CHARS
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index b7dfd64d06..9847f255ac 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -744,6 +744,7 @@ mymain(void)
                  "qemu-100-kstest-network-device-default-httpksc9eed63e-981e-48ec");
     TEST_MACHINE("kstest-network-device-default-httpks_(c9eed63e-981e-48ec--cdc-56b3f8c5f678)", 10,
                  "qemu-10-kstest-network-device-default-httpksc9eed63e-981e-48ec");
+    TEST_MACHINE("demo.test.", 11, "qemu-11-demo.test");
 
 # define TESTS_PM_SUPPORT_HELPER(name, function) \
     do { \
-- 
2.24.1




More information about the libvir-list mailing list