separate virDomainDefParseHubInfo from virDomainDefParseXML, move virDomainDefParseHubInfo into virDomainDefParseDeviceInfo --- src/conf/domain_conf.c | 69 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 72b3f56..37fa996 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20645,6 +20645,49 @@ virDomainDefParseNvramInfo(virDomainParseTotalParamPtr param) static int +virDomainDefParseHubInfo(virDomainParseTotalParamPtr param) +{ + virDomainDefPtr def = param->def; + xmlXPathContextPtr ctxt = param->ctxt; + virDomainXMLOptionPtr xmlopt = param->xmlopt; + unsigned int flags = param->flags; + + int ret = -1; + int n = 0; + size_t i; + xmlNodePtr *nodes = NULL; + + /* analysis of the hub devices */ + if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0) + goto cleanup; + if (n && VIR_ALLOC_N(def->hubs, n) < 0) + goto cleanup; + for (i = 0; i < n; i++) { + virDomainHubDefPtr hub; + + hub = virDomainHubDefParseXML(xmlopt, nodes[i], flags); + if (!hub) + goto cleanup; + + if (hub->type == VIR_DOMAIN_HUB_TYPE_USB && param->usb_none) { + virDomainHubDefFree(hub); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Can't add USB hub: " + "USB is disabled for this domain")); + goto cleanup; + } + + def->hubs[def->nhubs++] = hub; + } + ret = 0; + + cleanup: + VIR_FREE(nodes); + return ret; +} + + +static int virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) { typedef int (*virDomainPreaseDeviceFuc)(virDomainParseTotalParamPtr param); @@ -20672,6 +20715,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) virDomainDefParseRngInfo, virDomainDefParseTpmInfo, virDomainDefParseNvramInfo, + virDomainDefParseHubInfo, NULL }; @@ -20706,7 +20750,6 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainDefPtr def; bool uuid_generated = false; virHashTablePtr bootHash = NULL; - bool usb_none = false; virDomainParseTotalParam param = { xml, root, @@ -20775,30 +20818,6 @@ virDomainDefParseXML(xmlDocPtr xml, fun_index++; } - /* analysis of the hub devices */ - if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0) - goto error; - if (n && VIR_ALLOC_N(def->hubs, n) < 0) - goto error; - for (i = 0; i < n; i++) { - virDomainHubDefPtr hub; - - hub = virDomainHubDefParseXML(xmlopt, nodes[i], flags); - if (!hub) - goto error; - - if (hub->type == VIR_DOMAIN_HUB_TYPE_USB && usb_none) { - virDomainHubDefFree(hub); - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Can't add USB hub: " - "USB is disabled for this domain")); - goto error; - } - - def->hubs[def->nhubs++] = hub; - } - VIR_FREE(nodes); - /* analysis of the redirected devices */ if ((n = virXPathNodeSet("./devices/redirdev", ctxt, &nodes)) < 0) goto error; -- 2.8.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list