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

[libvirt] [PATCH 3/3] virsh: expose partial pull



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   |   19 ++++++++++++++-----
 tools/virsh.pod |   12 ++++++++----
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 66ba61c..588c7dd 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7193,14 +7193,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)
@@ -7221,6 +7228,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}
 };

diff --git a/tools/virsh.pod b/tools/virsh.pod
index 6730b8b..f497acd 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -575,10 +575,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>.

-- 
1.7.7.6


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