From nobody Tue Dec 16 11:43:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1740088908850420.82370099698915; Thu, 20 Feb 2025 14:01:48 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3E72A97D; Thu, 20 Feb 2025 17:01:48 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id EFC232267; Thu, 20 Feb 2025 17:00:40 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A61E521D9; Thu, 20 Feb 2025 17:00:36 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 2D67D21CD for ; Thu, 20 Feb 2025 17:00:31 -0500 (EST) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-501-dxDFvjmtMy2wUMzw-vcCUw-1; Thu, 20 Feb 2025 17:00:29 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 84BD419783BA for ; Thu, 20 Feb 2025 22:00:28 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.8]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A607C1800359 for ; Thu, 20 Feb 2025 22:00:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740088830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PReDI09E2CP+cuOflokbUylBDHRvXEnN+uXzmPKfYUA=; b=hK5gnMPaKAagYG4TrvmWi2+FGbnLg9VmP7k9n5YUucAJCzk1qGpx1ijV6saPpqRBBSfUjw 5+umK3gc4PR8fBaw6qdJDM49VBh6s2mNUEnIrJMbLAsSiXNr+x/jv4QwbjggDFV3El/foO JdZ7aW5zbqhNJF1qi0YhLK5N4sy9cs0= X-MC-Unique: dxDFvjmtMy2wUMzw-vcCUw-1 X-Mimecast-MFC-AGG-ID: dxDFvjmtMy2wUMzw-vcCUw_1740088828 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCHv1 3/4] conf: metadata: ignore empty metadata element Date: Thu, 20 Feb 2025 22:59:25 +0100 Message-ID: <207dd043b19a7a17cb68d6fa503005c9546c4f36.1740088765.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: gJFDjDhXZlvp8nb9tvlmJlRhInUtS0X6I9XjTPMiqm4_1740088828 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 65QOJ343JFHWK5VMBWFIIHNUGETKUUQP X-Message-ID-Hash: 65QOJ343JFHWK5VMBWFIIHNUGETKUUQP X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1740088909879019000 Content-Type: text/plain; charset="utf-8" Do not copy the node to domain/network definition if its empty. Signed-off-by: J=C3=A1n Tomko --- 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; =20 /* Extract custom metadata */ - if ((node =3D virXPathNode("./metadata[1]", ctxt)) !=3D NULL) + if ((node =3D virXPathNode("./metadata[1]", ctxt)) !=3D NULL && + xmlFirstElementChild(node)) { def->metadata =3D xmlCopyNode(node, 1); + } =20 /* 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, } =20 /* Extract custom metadata */ - if ((metadataNode =3D virXPathNode("./metadata[1]", ctxt)) !=3D NULL) { + if ((metadataNode =3D virXPathNode("./metadata[1]", ctxt)) !=3D NULL && + xmlFirstElementChild(metadataNode)) { def->metadata =3D xmlCopyNode(metadataNode, 1); virXMLNodeSanitizeNamespaces(def->metadata); } --=20 2.48.1