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

Re: [libvirt] [PATCH 5/8] Enable the virDomainBlockPull API in virsh



On 06/14/2011 08:36 AM, Adam Litke wrote:
> Define two new virsh commands:
>  * blockpull: Perform block pull operations (incremental plus start
>               and stop continuous streams)
>  * blockpullinfo: Retrieve progress info for continuous block pull

Idea for future expansion - make 'blockpull --all --blocking
[--verbose]' block until the pull completes, along with Ctrl-C to issue
an abort, along with printing stats if --verbose is used.  But that can
come later.

> 
> Share print_job_progress() with the migration code.
> 
> * tools/virsh.c: implement the new commands
> 
> Signed-off-by: Adam Litke <agl us ibm com>
> ---
>  tools/virsh.c |  113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 109 insertions(+), 4 deletions(-)

Good start, but missing virsh.pod documentation.

> @@ -4344,6 +4346,107 @@ done:
>      return ret;
>  }
>  
> +typedef enum {
> +    VSH_CMD_BLOCK_PULL_ONE = 0,
> +    VSH_CMD_BLOCK_PULL_ALL = 1,
> +    VSH_CMD_BLOCK_PULL_ABORT = 2,
> +    VSH_CMD_BLOCK_PULL_INFO = 3
> +} VSH_CMD_BLOCK_PULL_MODE;

We prefer camelCase for enum typedef names.

> +
> +static bool
> +cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
> +{
> +    virDomainBlockPullInfo info;
> +    int mode;
> +
> +    if (vshCommandOptBool (cmd, "all"))

Formatting nit - no space before arguments to function call.

> +        mode = VSH_CMD_BLOCK_PULL_ALL;
> +    else if (vshCommandOptBool (cmd, "abort"))
> +        mode = VSH_CMD_BLOCK_PULL_ABORT;

'virsh blockpull --all --abort' should error out, since they are
mutually exclusive.

ACK with this squashed in, so I pushed:

diff --git i/tools/virsh.c w/tools/virsh.c
index 51a89d4..19db058 100644
--- i/tools/virsh.c
+++ w/tools/virsh.c
@@ -4573,7 +4573,7 @@ typedef enum {
     VSH_CMD_BLOCK_PULL_ALL = 1,
     VSH_CMD_BLOCK_PULL_ABORT = 2,
     VSH_CMD_BLOCK_PULL_INFO = 3
-} VSH_CMD_BLOCK_PULL_MODE;
+} vshCmdBlockPullMode;

 static int
 blockPullImpl(vshControl *ctl, const vshCmd *cmd,
@@ -4627,10 +4627,17 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainBlockPullInfo info;
     int mode;
+    bool all = vshCommandOptBool(cmd, "all");
+    bool do_abort = vshCommandOptBool(cmd, "abort");

-    if (vshCommandOptBool (cmd, "all"))
+    if (all && do_abort) {
+        vshError(ctl, "%s", _("--all and --abort are mutually exclusive"));
+        return false;
+    }
+
+    if (all)
         mode = VSH_CMD_BLOCK_PULL_ALL;
-    else if (vshCommandOptBool (cmd, "abort"))
+    else if (do_abort)
         mode = VSH_CMD_BLOCK_PULL_ABORT;
     else
         mode = VSH_CMD_BLOCK_PULL_ONE;
diff --git i/tools/virsh.pod w/tools/virsh.pod
index c3f521a..c6879cb 100644
--- i/tools/virsh.pod
+++ w/tools/virsh.pod
@@ -371,6 +371,20 @@ Configure a domain to be automatically started at boot.

 The option I<--disable> disables autostarting.

+=item B<blockpull> I<domain-id> I<path> optional { I<--all> | I<--abort> }
+
+Request that the hypervisor update a thin-provisioned I<disk> (a disk
+image belonging to I<domain-id>) by pulling data from the backing
+source into the main disk image.  This command defaults to pulling one
+block at a time.  Using I<--all> requests that all data be pulled in
+the background, and progress can be tracked with B<blockpullinfo>.
+Using <--abort> will stop a long-running <--all>.
+
+=item B<blockpullinfo> I<domain-id> I<disk>
+
+Get information about the current status of a B<blockpull> operation
+started on B<disk>.
+
 =item B<console> I<domain-id> [I<devname>]

 Connect the virtual serial console for the guest. The optional

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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