From nobody Tue Nov 26 23:33:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562387904; cv=none; d=zoho.com; s=zohoarc; b=mcEXyXfQHHwUrdBvfNdXWrYJ3qYzlGMrbfdav51PQimGoJwU9LedaH+TLeruXs8Jp5XfJ8R61qU23oSIGIzJMYNYU5759PArYG5w+ZUL+FH//QXfUAj14rpBvE/DB3/9vunaBVZ6dWtI5omoDzu/PlpZM3Sss6zYBtJTkNbbK0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562387904; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=UAsddxfI4bJichzrpr4lJtW25Efm95d3JhOANIwIok8=; b=jgkIVT4RyInXAcr0urJ2LCxaqtjAw7bCp35GooSufhqzGZNZF33GhJ7SY5Sug1cHQEw1eyVwE6xGNA/NhKviqew8Q/UCQOysNcYrxxqb/Hfz/5BQwJkqnYu4YTTOkeZKTZxVtPlic33tn/b0YpyJReohJWLtaq1EFqQaxSUozQU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562387904071325.19911728461943; Fri, 5 Jul 2019 21:38:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5FA563082B46; Sat, 6 Jul 2019 04:38:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B4AA86E2E; Sat, 6 Jul 2019 04:38:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F2BFD18184B8; Sat, 6 Jul 2019 04:38:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x664bmkm006772 for ; Sat, 6 Jul 2019 00:37:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E2371001947; Sat, 6 Jul 2019 04:37:48 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-152.phx2.redhat.com [10.3.116.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 165421001B04 for ; Sat, 6 Jul 2019 04:37:48 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Fri, 5 Jul 2019 23:37:35 -0500 Message-Id: <20190706043735.26284-9-eblake@redhat.com> In-Reply-To: <20190706043735.26284-1-eblake@redhat.com> References: <20190706043735.26284-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/8] snapshot: Expose new filter flags in virsh X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 06 Jul 2019 04:38:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We already burned 'virsh snapshot-list --current' for a different purpose, so this adds --current-only/--no-current as the new bool flags to select the new filter bits. Update tests/virsh-snapshot to exercise the new flags. Signed-off-by: Eric Blake --- tests/virsh-snapshot | 8 +++++++- tools/virsh-snapshot.c | 10 ++++++++++ tools/virsh.pod | 7 ++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/virsh-snapshot b/tests/virsh-snapshot index 510904f470..8b0813233f 100755 --- a/tests/virsh-snapshot +++ b/tests/virsh-snapshot @@ -52,6 +52,7 @@ $abs_top_builddir/tools/virsh --connect test:///default >= out 2>err ' snapshot-current test --name # Deleting current root leads to multiple roots, demonstrate list filter= ing snapshot-delete test --current + snapshot-list test --current-only --name echo --err marker snapshot-current test --name echo --err marker @@ -63,7 +64,7 @@ $abs_top_builddir/tools/virsh --connect test:///default >= out 2>err ' # More fun with delete flags, current node moves up to remaining parent snapshot-current test s4 snapshot-delete test --children-only s6 - snapshot-current test --name + snapshot-list test --current-only --name snapshot-delete test --children s7 snapshot-current test --name snapshot-delete test s6 @@ -71,6 +72,7 @@ $abs_top_builddir/tools/virsh --connect test:///default >= out 2>err ' # Now the tree is linear, so we have an unambiguous topological order snapshot-list test --name snapshot-list test --name --topological + snapshot-list test --name --no-current # Capture some XML for later redefine echo "" snapshot-dumpxml test s3 @@ -123,6 +125,7 @@ Domain snapshot s1 deleted + Name Creation Time State --------------------------------------------- s3 TIMESTAMP running @@ -155,6 +158,7 @@ Snapshot s4 set as current Domain snapshot s6 children deleted s6 + Domain snapshot s7 deleted s6 @@ -167,6 +171,8 @@ s3 s3 s2 +s2 + EOF compare exp out.cooked || fail=3D1 diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index f7772ce549..9f8d1c5e5c 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -1463,6 +1463,14 @@ static const vshCmdOptDef opts_snapshot_list[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("sort list topologically rather than by name"), }, + {.name =3D "current-only", + .type =3D VSH_OT_BOOL, + .help =3D N_("filter to just the current snapshot"), + }, + {.name =3D "no-current", + .type =3D VSH_OT_BOOL, + .help =3D N_("filter out the current snapshot"), + }, {.name =3D NULL} }; @@ -1522,6 +1530,8 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) FILTER("disk-only", DISK_ONLY); FILTER("internal", INTERNAL); FILTER("external", EXTERNAL); + FILTER("current-only", CURRENT); + FILTER("no-current", NO_CURRENT); #undef FILTER if (vshCommandOptBool(cmd, "topological")) diff --git a/tools/virsh.pod b/tools/virsh.pod index 865fb2b0da..546727a90f 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -4767,7 +4767,8 @@ with I<--current>. [{I<--parent> | I<--roots> | [{I<--tree> | I<--name>}]}] [I<--topological>] [{[I<--from>] B | I<--current>} [I<--descendants>]] [I<--leaves>] [I<--no-leaves>] [I<--inactive>] [I<--active>] -[I<--disk-only>] [I<--internal>] [I<--external>] +[I<--disk-only>] [I<--internal>] [I<--external>] [I<--current-only>] +[I<--no-current>] List all of the available snapshots for the given domain, defaulting to show columns for the snapshot name, creation time, and domain state. @@ -4824,6 +4825,10 @@ that use internal storage of existing disk images. = If I<--external> is specified, the list will be filtered to snapshots that use external files for disk images or memory state. +If I<--current-only> is specified, the list will be filtered to just +the current snapshot (if it meets all other filters). If I<--no-current> +is specified, the list will be filtered to exclude the current snapshot. + =3Ditem B I I [I<--security-info>] Output the snapshot XML for the domain's snapshot named I. --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list