Do not copy the <metadata> node to domain/network definition if its empty. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/conf/domain_conf.c | 4 +++- src/conf/network_conf.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 878d1f68c1..6ca604a60b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19853,8 +19853,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); } -- 2.48.1