},
{.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,
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;
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;
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
listed in MiB/s and human-readable output automatically selects the
best resolution supported by the server.
-I<bandwidth> can be used to set bandwidth limit for the active job.
-Specifying a negative value is interpreted as an unsigned long long
+I<bandwidth> 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<NOTES> 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<blockresize> I<domain> I<path> I<size>