[libvirt] [PATCH v3 09/18] blockjob: add new --bytes flag to virsh blockjob

Eric Blake eblake at redhat.com
Fri Sep 5 19:13:16 UTC 2014


On 09/05/2014 03:05 AM, Peter Krempa wrote:
> On 08/31/14 06:02, Eric Blake wrote:
>> Expose the new flag just added to virDomainGetBlockJobInfo.
>> With --raw, the presence or absence of --bytes determines which
>> flag to use in the single API call.  Without --raw, the use of
>> --bytes forces an error if the server doesn't support it,
>> otherwise, the code tries to silently fall back to scaling the
>> MiB/s value.
>>
>> My goal is to eventually also support --bytes in bandwidth mode;
>> but that's a bit further down the road (and needs a new API flag
>> added in libvirt.h first).

the new flag hinted at is patch 14/14; I'm still working on the code for
a v4 patch for actually setting in byte mode.

> 
> ACK
> 

Pushed with a tweak I found during self-review:

diff --git i/tools/virsh-domain.c w/tools/virsh-domain.c
index 749fa67..2bb3bbc 100644
--- i/tools/virsh-domain.c
+++ w/tools/virsh-domain.c
@@ -2121,7 +2121,7 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0)
         goto cleanup;

-    /* If bytes were requested, or if raw mode is not forcing MiB/s
+    /* If bytes were requested, or if raw mode is not forcing a MiB/s
      * query and cache can't prove failure, then query bytes/sec.  */
     if (bytes || !(raw || ctl->blockJobNoBytes)) {
         flags |= VIR_DOMAIN_BLOCK_JOB_INFO_BANDWIDTH_BYTES;
@@ -2154,9 +2154,11 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
         /* Scale to bytes/s unless in raw mode */
         if (!raw) {
             speed <<= 20;
-            if (speed >> 20 != info.bandwidth)
+            if (speed >> 20 != info.bandwidth) {
                 vshError(ctl, _("overflow in converting %ld MiB/s to
bytes\n"),
                          info.bandwidth);
+                goto cleanup;
+            }
         }
     }


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140905/8ff575ab/attachment-0001.sig>


More information about the libvir-list mailing list