[libvirt] [PATCHv3 32/36] lib: Introduce flag VIR_DOMAIN_BLOCK_COMMIT_RELATIVE

Peter Krempa pkrempa at redhat.com
Fri May 30 08:37:54 UTC 2014


Introduce flag for the block commit API to allow the commit operation to
leave the chain relatively addressed. Also adds a virsh switch to enable
this behavior.
---
 include/libvirt/libvirt.h.in | 4 ++++
 tools/virsh-domain.c         | 7 +++++++
 tools/virsh.pod              | 6 ++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 260c971..2df7fc8 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2588,6 +2588,10 @@ typedef enum {
     VIR_DOMAIN_BLOCK_COMMIT_DELETE  = 1 << 1, /* Delete any files that are now
                                                  invalid after their contents
                                                  have been committed */
+    VIR_DOMAIN_BLOCK_COMMIT_RELATIVE = 1 << 2, /* try to keep the backing chain
+                                                  relative if the components
+                                                  removed by the commit are
+                                                  already relative */
 } virDomainBlockCommitFlags;

 int virDomainBlockCommit(virDomainPtr dom, const char *disk, const char *base,
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 84a6706..5c3a142 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1492,6 +1492,8 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
             flags |= VIR_DOMAIN_BLOCK_COMMIT_SHALLOW;
         if (vshCommandOptBool(cmd, "delete"))
             flags |= VIR_DOMAIN_BLOCK_COMMIT_DELETE;
+        if (vshCommandOptBool(cmd, "keep-relative"))
+            flags |= VIR_DOMAIN_BLOCK_COMMIT_RELATIVE;
         ret = virDomainBlockCommit(dom, path, base, top, bandwidth, flags);
         break;
     case VSH_CMD_BLOCK_JOB_COPY:
@@ -1612,6 +1614,11 @@ static const vshCmdOptDef opts_block_commit[] = {
      .type = VSH_OT_BOOL,
      .help = N_("with --wait, don't wait for cancel to finish")
     },
+    {.name = "keep-relative",
+     .type = VSH_OT_BOOL,
+     .help = N_("keep the backing chain relative if it was relatively "
+                "referenced if it was before")
+    },
     {.name = NULL}
 };

diff --git a/tools/virsh.pod b/tools/virsh.pod
index 02671b4..03b94a5 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -767,7 +767,7 @@ address of virtual interface (such as I<detach-interface> or
 I<domif-setlink>) will accept the MAC address printed by this command.

 =item B<blockcommit> I<domain> I<path> [I<bandwidth>]
-{[I<base>] | [I<--shallow>]} [I<top>] [I<--delete>]
+{[I<base>] | [I<--shallow>]} [I<top>] [I<--delete>] [I<--keep-relative>]
 [I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async>]]

 Reduce the length of a backing image chain, by committing changes at the
@@ -779,7 +779,9 @@ I<--shallow> can be used instead of I<base> to specify the immediate
 backing file of the resulting top image to be committed.  The files
 being committed are rendered invalid, possibly as soon as the operation
 starts; using the I<--delete> flag will remove these files at the successful
-completion of the commit operation.
+completion of the commit operation. Using the I<--keep-relative> flag
+will try to keep the backing chain names relative (if they were
+relative before).

 By default, this command returns as soon as possible, and data for
 the entire disk is committed in the background; the progress of the
-- 
1.9.3




More information about the libvir-list mailing list