]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: expose partial pull
authorEric Blake <eblake@redhat.com>
Sat, 18 Feb 2012 16:55:45 +0000 (09:55 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 29 Feb 2012 20:44:20 +0000 (13:44 -0700)
Now virsh can call virDomainBlockRebase.

* tools/virsh.c (cmdBlockPull): Add --base parameter.
(blockJobImpl): Use it to expose BlockRebase API.
* tools/virsh.pod (blockpull): Document it.

tools/virsh.c
tools/virsh.pod

index 3b34f7e914a423eb8522e26ea4263db9ef7de211..dc362dcebdf814f04684800a87b7e31382bd02e6 100644 (file)
@@ -7349,14 +7349,21 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
         goto cleanup;
     }
 
-    if (mode == VSH_CMD_BLOCK_JOB_ABORT)
+    if (mode == VSH_CMD_BLOCK_JOB_ABORT) {
         ret = virDomainBlockJobAbort(dom, path, 0);
-    else if (mode == VSH_CMD_BLOCK_JOB_INFO)
+    } else if (mode == VSH_CMD_BLOCK_JOB_INFO) {
         ret = virDomainGetBlockJobInfo(dom, path, info, 0);
-    else if (mode == VSH_CMD_BLOCK_JOB_SPEED)
+    } else if (mode == VSH_CMD_BLOCK_JOB_SPEED) {
         ret = virDomainBlockJobSetSpeed(dom, path, bandwidth, 0);
-    else if (mode == VSH_CMD_BLOCK_JOB_PULL)
-        ret = virDomainBlockPull(dom, path, bandwidth, 0);
+    } else if (mode == VSH_CMD_BLOCK_JOB_PULL) {
+        const char *base = NULL;
+        if (vshCommandOptString(cmd, "base", &base) < 0)
+            goto cleanup;
+        if (base)
+            ret = virDomainBlockRebase(dom, path, base, bandwidth, 0);
+        else
+            ret = virDomainBlockPull(dom, path, bandwidth, 0);
+    }
 
 cleanup:
     if (dom)
@@ -7377,6 +7384,8 @@ static const vshCmdOptDef opts_block_pull[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"path", VSH_OT_DATA, VSH_OFLAG_REQ, N_("Fully-qualified path of disk")},
     {"bandwidth", VSH_OT_DATA, VSH_OFLAG_NONE, N_("Bandwidth limit in MB/s")},
+    {"base", VSH_OT_DATA, VSH_OFLAG_NONE,
+     N_("path of backing file in chain for a partial pull")},
     {NULL, 0, 0, NULL}
 };
 
index b7dcef5291bed227760de50df3007862ab138ce3..8f6a2d6d890076df16f808ed9507d447e90966a0 100644 (file)
@@ -598,10 +598,14 @@ currently in use by a running domain. Other contexts that require a MAC
 address of virtual interface (such as I<detach-interface> or
 I<domif-setlink>) will accept the MAC address printed by this command.
 
-=item B<blockpull> I<domain> I<path> [I<bandwidth>]
-
-Populate a disk from its backing image. Once all data from its backing
-image has been pulled, the disk no longer depends on the backing image.
+=item B<blockpull> I<domain> I<path> [I<bandwidth>] [I<base>]
+
+Populate a disk from its backing image chain. By default, this command
+flattens the entire chain; but if I<base> is specified, containing the
+name of one of the backing files in the chain, then that file becomes
+the new backing file and only the intermediate portion of the chain is
+pulled.  Once all requested data from the backing image chain has been
+pulled, the disk no longer depends on that portion of the backing chain.
 It pulls data for the entire disk in the background, the process of the
 operation can be checked with B<blockjob>.