From nobody Fri May 17 03:54:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1693506572; cv=none; d=zohomail.com; s=zohoarc; b=DnsS/ZRw1fzBgL5lH/FIyRZlwARpa9KLz7zQcUA+FMT8yyG3A2safTP3YyrO9gyWoUtQYPth0Omg3gtInIk2g372dBctIl90/hmwssKP8jnqIWhgdQyZehTMWpvJx6PqRkNRU2ErP27y5jf+oOTTwrFDpTtjlxSqdH0mTokfTlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693506572; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dQK0O2uejb20l7hAJCYPYi+vVwFWQFummUpfhY8exbg=; b=e/qVlHYfEpAX1WC27AjfbTPZSPRPQ0v4k/Q1u/XXqgp6jmLMUa654EdtJS2CTq/fzfJDAjJq4ezB9zWvwV+IU6StHwK6HNXqDfmULv80CKyMhuEE+e0B23sPbkoW6IgcvIjg7g6J3Qj3IQyolSjMmKMTtL0fQUPrA1EWMkr28R0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1693506572897863.8948293675827; Thu, 31 Aug 2023 11:29:32 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-9NN0gqhuPjKm1b4MDj0now-1; Thu, 31 Aug 2023 14:29:28 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D08533C0FCA5; Thu, 31 Aug 2023 18:29:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25EE540C6F4C; Thu, 31 Aug 2023 18:29:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DFB72194658D; Thu, 31 Aug 2023 18:29:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3FED81946587 for ; Thu, 31 Aug 2023 18:29:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3057240316A; Thu, 31 Aug 2023 18:29:24 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29018403168 for ; Thu, 31 Aug 2023 18:29:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9B8D280BC51 for ; Thu, 31 Aug 2023 18:29:23 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-5UFZXzmnNpi7sk81idxJHg-1; Thu, 31 Aug 2023 14:29:21 -0400 Received: from fews01-sea.riseup.net (fews01-sea-pn.riseup.net [10.0.1.109]) (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 mx1.riseup.net (Postfix) with ESMTPS id 4Rc8nr0p00zDqsf for ; Thu, 31 Aug 2023 18:29:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews01-sea.riseup.net (Postfix) with ESMTPSA id 4Rc8np6lx4zJn1b; Thu, 31 Aug 2023 18:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693506571; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dQK0O2uejb20l7hAJCYPYi+vVwFWQFummUpfhY8exbg=; b=DtFKhjBkWCWYJN1zrAOsYoC7wnIHoSStkahyfCT6A8Uh1HlQaeiZ8Rf+AS+YaquHSq0Ycs aElgsX+IKzpVzJyxBurkiyQNTtwU7PkvxeEm0rDA/LjC1k/8AGHjug2DV3lBk1KvXiTbVf KFn9/zaOQ1CHMc4Ur6HmiT1LR3oLwpY= X-MC-Unique: 9NN0gqhuPjKm1b4MDj0now-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 5UFZXzmnNpi7sk81idxJHg-1 X-Riseup-User-ID: B5625EDD27D6E7509E8F9A9BAFA9C8EE1C9D439644F1FB26FDA47F05D1ADE924 From: K Shiva Kiran To: libvir-list@redhat.com Subject: [PATCH] virsh: Fix net-desc --config output Date: Thu, 31 Aug 2023 23:59:08 +0530 Message-ID: <20230831182938.43016-1-shiva_kr@riseup.net> In-Reply-To: <5405f7f643b60d601a5f4711c4e21aa0.jdenemar@redhat.com> References: <5405f7f643b60d601a5f4711c4e21aa0.jdenemar@redhat.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: K Shiva Kiran Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: riseup.net Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693506575457100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Fixes the following bug: Command: `net-desc --config [--title] my_network` Expected Output: Title/Description of persistent config Output: Title/Description of live config This was caused due to the usage of a single `flags` variable in `virshGetNetworkDescription()` which ended up in a wrong enum being passed to `virNetworkGetMetadata()` (enum being that of LIVE instead of CONFIG). Although the domain object has the same code, this didn't cause a problem there because the enum values of `VIR_DOMAIN_INACTIVE_XML` and `VIR_DOMAIN_METADATA_CONFIG` turn out to be the same (1 << 1), whereas they are not for network equivalent ones (1 << 0, 1 << 1). Signed-off-by: K Shiva Kiran --- tools/virsh-network.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 49778d0f4f..8965d87c9c 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -366,7 +366,8 @@ static const vshCmdOptDef opts_network_desc[] =3D { /* extract description or title from network xml */ static char * virshGetNetworkDescription(vshControl *ctl, virNetworkPtr net, - bool title, unsigned int flags) + bool title, unsigned int flags, + unsigned int queryflags) { char *desc =3D NULL; g_autoptr(xmlDoc) doc =3D NULL; @@ -394,7 +395,7 @@ virshGetNetworkDescription(vshControl *ctl, virNetworkP= tr net, } =20 /* fall back to xml */ - if (virshNetworkGetXMLFromNet(ctl, net, flags, &doc, &ctxt) < 0) + if (virshNetworkGetXMLFromNet(ctl, net, queryflags, &doc, &ctxt) < 0) return NULL; =20 if (title) @@ -454,7 +455,7 @@ cmdNetworkDesc(vshControl *ctl, const vshCmd *cmd) g_autofree char *descNet =3D NULL; g_autofree char *descNew =3D NULL; =20 - if (!(descNet =3D virshGetNetworkDescription(ctl, net, title, quer= yflags))) + if (!(descNet =3D virshGetNetworkDescription(ctl, net, title, flag= s, queryflags))) return false; =20 if (!descArg) @@ -515,7 +516,7 @@ cmdNetworkDesc(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, "%s", _("Network description updated succes= sfully")); =20 } else { - g_autofree char *desc =3D virshGetNetworkDescription(ctl, net, tit= le, queryflags); + g_autofree char *desc =3D virshGetNetworkDescription(ctl, net, tit= le, flags, queryflags); if (!desc) return false; =20 @@ -1128,7 +1129,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_G= NUC_UNUSED) if (optTitle) { g_autofree char *title =3D NULL; =20 - if (!(title =3D virshGetNetworkDescription(ctl, network, t= rue, 0))) + if (!(title =3D virshGetNetworkDescription(ctl, network, t= rue, 0, 0))) goto cleanup; if (vshTableRowAppend(table, virNetworkGetName(network), --=20 2.42.0