[PATCHv3 40/43] snapshot: wire up disk-only flag to snapshot-create

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

 



I still need a good solution for snapshot-create-as to list multiple
disk options.  But this patch is sufficient to test the creation
of disk snapshots using only default <disks> for snapshot-create-as,
and snapshot-create provides full access to the snapshot process.

* tools/virsh.c (cmdSnapshotCreate, cmdSnapshotCreateAs): Add
--disk-only.
* tools/virsh.pod (snapshot-create, snapshot-create-as): Document
it.
---
 tools/virsh.c   |   12 ++++++++++--
 tools/virsh.pod |   20 +++++++++++++++-----
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index fa80a52..8b522fc 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -12269,6 +12269,7 @@ static const vshCmdOptDef opts_snapshot_create[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"xmlfile", VSH_OT_DATA, 0, N_("domain snapshot XML")},
     {"halt", VSH_OT_BOOL, 0, N_("halt domain after snapshot is created")},
+    {"disk-only", VSH_OT_BOOL, 0, N_("capture disk state but not vm state")},
     {NULL, 0, 0, NULL}
 };

@@ -12284,6 +12285,9 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "halt"))
         flags |= VIR_DOMAIN_SNAPSHOT_CREATE_HALT;

+    if (vshCommandOptBool(cmd, "disk-only"))
+        flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
+
     if (!vshConnectionUsability(ctl, ctl->conn))
         goto cleanup;

@@ -12333,6 +12337,7 @@ static const vshCmdOptDef opts_snapshot_create_as[] = {
     {"description", VSH_OT_DATA, 0, N_("description of snapshot")},
     {"print-xml", VSH_OT_BOOL, 0, N_("print XML document rather than create")},
     {"halt", VSH_OT_BOOL, 0, N_("halt domain after snapshot is created")},
+    {"disk-only", VSH_OT_BOOL, 0, N_("capture disk state but not vm state")},
     {NULL, 0, 0, NULL}
 };

@@ -12350,6 +12355,9 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "halt"))
         flags |= VIR_DOMAIN_SNAPSHOT_CREATE_HALT;

+    if (vshCommandOptBool(cmd, "disk-only"))
+        flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
+
     if (!vshConnectionUsability(ctl, ctl->conn))
         goto cleanup;

@@ -12377,9 +12385,9 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
     }

     if (vshCommandOptBool(cmd, "print-xml")) {
-        if (vshCommandOptBool(cmd, "halt")) {
+        if (flags) {
             vshError(ctl, "%s",
-                     _("--print-xml and --halt are mutually exclusive"));
+                     _("--print-xml does not work with --halt or --disk-only"));
             goto cleanup;
         }
         vshPrint(ctl, "%s\n",  buffer);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index b357330..a702520 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1605,26 +1605,36 @@ used to represent properties of snapshots.

 =over 4

-=item B<snapshot-create> I<domain> [I<xmlfile>] [I<--halt>]
+=item B<snapshot-create> I<domain> [I<xmlfile>] [I<--halt>] [I<--disk-only>]

 Create a snapshot for domain I<domain> with the properties specified in
 I<xmlfile>.  The only properties settable for a domain snapshot are the
-<name> and <description>; the rest of the fields are ignored, and
+<name> and <description>, as well as <disks> if I<--disk-only> is given;
+the rest of the fields are ignored, and
 automatically filled in by libvirt.  If I<xmlfile> is completely omitted,
 then libvirt will choose a value for all fields.

 If I<--halt> is specified, the domain will be left in an inactive state
 after the snapshot is created.

-=item B<snapshot-create-as> I<domain> [{I<--print-xml> | I<--halt>}]
-[I<name>] [I<description>]
+If I<--disk-only> is specified, the snapshot will only include disk
+state rather than the usual system checkpoint with vm state.  Disk
+snapshots are faster than full system checkpoints, but reverting to a
+disk snapshot may require fsck or journal replays, since it is like
+the disk state at the point when the power cord is abruptly pulled;
+and mixing I<--halt> and I<--disk-only> loses any data that was not
+flushed to disk at the time.
+
+=item B<snapshot-create-as> I<domain> {[I<--print-xml>] | [I<--halt>]
+[I<--disk-only>]} [I<name>] [I<description>]

 Create a snapshot for domain I<domain> with the given <name> and
 <description>; if either value is omitted, libvirt will choose a
 value.  If I<--print-xml> is specified, then XML appropriate for
 I<snapshot-create> is output, rather than actually creating a snapshot.
 Otherwise, if I<--halt> is specified, the domain will be left in an
-inactive state after the snapshot is created.
+inactive state after the snapshot is created, and if I<--disk-only>
+is specified, the snapshot will not include vm state.

 =item B<snapshot-current> I<domain> [I<--name>] [I<--security-info>]

-- 
1.7.4.4

--
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]