Re: [PATCHv3 01.7/43] snapshot: expose --running and --paused in virsh

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

 



On 08/27/2011 08:25 AM, Eric Blake wrote:
Pretty straight-forward exposure of new flags.  For most commands,
we let the API reject mutually exclusive flags; but for save-image-edit,
we do the sanity check ourselves to avoid looping on flag failure if
the edit cycle is ever enhanced to allow the user to retry an edit
to fix up an xml validation error.

* tools/virsh.c (cmdManagedSave, cmdRestore, cmdSave)
(cmdSaveImageDefine, cmdSaveImageEdit): Add new flags.
* tools/virsh.pod (managedsave, restore, save, save-image-define)
(save-image-edit): Document them.
---
  tools/virsh.c   |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
  tools/virsh.pod |   32 ++++++++++++++++++++++++++++++--
  2 files changed, 80 insertions(+), 7 deletions(-)

Missed a couple.  I'm squashing this in, for my v4 posting.

diff --git i/tools/virsh.c w/tools/virsh.c
index 4426d2b..6131ec6 100644
--- i/tools/virsh.c
+++ w/tools/virsh.c
@@ -12357,6 +12357,8 @@ static const vshCmdInfo info_snapshot_revert[] = {
 static const vshCmdOptDef opts_snapshot_revert[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"snapshotname", VSH_OT_DATA, VSH_OFLAG_REQ, N_("snapshot name")},
+ {"running", VSH_OT_BOOL, 0, N_("after reverting, change state to running")}, + {"paused", VSH_OT_BOOL, 0, N_("after reverting, change state to paused")},
     {NULL, 0, 0, NULL}
 };

@@ -12367,6 +12369,12 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
     bool ret = false;
     const char *name = NULL;
     virDomainSnapshotPtr snapshot = NULL;
+    int flags = 0;
+
+    if (vshCommandOptBool(cmd, "running"))
+        flags |= VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING;
+    if (vshCommandOptBool(cmd, "paused"))
+        flags |= VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED;

     if (!vshConnectionUsability(ctl, ctl->conn))
         goto cleanup;
@@ -12382,7 +12390,7 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
     if (snapshot == NULL)
         goto cleanup;

-    if (virDomainRevertToSnapshot(snapshot, 0) < 0)
+    if (virDomainRevertToSnapshot(snapshot, flags) < 0)
         goto cleanup;

     ret = true;
diff --git i/tools/virsh.pod w/tools/virsh.pod
index 5967d1f..69af408 100644
--- i/tools/virsh.pod
+++ w/tools/virsh.pod
@@ -1627,14 +1627,22 @@ Output the snapshot XML for the domain's snapshot named I<snapshot>.

 Output the name of the parent snapshot for the given I<snapshot>, if any.

-=item B<snapshot-revert> I<domain> I<snapshot>
+=item B<snapshot-revert> I<domain> I<snapshot> [{I<--running> | I<--paused>}]

Revert the given domain to the snapshot specified by I<snapshot>. Be aware
-that this is a destructive action; any changes in the domain since the
+that this is a destructive action; any changes in the domain since the last
snapshot was taken will be lost. Also note that the state of the domain after
 snapshot-revert is complete will be the state of the domain at the time
 the original snapshot was taken.

+Normally, reverting to a snapshot leaves the domain in the state it was
+at the time the snapshot was created, except that a disk snapshot with
+no vm state leaves the domain in an inactive state.  Passing either the
+I<--running> or I<--paused> flag will perform additional state changes
+(such as booting an inactive domain, or pausing a running domain).  Since
+transient domains cannot be inactive, it is required to use one of these
+flags when reverting to a disk snapshot of a transient domain.
+
 =item B<snapshot-delete> I<domain> I<snapshot> I<--children>

 Delete the snapshot for the domain named I<snapshot>.  If this snapshot

--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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