]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
lib: Introduce flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE
authorPeter Krempa <pkrempa@redhat.com>
Fri, 16 May 2014 13:40:06 +0000 (15:40 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 8 Jul 2014 09:51:06 +0000 (11:51 +0200)
Introduce flag for the block rebase API to allow the rebase operation to
leave the chain relatively addressed. Also adds a virsh switch to enable
this behavior.

include/libvirt/libvirt.h.in
src/libvirt.c
tools/virsh-domain.c
tools/virsh.pod

index 8c4ee8b89030607dce7f6d79b2b1c59786683c23..ad6785fc8aa64f21c3a689b86fb68d49c17acc12 100644 (file)
@@ -2587,6 +2587,9 @@ typedef enum {
                                                    file for a copy */
     VIR_DOMAIN_BLOCK_REBASE_COPY_RAW  = 1 << 2, /* Make destination file raw */
     VIR_DOMAIN_BLOCK_REBASE_COPY      = 1 << 3, /* Start a copy job */
+    VIR_DOMAIN_BLOCK_REBASE_RELATIVE  = 1 << 4, /* Keep backing chain
+                                                   referenced using relative
+                                                   names */
 } virDomainBlockRebaseFlags;
 
 int           virDomainBlockRebase(virDomainPtr dom, const char *disk,
index f178727f014a04c89cd635cca579ea34746ef7a9..316fdf0445e64c851aeabd94752e81b4e3f2bddb 100644 (file)
@@ -19721,6 +19721,10 @@ virDomainBlockPull(virDomainPtr dom, const char *disk,
  * exists.  If the job is aborted, a new one can be started later to
  * resume from the same point.
  *
+ * If @flags contains VIR_DOMAIN_BLOCK_REBASE_RELATIVE, the name recorded
+ * into the active disk as the location for @base will be kept relative.
+ * The operation will fail if libvirt can't infer the name.
+ *
  * When @flags includes VIR_DOMAIN_BLOCK_REBASE_COPY, this starts a copy,
  * where @base must be the name of a new file to copy the chain to.  By
  * default, the copy will pull the entire source chain into the destination
index ff804c54479dc5027d037371c99bafad73f4fe60..b5b9f91e0edcf48267556badf8de7c4cf58d107f 100644 (file)
@@ -1488,10 +1488,14 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
     case VSH_CMD_BLOCK_JOB_PULL:
         if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0)
             goto cleanup;
-        if (base)
-            ret = virDomainBlockRebase(dom, path, base, bandwidth, 0);
+        if (vshCommandOptBool(cmd, "keep-relative"))
+            flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;
+
+        if (base || flags)
+            ret = virDomainBlockRebase(dom, path, base, bandwidth, flags);
         else
             ret = virDomainBlockPull(dom, path, bandwidth, 0);
+
         break;
     case VSH_CMD_BLOCK_JOB_COMMIT:
         if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0 ||
@@ -2127,6 +2131,10 @@ static const vshCmdOptDef opts_block_pull[] = {
      .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 relatively referenced")
+    },
     {.name = NULL}
 };
 
index 7f0e76a3efb0e9cc2791dfeaec7c3346c82c85eb..99d0b746b4fe7a889a9e61fcc2130939d981a167 100644 (file)
@@ -911,6 +911,7 @@ I<bandwidth> specifies copying bandwidth limit in MiB/s.
 
 =item B<blockpull> I<domain> I<path> [I<bandwidth>] [I<base>]
 [I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async>]]
+[I<--keep-relative>]
 
 Populate a disk from its backing image chain. By default, this command
 flattens the entire chain; but if I<base> is specified, containing the
@@ -930,6 +931,9 @@ is triggered, I<--async> will return control to the user as fast as
 possible, otherwise the command may continue to block a little while
 longer until the job is done cleaning up.
 
+Using the I<--keep-relative> flag will keep the backing chain names
+relative.
+
 I<path> specifies fully-qualified path of the disk; it corresponds
 to a unique target name (<target dev='name'/>) or source file (<source
 file='name'/>) for one of the disk devices attached to I<domain> (see