From f19390d2d3ab18cc9bff53e1d642e4e2b534f5a5 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Wed, 25 Jan 2017 17:42:07 +0100 Subject: [PATCH] domain_conf: vnc: preserve autoport value if no port was specified The issue is that if this graphics definition is provided: it's parsed as: but if the resulting XML is parsed again the output is: and this should not happen. The XML have to always remain the same after it was already parsed by libvirt. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1383039 Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 2 ++ .../generic-graphics-vnc-autoport-no.xml | 30 +++++++++++++++++++ tests/genericxml2xmltest.c | 1 + 3 files changed, 33 insertions(+) create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-autoport-no.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a2b72cb9c5..877a0bf5c1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11722,6 +11722,8 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) def->data.vnc.port = 0; def->data.vnc.autoport = true; + } else { + def->data.vnc.autoport = false; } } diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-autoport-no.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-autoport-no.xml new file mode 100644 index 0000000000..748e7f489d --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-autoport-no.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 2ea2396480..488190270f 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -91,6 +91,7 @@ mymain(void) DO_TEST_DIFFERENT("graphics-vnc-socket-attr-listen-socket"); DO_TEST_FULL("graphics-vnc-socket-attr-listen-socket-mismatch", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST("graphics-vnc-autoport-no"); DO_TEST_FULL("name-slash-fail", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);