separate virDomainDefParseRngInfo from virDomainDefParseXML, move virDomainDefParseRngInfo into virDomainDefParseDeviceInfo --- src/conf/domain_conf.c | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 42736e3..a98841f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20541,6 +20541,40 @@ virDomainDefParseMemballoonInfo(virDomainParseTotalParamPtr param) return ret; } + +static int +virDomainDefParseRngInfo(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; + + /* Parse the RNG devices */ + if ((n = virXPathNodeSet("./devices/rng", ctxt, &nodes)) < 0) + goto cleanup; + if (n && VIR_ALLOC_N(def->rngs, n) < 0) + goto cleanup; + for (i = 0; i < n; i++) { + virDomainRNGDefPtr rng = virDomainRNGDefParseXML(xmlopt, nodes[i], + ctxt, flags); + if (!rng) + goto cleanup; + + def->rngs[def->nrngs++] = rng; + } + ret = 0; + + cleanup: + VIR_FREE(nodes); + return ret; +} + static int virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) { @@ -20566,6 +20600,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) virDomainDefParseHostdevInfo, virDomainDefParseWatchdogInfo, virDomainDefParseMemballoonInfo, + virDomainDefParseRngInfo, NULL }; @@ -20669,21 +20704,6 @@ virDomainDefParseXML(xmlDocPtr xml, fun_index++; } - /* Parse the RNG devices */ - if ((n = virXPathNodeSet("./devices/rng", ctxt, &nodes)) < 0) - goto error; - if (n && VIR_ALLOC_N(def->rngs, n) < 0) - goto error; - for (i = 0; i < n; i++) { - virDomainRNGDefPtr rng = virDomainRNGDefParseXML(xmlopt, nodes[i], - ctxt, flags); - if (!rng) - goto error; - - def->rngs[def->nrngs++] = rng; - } - VIR_FREE(nodes); - /* Parse the TPM devices */ if ((n = virXPathNodeSet("./devices/tpm", ctxt, &nodes)) < 0) goto error; -- 2.8.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list