diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index cecab63b38..c24710231e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2492,7 +2492,7 @@ static const vshCmdOptDef opts_block_job[] = { }, {.name = "bytes", .type = VSH_OT_BOOL, - .help = N_("with --info, get bandwidth in bytes rather than MiB/s") + .help = N_("get/set bandwidth in bytes rather than MiB/s") }, {.name = "raw", .type = VSH_OT_BOOL, @@ -2611,14 +2611,19 @@ static bool virshBlockJobSetSpeed(vshControl *ctl, const vshCmd *cmd, virDomainPtr dom, - const char *path) + const char *path, + bool bytes) { unsigned long bandwidth; + unsigned int flags = 0; - if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0) + if (bytes) + flags |= VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES; + + if (vshBlockJobOptionBandwidth(ctl, cmd, bytes, &bandwidth) < 0) return false; - if (virDomainBlockJobSetSpeed(dom, path, bandwidth, 0) < 0) + if (virDomainBlockJobSetSpeed(dom, path, bandwidth, flags) < 0) return false; return true; @@ -2672,8 +2677,6 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS("bytes", "abort"); VSH_EXCLUSIVE_OPTIONS_VAR(bytes, pivot); VSH_EXCLUSIVE_OPTIONS_VAR(bytes, async); - /* XXX also support --bytes with bandwidth mode */ - VSH_EXCLUSIVE_OPTIONS_VAR(bytes, bandwidth); if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; @@ -2683,7 +2686,7 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd) goto cleanup; if (bandwidth) - ret = virshBlockJobSetSpeed(ctl, cmd, dom, path); + ret = virshBlockJobSetSpeed(ctl, cmd, dom, path, bytes); else if (abortMode || pivot || async) ret = virshBlockJobAbort(dom, path, pivot, async); else diff --git a/tools/virsh.pod b/tools/virsh.pod index 95951993ad..eb4e147752 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1155,10 +1155,15 @@ not supply bytes/s resolution; when omitting the flag, raw output is listed in MiB/s and human-readable output automatically selects the best resolution supported by the server. -I can be used to set bandwidth limit for the active job. -Specifying a negative value is interpreted as an unsigned long long +I can be used to set bandwidth limit for the active job in MiB/s. +If I<--bytes> is specified then the bandwidth value is interpreted in +bytes/s. Specifying a negative value is interpreted as an unsigned long value or essentially unlimited. The hypervisor can choose whether to -reject the value or convert it to the maximum value allowed. +reject the value or convert it to the maximum value allowed. Optionally a +scaled positive number may be used as bandwidth (see B above). Using +I<--bytes> with a scaled value allows to use finer granularity. A scaled value +used without I<--bytes> will be rounded down to MiB/s. Note that the +I<--bytes> may be unsupported by the hypervisor. =item B I I I