From 161713436e00a8532be3d936eec095120b8c6a1a Mon Sep 17 00:00:00 2001 From: Nishith Shah Date: Wed, 4 May 2016 14:25:10 +0000 Subject: [PATCH] virsh: blkdeviotune: accept human readable values for bytes https://bugzilla.redhat.com/show_bug.cgi?id=885380 Use vshCommandOptScaledInt instead of vshCommandOptULongLong so that values with suffixes can be passed when bytes are being passed along. Values for the iops parameters still need to be given in the absolute form as they are not bytes but numbers. Signed-off-by: Nishith Shah --- tools/virsh-domain.c | 24 ++++++++++++------------ tools/virsh.pod | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d5108dde78..8d7ff61240 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -1164,7 +1164,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = { }, {.name = "total-bytes-sec", .type = VSH_OT_INT, - .help = N_("total throughput limit in bytes per second") + .help = N_("total throughput limit, as scaled integer (default bytes)") }, {.name = "read_bytes_sec", .type = VSH_OT_ALIAS, @@ -1172,7 +1172,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = { }, {.name = "read-bytes-sec", .type = VSH_OT_INT, - .help = N_("read throughput limit in bytes per second") + .help = N_("read throughput limit, as scaled integer (default bytes)") }, {.name = "write_bytes_sec", .type = VSH_OT_ALIAS, @@ -1180,7 +1180,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = { }, {.name = "write-bytes-sec", .type = VSH_OT_INT, - .help = N_("write throughput limit in bytes per second") + .help = N_("write throughput limit, as scaled integer (default bytes)") }, {.name = "total_iops_sec", .type = VSH_OT_ALIAS, @@ -1212,7 +1212,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = { }, {.name = "total-bytes-sec-max", .type = VSH_OT_INT, - .help = N_("total max in bytes") + .help = N_("total max, as scaled integer (default bytes)") }, {.name = "read_bytes_sec_max", .type = VSH_OT_ALIAS, @@ -1220,7 +1220,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = { }, {.name = "read-bytes-sec-max", .type = VSH_OT_INT, - .help = N_("read max in bytes") + .help = N_("read max, as scaled integer (default bytes)") }, {.name = "write_bytes_sec_max", .type = VSH_OT_ALIAS, @@ -1228,7 +1228,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = { }, {.name = "write-bytes-sec-max", .type = VSH_OT_INT, - .help = N_("write max in bytes") + .help = N_("write max, as scaled integer (default bytes)") }, {.name = "total_iops_sec_max", .type = VSH_OT_ALIAS, @@ -1299,7 +1299,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "device", &disk) < 0) goto cleanup; - if ((rv = vshCommandOptULongLong(ctl, cmd, "total-bytes-sec", &value)) < 0) { + if ((rv = vshCommandOptScaledInt(ctl, cmd, "total-bytes-sec", &value, 1, ULLONG_MAX)) < 0) { goto interror; } else if (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, @@ -1308,7 +1308,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) goto save_error; } - if ((rv = vshCommandOptULongLong(ctl, cmd, "read-bytes-sec", &value)) < 0) { + if ((rv = vshCommandOptScaledInt(ctl, cmd, "read-bytes-sec", &value, 1, ULLONG_MAX)) < 0) { goto interror; } else if (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, @@ -1317,7 +1317,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) goto save_error; } - if ((rv = vshCommandOptULongLong(ctl, cmd, "write-bytes-sec", &value)) < 0) { + if ((rv = vshCommandOptScaledInt(ctl, cmd, "write-bytes-sec", &value, 1, ULLONG_MAX)) < 0) { goto interror; } else if (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, @@ -1326,7 +1326,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) goto save_error; } - if ((rv = vshCommandOptULongLong(ctl, cmd, "total-bytes-sec-max", &value)) < 0) { + if ((rv = vshCommandOptScaledInt(ctl, cmd, "total-bytes-sec-max", &value, 1, ULLONG_MAX)) < 0) { goto interror; } else if (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, @@ -1335,7 +1335,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) goto save_error; } - if ((rv = vshCommandOptULongLong(ctl, cmd, "read-bytes-sec-max", &value)) < 0) { + if ((rv = vshCommandOptScaledInt(ctl, cmd, "read-bytes-sec-max", &value, 1, ULLONG_MAX)) < 0) { goto interror; } else if (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, @@ -1344,7 +1344,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) goto save_error; } - if ((rv = vshCommandOptULongLong(ctl, cmd, "write-bytes-sec-max", &value)) < 0) { + if ((rv = vshCommandOptScaledInt(ctl, cmd, "write-bytes-sec-max", &value, 1, ULLONG_MAX)) < 0) { goto interror; } else if (rv > 0) { if (virTypedParamsAddULLong(¶ms, &nparams, &maxparams, diff --git a/tools/virsh.pod b/tools/virsh.pod index 2a95df7458..6844823b34 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1097,15 +1097,21 @@ I (see also B for listing these names). If no limit is specified, it will query current I/O limits setting. Otherwise, alter the limits with these flags: -I<--total-bytes-sec> specifies total throughput limit in bytes per second. -I<--read-bytes-sec> specifies read throughput limit in bytes per second. -I<--write-bytes-sec> specifies write throughput limit in bytes per second. +I<--total-bytes-sec> specifies total throughput limit as a scaled integer, the +default being bytes per second if no suffix is specified. +I<--read-bytes-sec> specifies read throughput limit as a scaled integer, the +default being bytes per second if no suffix is specified. +I<--write-bytes-sec> specifies write throughput limit as a scaled integer, the +default being bytes per second if no suffix is specified. I<--total-iops-sec> specifies total I/O operations limit per second. I<--read-iops-sec> specifies read I/O operations limit per second. I<--write-iops-sec> specifies write I/O operations limit per second. -I<--total-bytes-sec-max> specifies maximum total throughput limit in bytes per second. -I<--read-bytes-sec-max> specifies maximum read throughput limit in bytes per second. -I<--write-bytes-sec-max> specifies maximum write throughput limit in bytes per second. +I<--total-bytes-sec-max> specifies maximum total throughput limit as a scaled +integer, the default being bytes per second if no suffix is specified +I<--read-bytes-sec-max> specifies maximum read throughput limit as a scaled +integer, the default being bytes per second if no suffix is specified. +I<--write-bytes-sec-max> specifies maximum write throughput limit as a scaled +integer, the default being bytes per second if no suffix is specified. I<--total-iops-sec-max> specifies maximum total I/O operations limit per second. I<--read-iops-sec-max> specifies maximum read I/O operations limit per second. I<--write-iops-sec-max> specifies maximum write I/O operations limit per second. -- GitLab