separate virDomainDefParseTpmInfo from virDomainDefParseXML, move virDomainDefParseTpmInfo into virDomainDefParseDeviceInfo --- src/conf/domain_conf.c | 52 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a98841f..8f86c76 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20575,6 +20575,41 @@ virDomainDefParseRngInfo(virDomainParseTotalParamPtr param) return ret; } + +static int +virDomainDefParseTpmInfo(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; + + /* Parse the TPM devices */ + if ((n = virXPathNodeSet("./devices/tpm", ctxt, &nodes)) < 0) + goto cleanup; + + if (n > 1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only a single TPM device is supported")); + goto cleanup; + } + + if (n > 0) { + if (!(def->tpm = virDomainTPMDefParseXML(xmlopt, nodes[0], ctxt, flags))) + goto cleanup; + } + VIR_FREE(nodes); + + cleanup: + VIR_FREE(nodes); + return ret; +} + + static int virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) { @@ -20601,6 +20636,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) virDomainDefParseWatchdogInfo, virDomainDefParseMemballoonInfo, virDomainDefParseRngInfo, + virDomainDefParseTpmInfo, NULL }; @@ -20704,22 +20740,6 @@ virDomainDefParseXML(xmlDocPtr xml, fun_index++; } - /* Parse the TPM devices */ - if ((n = virXPathNodeSet("./devices/tpm", ctxt, &nodes)) < 0) - goto error; - - if (n > 1) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("only a single TPM device is supported")); - goto error; - } - - if (n > 0) { - if (!(def->tpm = virDomainTPMDefParseXML(xmlopt, nodes[0], ctxt, flags))) - goto error; - } - VIR_FREE(nodes); - if ((n = virXPathNodeSet("./devices/nvram", ctxt, &nodes)) < 0) goto error; -- 2.8.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list