1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 06:50:22 +03:00

conf: metadata: ignore empty metadata element

Do not copy the <metadata> node to domain/network definition
if its empty.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2025-02-20 22:48:40 +01:00
parent 633c55dbd6
commit 0b69d47774
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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);
}