separate virDomainDefParseNvramInfo from virDomainDefParseXML, move virDomainDefParseNvramInfo into virDomainDefParseDeviceInfo --- src/conf/domain_conf.c | 51 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8f86c76..72b3f56 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20611,6 +20611,40 @@ virDomainDefParseTpmInfo(virDomainParseTotalParamPtr param) static int +virDomainDefParseNvramInfo(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; + xmlNodePtr *nodes = NULL; + + if ((n = virXPathNodeSet("./devices/nvram", ctxt, &nodes)) < 0) + goto cleanup; + + if (n > 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("only a single nvram device is supported")); + goto cleanup; + } else if (n == 1) { + virDomainNVRAMDefPtr nvram = + virDomainNVRAMDefParseXML(xmlopt, nodes[0], flags); + if (!nvram) + goto cleanup; + def->nvram = nvram; + } + ret = 0; + + cleanup: + VIR_FREE(nodes); + return ret; +} + + +static int virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) { typedef int (*virDomainPreaseDeviceFuc)(virDomainParseTotalParamPtr param); @@ -20637,6 +20671,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) virDomainDefParseMemballoonInfo, virDomainDefParseRngInfo, virDomainDefParseTpmInfo, + virDomainDefParseNvramInfo, NULL }; @@ -20740,22 +20775,6 @@ virDomainDefParseXML(xmlDocPtr xml, fun_index++; } - if ((n = virXPathNodeSet("./devices/nvram", ctxt, &nodes)) < 0) - goto error; - - if (n > 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("only a single nvram device is supported")); - goto error; - } else if (n == 1) { - virDomainNVRAMDefPtr nvram = - virDomainNVRAMDefParseXML(xmlopt, nodes[0], flags); - if (!nvram) - goto error; - def->nvram = nvram; - VIR_FREE(nodes); - } - /* analysis of the hub devices */ if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0) goto error; -- 2.8.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list