Instead of calling the virDomainGraphicsListensParseXML function for all graphics types and ignore the wrong ones move the call only to graphics types where we supports listen elements. Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/conf/domain_conf.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index befbd4f..dc3bc22 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10696,13 +10696,6 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, ctxt->node = node; - if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC && - def->type != VIR_DOMAIN_GRAPHICS_TYPE_RDP && - def->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { - ret = 0; - goto error; - } - /* parse the <listen> subelements for graphics types that support it */ nListens = virXPathNodeSet("./listen", ctxt, &listenNodes); if (nListens < 0) @@ -10761,6 +10754,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, static int virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr def, xmlNodePtr node, + xmlXPathContextPtr ctxt, unsigned int flags) { char *port = virXMLPropString(node, "port"); @@ -10769,6 +10763,9 @@ virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr def, char *autoport = virXMLPropString(node, "autoport"); int ret = -1; + if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) + goto error; + if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.vnc.port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -10869,6 +10866,7 @@ virDomainGraphicsDefParseXMLSdl(virDomainGraphicsDefPtr def, static int virDomainGraphicsDefParseXMLRdp(virDomainGraphicsDefPtr def, xmlNodePtr node, + xmlXPathContextPtr ctxt, unsigned int flags) { char *port = virXMLPropString(node, "port"); @@ -10877,6 +10875,9 @@ virDomainGraphicsDefParseXMLRdp(virDomainGraphicsDefPtr def, char *multiUser = virXMLPropString(node, "multiUser"); int ret = -1; + if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) + goto error; + if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.rdp.port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -10947,6 +10948,7 @@ virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def, static int virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, xmlNodePtr node, + xmlXPathContextPtr ctxt, unsigned int flags) { xmlNodePtr cur; @@ -10957,6 +10959,9 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, int defaultModeVal; int ret = -1; + if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) + goto error; + if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.spice.port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -11269,12 +11274,9 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, goto error; } - if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) - goto error; - switch (def->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - if (virDomainGraphicsDefParseXMLVnc(def, node, flags) < 0) + if (virDomainGraphicsDefParseXMLVnc(def, node, ctxt, flags) < 0) goto error; break; case VIR_DOMAIN_GRAPHICS_TYPE_SDL: @@ -11282,7 +11284,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, goto error; break; case VIR_DOMAIN_GRAPHICS_TYPE_RDP: - if (virDomainGraphicsDefParseXMLRdp(def, node, flags) < 0) + if (virDomainGraphicsDefParseXMLRdp(def, node, ctxt, flags) < 0) goto error; break; case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: @@ -11290,7 +11292,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, goto error; break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if (virDomainGraphicsDefParseXMLSpice(def, node, flags) < 0) + if (virDomainGraphicsDefParseXMLSpice(def, node, ctxt, flags) < 0) goto error; break; } -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list