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>
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
}
/* 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);
}