[libvirt] [PATCH 6/7] virsh: Allow restoring snapshot with non-persistent configuration

Kothapally Madhu Pavan kmp at linux.vnet.ibm.com
Mon Oct 30 08:51:55 UTC 2017


Now, snapshot-restore will allow restoring snapshots with non-persistent
configuration as both active and inactive XML configurations are saved
in snapshot. User can discard non-persistent configuratin of a domain
using --active-only flag. When --active-only flag is used, active XML
configuration of the snapshot is used as both the active and inactive
XML configuration of the domain after restore.

Signed-off-by: Kothapally Madhu Pavan <kmp at linux.vnet.ibm.com>
---
 tools/virsh-snapshot.c | 6 ++++++
 tools/virsh.pod        | 9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 48fc034..7f6a231 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -1811,6 +1811,10 @@ static const vshCmdOptDef opts_snapshot_revert[] = {
      .type = VSH_OT_BOOL,
      .help = N_("try harder on risky reverts")
     },
+    {.name = "active-only",
+     .type = VSH_OT_BOOL,
+     .help = N_("use only active snapshot configuration when restoring")
+    },
     {.name = NULL}
 };
 
@@ -1835,6 +1839,8 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
      * when the error says it will make a difference.  */
     if (vshCommandOptBool(cmd, "force"))
         force = true;
+    if (vshCommandOptBool(cmd, "active-only"))
+        flags |= VIR_DOMAIN_SNAPSHOT_REVERT_ACTIVE_ONLY;
 
     dom = virshCommandOptDomain(ctl, cmd, NULL);
     if (dom == NULL)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 0578f8f..791014e 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -4526,7 +4526,7 @@ Output the name of the parent snapshot, if any, for the given
 I<snapshot>, or for the current snapshot with I<--current>.
 
 =item B<snapshot-revert> I<domain> {I<snapshot> | I<--current>}
-[{I<--running> | I<--paused>}] [I<--force>]
+[{I<--running> | I<--paused>}] [I<--force>] [I<--active-only>]
 
 Revert the given domain to the snapshot specified by I<snapshot>, or to
 the current snapshot with I<--current>.  Be aware
@@ -4559,6 +4559,13 @@ snapshot that uses a provably incompatible configuration, as well as
 with an inactive snapshot that is combined with the I<--start> or
 I<--pause> flag.
 
+When inactive XML configuration of a snapshot is available along with
+active XML configuration both the inactive and active XMl configurations
+are used to restore the snapshot. This will keep the non-persistent
+configuration alive after restoring a snapshot. User can kill the
+non-persistent configuration by issuing I<--active-only> flag. This will
+use active XML configuraton alone to revert the snapshot.
+
 =item B<snapshot-delete> I<domain> {I<snapshot> | I<--current>} [I<--metadata>]
 [{I<--children> | I<--children-only>}]
 
-- 
1.8.3.1




More information about the libvir-list mailing list