From nobody Mon Feb 9 16:21:11 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1711195773803106.9793164593309; Sat, 23 Mar 2024 05:09:33 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A98F02278; Sat, 23 Mar 2024 08:09:32 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CBC551AEC; Sat, 23 Mar 2024 07:40:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D21861D77; Sat, 23 Mar 2024 07:40:28 -0400 (EDT) Received: from mx1.osci.io (polly.osci.io [8.43.85.229]) (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 3CF7E1D7A for ; Sat, 23 Mar 2024 07:32:55 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 71A3D223EB; Fri, 22 Mar 2024 13:56:47 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by mx1.osci.io (Postfix) with ESMTPS id D3932223EA for ; Fri, 22 Mar 2024 13:56:46 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-E2KAim7SPCSpyQK3i1SDmQ-1; Fri, 22 Mar 2024 13:56:44 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 67B6E1865428 for ; Fri, 22 Mar 2024 17:56:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5CD5492BDD for ; Fri, 22 Mar 2024 17:56:43 +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.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: E2KAim7SPCSpyQK3i1SDmQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 26/35] virsh: Fix '--name' and '--parent' used together in '(snapshot|checkpoint)-list' command Date: Fri, 22 Mar 2024 18:56:04 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 2B4K5NFMRHXYAQM3MQLM6XZG2ECY2AFC X-Message-ID-Hash: 2B4K5NFMRHXYAQM3MQLM6XZG2ECY2AFC X-MailFrom: SRS0=Xa5W=K4=redhat.com=pkrempa@osci.io 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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1711195775815100001 Until now when '--name' was used the parent was not printed and the option was ignored. One option would be to declare the options mutually exclusive, but for testing it may come handy to print both the snapshot name and parent. Adjust the code to print them tab-separated and adjust the docs. Signed-off-by: Peter Krempa --- docs/manpages/virsh.rst | 15 ++++++++++----- tools/virsh-checkpoint.c | 18 ++++++++++++------ tools/virsh-snapshot.c | 18 ++++++++++++------ 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 115b802c45..5cf510b6e9 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -7673,9 +7673,11 @@ If *--parent* is specified, add a column to the outp= ut table giving the name of the parent of each snapshot. If *--roots* is specified, the list will be filtered to just snapshots that have no parents. If *--tree* is specified, the output will be in a tree format, listing -just snapshot names. These three options are mutually exclusive. If -*--name* is specified only the snapshot name is printed. This option is -mutually exclusive with *--tree*. +just snapshot names. These three options are mutually exclusive. + +If *--name* is specified only the snapshot name is printed optionally +followed by a tab-separated name of the parent snapshot if *--parent* is u= sed +as well. This option is mutually exclusive with *--tree*. If *--from* is provided, filter the list to snapshots which are children of the given ``snapshot``; or if *--current* is provided, @@ -7989,8 +7991,11 @@ the name of the parent of each checkpoint. If *--ro= ots* is specified, the list will be filtered to just checkpoints that have no parents. If *--tree* is specified, the output will be in a tree format, listing just checkpoint names. These three options are -mutually exclusive. If *--name* is specified only the checkpoint name -is printed. This option is mutually exclusive with *--tree*. +mutually exclusive. + +If *--name* is specified only the checkpoint name is printed optionally +followed by a tab-separated name of the parent checkpoint if *--parent* is= used +as well. This option is mutually exclusive with *--tree*. If *--from* is provided, filter the list to checkpoints which are children of the given ``checkpoint``. When used in isolation or with diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index 869c071700..ebad2907e5 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -753,12 +753,6 @@ cmdCheckpointList(vshControl *ctl, chk_name =3D virDomainCheckpointGetName(checkpoint); assert(chk_name); - if (name) { - /* just print the checkpoint name */ - vshPrint(ctl, "%s\n", chk_name); - continue; - } - if (!(doc =3D virDomainCheckpointGetXMLDesc(checkpoint, 0))) continue; @@ -769,6 +763,18 @@ cmdCheckpointList(vshControl *ctl, parent_chk =3D virXPathString("string(/domaincheckpoint/parent= /name)", ctxt); + if (name) { + vshPrint(ctl, "%s", chk_name); + + if (parent_chk) + vshPrint(ctl, "\t%s", parent_chk); + + vshPrint(ctl, "\n"); + + /* just print the checkpoint name */ + continue; + } + if (virXPathLongLong("string(/domaincheckpoint/creationTime)", ctx= t, &creation_longlong) < 0) continue; diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 899bae7e9a..7b22962efb 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -1509,12 +1509,6 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) snap_name =3D virDomainSnapshotGetName(snapshot); assert(snap_name); - if (name) { - /* just print the snapshot name */ - vshPrint(ctl, "%s\n", snap_name); - continue; - } - if (!(doc =3D virDomainSnapshotGetXMLDesc(snapshot, 0))) continue; @@ -1525,6 +1519,18 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) parent_snap =3D virXPathString("string(/domainsnapshot/parent/= name)", ctxt); + if (name) { + vshPrint(ctl, "%s", snap_name); + + if (parent_snap) + vshPrint(ctl, "\t%s", parent_snap); + + vshPrint(ctl, "\n"); + + /* just print the snapshot name */ + continue; + } + if (!(state =3D virXPathString("string(/domainsnapshot/state)", ct= xt))) continue; --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org