[PATCH v2 09/11] virsh: Expose bulk snapshot dumpxml/redefine

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

 



Add flags to the 'dumpxml' and 'snapshot-create' commands to pass
the newly-added bulk snapshot flags through.

For command-line convenience, I intentionally made --redefine-list
imply --redefine, even though the counterpart C flags are distinct
(and you get an error if you pass _REDEFINE_LIST without _REDEFINE).

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 tools/virsh-domain.c   |  7 +++++++
 tools/virsh-snapshot.c | 14 ++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 5699018dcc..78854b1e0a 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10055,6 +10055,10 @@ static const vshCmdOptDef opts_dumpxml[] = {
      .type = VSH_OT_BOOL,
      .help = N_("provide XML suitable for migrations")
     },
+    {.name = "snapshots",
+     .type = VSH_OT_BOOL,
+     .help = N_("include all domain snapshots in XML dump"),
+    },
     {.name = NULL}
 };

@@ -10069,6 +10073,7 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
     bool secure = vshCommandOptBool(cmd, "security-info");
     bool update = vshCommandOptBool(cmd, "update-cpu");
     bool migratable = vshCommandOptBool(cmd, "migratable");
+    bool snapshots = vshCommandOptBool(cmd, "snapshots");

     if (inactive)
         flags |= VIR_DOMAIN_XML_INACTIVE;
@@ -10078,6 +10083,8 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_DOMAIN_XML_UPDATE_CPU;
     if (migratable)
         flags |= VIR_DOMAIN_XML_MIGRATABLE;
+    if (snapshots)
+        flags |= VIR_DOMAIN_XML_SNAPSHOTS;

     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 6cadb2b0d6..a58731c46e 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -80,6 +80,13 @@ virshSnapshotCreate(vshControl *ctl, virDomainPtr dom, const char *buffer,
         goto cleanup;
     }

+    if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST) {
+        vshPrintExtra(ctl, "%s",
+                      _("Domain snapshot list imported successfully"));
+        ret = true;
+        goto cleanup;
+    }
+
     name = virDomainSnapshotGetName(snapshot);
     if (!name) {
         vshError(ctl, "%s", _("Could not get snapshot name"));
@@ -122,6 +129,10 @@ static const vshCmdOptDef opts_snapshot_create[] = {
      .help = N_("redefine metadata for existing snapshot")
     },
     VIRSH_COMMON_OPT_CURRENT(N_("with redefine, set current snapshot")),
+    {.name = "redefine-list",
+     .type = VSH_OT_BOOL,
+     .help = N_("bulk define a set of snapshots, implies --redefine"),
+    },
     {.name = "no-metadata",
      .type = VSH_OT_BOOL,
      .help = N_("take snapshot but create no metadata")
@@ -177,6 +188,9 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
         flags |= VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC;
     if (vshCommandOptBool(cmd, "live"))
         flags |= VIR_DOMAIN_SNAPSHOT_CREATE_LIVE;
+    if (vshCommandOptBool(cmd, "redefine-list"))
+        flags |= VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE |
+            VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE_LIST;

     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;
-- 
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