From d40d18fb8f09aabc08861ad573c40727e7d475dd Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 17 Mar 2016 13:41:00 +0100 Subject: [PATCH] virsh: blockpull: Support --bytes and scaled integers Use vshBlockJobOptionBandwidth to parse the bandwidth value which will allow users to specify bandwidth in bytes or as a scaled integer. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1288000 --- tools/virsh-domain.c | 15 +++++++++++++-- tools/virsh.pod | 9 ++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 510f68128b..cda442db21 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2761,6 +2761,10 @@ static const vshCmdOptDef opts_block_pull[] = { .type = VSH_OT_BOOL, .help = N_("keep the backing chain relatively referenced") }, + {.name = "bytes", + .type = VSH_OT_BOOL, + .help = N_("the bandwidth limit is in bytes/s rather than MiB/s") + }, {.name = NULL} }; @@ -2772,6 +2776,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd) bool blocking = vshCommandOptBool(cmd, "wait"); bool verbose = vshCommandOptBool(cmd, "verbose"); bool async = vshCommandOptBool(cmd, "async"); + bool bytes = vshCommandOptBool(cmd, "bytes"); int timeout = 0; const char *path = NULL; const char *base = NULL; @@ -2788,7 +2793,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "base", &base) < 0) return false; - if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0) + if (vshBlockJobOptionBandwidth(ctl, cmd, bytes, &bandwidth) < 0) return false; if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) @@ -2806,10 +2811,16 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd) goto cleanup; if (base || flags) { + if (bytes) + flags |= VIR_DOMAIN_BLOCK_REBASE_BANDWIDTH_BYTES; + if (virDomainBlockRebase(dom, path, base, bandwidth, flags) < 0) goto cleanup; } else { - if (virDomainBlockPull(dom, path, bandwidth, 0) < 0) + if (bytes) + flags |= VIR_DOMAIN_BLOCK_PULL_BANDWIDTH_BYTES; + + if (virDomainBlockPull(dom, path, bandwidth, flags) < 0) goto cleanup; } diff --git a/tools/virsh.pod b/tools/virsh.pod index b1d859416f..0c02d7f4e3 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1049,7 +1049,7 @@ within a certain range. Specifying I will control how much data can be simultaneously in-flight during the copy; larger values use more memory but may allow faster completion (the default value is usually correct). -=item B I I [I] [I] +=item B I I [I] [I<--bytes>] [I] [I<--wait> [I<--verbose>] [I<--timeout> B] [I<--async>]] [I<--keep-relative>] @@ -1078,10 +1078,9 @@ I specifies fully-qualified path of the disk; it corresponds to a unique target name () or source file () for one of the disk devices attached to I (see also B for listing these names). -I specifies copying bandwidth limit in MiB/s. Specifying a negative -value is interpreted as an unsigned long long value or essentially -unlimited. The hypervisor can choose whether to reject the value or -convert it to the maximum value allowed. +I specifies copying bandwidth limit in MiB/s. For further information +on the I argument see the corresponding section for the B +command. =item B I I [[I<--config>] [I<--live>] | [I<--current>]] -- GitLab