separate virDomainDefParseDomainInfo from virDomainDefParseXML --- src/conf/domain_conf.c | 90 +++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0f7069c..2daa6df 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18694,6 +18694,58 @@ virDomainDefParseOsNodeInfo(virDomainParseTotalParamPtr param) } +static int +virDomainDefParseDomainInfo(virDomainParseTotalParamPtr param) +{ + virDomainDefPtr def = param->def; + xmlXPathContextPtr ctxt = param->ctxt; + char *tmp = NULL; + int ret = -1; + + /* Extract domain name */ + if (!(def->name = virXPathString("string(./name[1])", ctxt))) { + virReportError(VIR_ERR_NO_NAME, NULL); + goto cleanup; + } + + /* Extract domain uuid. If both uuid and sysinfo/system/entry/uuid + * exist, they must match; and if only the latter exists, it can + * also serve as the uuid. */ + tmp = virXPathString("string(./uuid[1])", ctxt); + if (!tmp) { + if (virUUIDGenerate(def->uuid)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to generate UUID")); + goto cleanup; + } + param->uuid_generated = true; + } else { + if (virUUIDParse(tmp, def->uuid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed uuid element")); + goto cleanup; + } + VIR_FREE(tmp); + } + + /* Extract short description of domain (title) */ + def->title = virXPathString("string(./title[1])", ctxt); + if (def->title && strchr(def->title, '\n')) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Domain title can't contain newlines")); + goto cleanup; + } + + /* Extract documentation if present */ + def->description = virXPathString("string(./description[1])", ctxt); + ret = 0; + + cleanup: + VIR_FREE(tmp); + return ret; +} + + static virDomainDefPtr virDomainDefParseXML(xmlDocPtr xml, xmlNodePtr root, @@ -18737,6 +18789,7 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainDefParseIdInfo, virDomainDefParseVirtTypeInfo, virDomainDefParseOsNodeInfo, + virDomainDefParseDomainInfo, NULL }; @@ -18764,43 +18817,6 @@ virDomainDefParseXML(xmlDocPtr xml, fun_index++; } - /* Extract domain name */ - if (!(def->name = virXPathString("string(./name[1])", ctxt))) { - virReportError(VIR_ERR_NO_NAME, NULL); - goto error; - } - - /* Extract domain uuid. If both uuid and sysinfo/system/entry/uuid - * exist, they must match; and if only the latter exists, it can - * also serve as the uuid. */ - tmp = virXPathString("string(./uuid[1])", ctxt); - if (!tmp) { - if (virUUIDGenerate(def->uuid)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Failed to generate UUID")); - goto error; - } - uuid_generated = true; - } else { - if (virUUIDParse(tmp, def->uuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed uuid element")); - goto error; - } - VIR_FREE(tmp); - } - - /* Extract short description of domain (title) */ - def->title = virXPathString("string(./title[1])", ctxt); - if (def->title && strchr(def->title, '\n')) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Domain title can't contain newlines")); - goto error; - } - - /* Extract documentation if present */ - def->description = virXPathString("string(./description[1])", ctxt); - /* analysis of security label, done early even though we format it * late, so devices can refer to this for defaults */ if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL)) { -- 2.8.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list