From: Ján Tomko Date: Thu, 20 Feb 2025 21:48:40 +0000 (+0100) Subject: conf: metadata: ignore empty metadata element X-Git-Tag: v11.2.0-rc1~302 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b69d47774c9cb42c4f9d637dd0760b02649cfdb;p=thirdparty%2Flibvirt.git conf: metadata: ignore empty metadata element Do not copy the node to domain/network definition if its empty. Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 206b0480ca..d2d35abb7b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19855,8 +19855,10 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt, return NULL; /* Extract custom metadata */ - if ((node = virXPathNode("./metadata[1]", ctxt)) != NULL) + if ((node = virXPathNode("./metadata[1]", ctxt)) != NULL && + xmlFirstElementChild(node)) { def->metadata = xmlCopyNode(node, 1); + } /* we have to make a copy of all of the callback pointers here since * we won't have the virCaps structure available during free diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 316a84502d..8cd26de72f 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1898,7 +1898,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, } /* Extract custom metadata */ - if ((metadataNode = virXPathNode("./metadata[1]", ctxt)) != NULL) { + if ((metadataNode = virXPathNode("./metadata[1]", ctxt)) != NULL && + xmlFirstElementChild(metadataNode)) { def->metadata = xmlCopyNode(metadataNode, 1); virXMLNodeSanitizeNamespaces(def->metadata); }