[PATCH 8/8] snapshot: Expose new filter flags in virsh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <eblake@xxxxxxxxxx>
---
 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 filtering
   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 "<!--MarkerA-->"
   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=1

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[] = {
      .type = VSH_OT_BOOL,
      .help = N_("sort list topologically rather than by name"),
     },
+    {.name = "current-only",
+     .type = VSH_OT_BOOL,
+     .help = N_("filter to just the current snapshot"),
+    },
+    {.name = "no-current",
+     .type = VSH_OT_BOOL,
+     .help = N_("filter out the current snapshot"),
+    },

     {.name = 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<snapshot> | 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.
+
 =item B<snapshot-dumpxml> I<domain> I<snapshot> [I<--security-info>]

 Output the snapshot XML for the domain's snapshot named I<snapshot>.
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux