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 <nishithshah.2211@gmail.com>
This commit is contained in:
Nishith Shah 2016-05-04 14:25:10 +00:00 committed by Michal Privoznik
parent 99c17cb205
commit 161713436e
2 changed files with 24 additions and 18 deletions

View File

@ -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(&params, &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(&params, &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(&params, &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(&params, &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(&params, &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(&params, &nparams, &maxparams,

View File

@ -1097,15 +1097,21 @@ I<domain> (see also B<domblklist> 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.