From nobody Sun Feb 8 12:13:16 2026 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 17400904404171022.6976136401173; Thu, 20 Feb 2025 14:27:20 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id C058719C2; Thu, 20 Feb 2025 17:27:19 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 128B1196A; Thu, 20 Feb 2025 17:27:04 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 22F7B1905; Thu, 20 Feb 2025 17:27:02 -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 99A18179B for ; Thu, 20 Feb 2025 17:27:01 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-cEvAnX8KPmKXsEDcYAqOAQ-1; Thu, 20 Feb 2025 17:26:59 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7DC861800373 for ; Thu, 20 Feb 2025 22:26:58 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.8]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8A94C180087E for ; Thu, 20 Feb 2025 22:26:57 +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=1740090421; 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; bh=+172fePvkPAnZeQ5QgnO1tCC7si/9X+d5YTXqIvMQ2g=; b=fP0d2IEEvvcQwijTJsuR8AnanHpWsU/SSMp7uUxQ65ObrEQjEiFs/TSNtljVs5l9R3Khn4 jwqWcdoLIOpNRrWZsd8+f9PjmU5IDQx0kXt+uGNQLaF4sIBhLgXLthmYc+5lxHdRS3K85S mdqsAIG9R6D0RcozuDUnI6+G15aWfwE= X-MC-Unique: cEvAnX8KPmKXsEDcYAqOAQ-1 X-Mimecast-MFC-AGG-ID: cEvAnX8KPmKXsEDcYAqOAQ_1740090418 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH] tools: virsh: metadata: do not report error on missing metadata Date: Thu, 20 Feb 2025 23:26:32 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: -0pIOD0-df8oL-IujbLu9fkE_VFw0LbSzyz0sN26ySk_1740090418 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EQUTQGX22YVKCWIMMZOYU3SXGIT4YTWZ X-Message-ID-Hash: EQUTQGX22YVKCWIMMZOYU3SXGIT4YTWZ 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: 1740090441009019000 Content-Type: text/plain; charset="utf-8" Similarly to `desc` and `net-desc`, return an empty string if there is no metadata to be returned. https://issues.redhat.com/browse/RHEL-27172 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- tools/virsh-domain.c | 10 ++++++++-- tools/virsh-network.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index f3da2f903f..e104aa909a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8480,8 +8480,14 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) g_autofree char *data =3D NULL; /* get */ if (!(data =3D virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEME= NT, - uri, flags))) - return false; + uri, flags))) { + if (virGetLastErrorCode() =3D=3D VIR_ERR_NO_DOMAIN_METADATA) { + virResetLastError(); + data =3D g_strdup(""); + } else { + return false; + } + } =20 vshPrint(ctl, "%s\n", data); } diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 6fcc7fd8ee..bcdb76ae36 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -604,8 +604,14 @@ cmdNetworkMetadata(vshControl *ctl, const vshCmd *cmd) =20 /* get */ if (!(data =3D virNetworkGetMetadata(net, VIR_NETWORK_METADATA_ELE= MENT, - uri, flags))) - return false; + uri, flags))) { + if (virGetLastErrorCode() =3D=3D VIR_ERR_NO_NETWORK_METADATA) { + virResetLastError(); + data =3D g_strdup(""); + } else { + return false; + } + } =20 vshPrint(ctl, "%s\n", data); } --=20 2.48.1