separate virDomainDefParseSmartCardsInfo from virDomainDefParseXML, move virDomainDefParseSmartCardsInfo into virDomainDefParseDeviceInfo --- src/conf/domain_conf.c | 57 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3448c42..f818228 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20030,6 +20030,43 @@ virDomainDefParseInterfaceInfo(virDomainParseTotalParamPtr param) return ret; } + +static int +virDomainDefParseSmartCardsInfo(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 smartcard devices */ + if ((n = virXPathNodeSet("./devices/smartcard", ctxt, &nodes)) < 0) + goto cleanup; + if (n && VIR_ALLOC_N(def->smartcards, n) < 0) + goto cleanup; + + for (i = 0; i < n; i++) { + virDomainSmartcardDefPtr card = virDomainSmartcardDefParseXML(xmlopt, + nodes[i], + ctxt, + flags); + if (!card) + goto cleanup; + + def->smartcards[def->nsmartcards++] = card; + } + ret = 0; + + cleanup: + VIR_FREE(nodes); + return ret; +} + static int virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) { @@ -20043,6 +20080,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) virDomainDefParseLeaseInfo, virDomainDefParseFilesystemInfo, virDomainDefParseInterfaceInfo, + virDomainDefParseSmartCardsInfo, NULL }; @@ -20146,25 +20184,6 @@ virDomainDefParseXML(xmlDocPtr xml, fun_index++; } - /* analysis of the smartcard devices */ - if ((n = virXPathNodeSet("./devices/smartcard", ctxt, &nodes)) < 0) - goto error; - if (n && VIR_ALLOC_N(def->smartcards, n) < 0) - goto error; - - for (i = 0; i < n; i++) { - virDomainSmartcardDefPtr card = virDomainSmartcardDefParseXML(xmlopt, - nodes[i], - ctxt, - flags); - if (!card) - goto error; - - def->smartcards[def->nsmartcards++] = card; - } - VIR_FREE(nodes); - - /* analysis of the character devices */ if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) goto error; -- 2.8.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list