Signed-off-by: Shi Lei <shi_...@massclouds.com> --- src/conf/domain_conf.c | 46 +++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 14 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bc42068..b3ec111 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14431,10 +14431,35 @@ virDomainGraphicsRDPDefParseXMLHook(xmlNodePtr node G_GNUC_UNUSED, } +static int +virDomainGraphicsSpiceDefParseXMLHook(xmlNodePtr node G_GNUC_UNUSED, + virDomainGraphicsSpiceDefPtr def, + const char *instname G_GNUC_UNUSED, + void *parent G_GNUC_UNUSED, + void *opaque) +{ + unsigned int flags = 0; + if (opaque) + flags = *((unsigned int *) opaque); + + if (def->port == -1 && def->tlsPort == -1) { + /* Legacy compat syntax, used -1 for auto-port */ + def->autoport = true; + } + + if (def->autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { + def->port = 0; + def->tlsPort = 0; + } + + return 0; +} + + static int virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, xmlNodePtr node, - xmlXPathContextPtr ctxt, + xmlXPathContextPtr ctxt G_GNUC_UNUSED, unsigned int flags) { xmlNodePtr cur; @@ -14444,9 +14469,6 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, g_autofree char *autoport = virXMLPropString(node, "autoport"); g_autofree char *defaultMode = virXMLPropString(node, "defaultMode"); - if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) - return -1; - if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.spice.port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -14482,16 +14504,6 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.defaultMode = defaultModeVal; } - if (def->data.spice.port == -1 && def->data.spice.tlsPort == -1) { - /* Legacy compat syntax, used -1 for auto-port */ - def->data.spice.autoport = true; - } - - if (def->data.spice.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { - def->data.spice.port = 0; - def->data.spice.tlsPort = 0; - } - def->data.spice.keymap = virXMLPropString(node, "keymap"); if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth, @@ -14701,6 +14713,10 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, cur = cur->next; } + if (virDomainGraphicsSpiceDefParseXMLHook(node, &def->data.spice, NULL, + def, &flags) < 0) + return -1; + return 0; } @@ -14808,6 +14824,8 @@ virDomainGraphicsDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) + goto error; if (virDomainGraphicsDefParseXMLSpice(def, node, ctxt, flags) < 0) goto error; break; -- 2.25.1