virsh: Require option flags for 'blkdeviotune' arguments

Make all of the tunable parameter flags require the option name (don't
parse them positionally).

While techically this would be a breaking change if anyone were to
specify the tunable values positionally this is not the case as the
first two tunables are not compatible with each other:

  $ virsh blkdeviotune cd vda 4 5
  error: Unable to change block I/O throttle
  error: invalid argument: total and read/write of bytes_sec cannot be set at the same time

The above is produced by all implementations of the API (qemu and test
drivers). It is true that the first tunable can be specified
positionally (--total-bytes-sec) but it is misleading and shoud not be
allowed either.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2024-03-13 22:50:02 +01:00
parent baa20d6eb8
commit 39218865f4

View File

@ -1204,6 +1204,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "total-bytes-sec", {.name = "total-bytes-sec",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("total throughput limit, as scaled integer (default bytes)") .help = N_("total throughput limit, as scaled integer (default bytes)")
}, },
{.name = "read_bytes_sec", {.name = "read_bytes_sec",
@ -1212,6 +1213,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "read-bytes-sec", {.name = "read-bytes-sec",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("read throughput limit, as scaled integer (default bytes)") .help = N_("read throughput limit, as scaled integer (default bytes)")
}, },
{.name = "write_bytes_sec", {.name = "write_bytes_sec",
@ -1220,6 +1222,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "write-bytes-sec", {.name = "write-bytes-sec",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("write throughput limit, as scaled integer (default bytes)") .help = N_("write throughput limit, as scaled integer (default bytes)")
}, },
{.name = "total_iops_sec", {.name = "total_iops_sec",
@ -1228,6 +1231,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "total-iops-sec", {.name = "total-iops-sec",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("total I/O operations limit per second") .help = N_("total I/O operations limit per second")
}, },
{.name = "read_iops_sec", {.name = "read_iops_sec",
@ -1236,6 +1240,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "read-iops-sec", {.name = "read-iops-sec",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("read I/O operations limit per second") .help = N_("read I/O operations limit per second")
}, },
{.name = "write_iops_sec", {.name = "write_iops_sec",
@ -1244,6 +1249,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "write-iops-sec", {.name = "write-iops-sec",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("write I/O operations limit per second") .help = N_("write I/O operations limit per second")
}, },
{.name = "total_bytes_sec_max", {.name = "total_bytes_sec_max",
@ -1252,6 +1258,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "total-bytes-sec-max", {.name = "total-bytes-sec-max",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("total max, as scaled integer (default bytes)") .help = N_("total max, as scaled integer (default bytes)")
}, },
{.name = "read_bytes_sec_max", {.name = "read_bytes_sec_max",
@ -1260,6 +1267,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "read-bytes-sec-max", {.name = "read-bytes-sec-max",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("read max, as scaled integer (default bytes)") .help = N_("read max, as scaled integer (default bytes)")
}, },
{.name = "write_bytes_sec_max", {.name = "write_bytes_sec_max",
@ -1268,6 +1276,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "write-bytes-sec-max", {.name = "write-bytes-sec-max",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("write max, as scaled integer (default bytes)") .help = N_("write max, as scaled integer (default bytes)")
}, },
{.name = "total_iops_sec_max", {.name = "total_iops_sec_max",
@ -1276,6 +1285,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "total-iops-sec-max", {.name = "total-iops-sec-max",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("total I/O operations max") .help = N_("total I/O operations max")
}, },
{.name = "read_iops_sec_max", {.name = "read_iops_sec_max",
@ -1284,6 +1294,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "read-iops-sec-max", {.name = "read-iops-sec-max",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("read I/O operations max") .help = N_("read I/O operations max")
}, },
{.name = "write_iops_sec_max", {.name = "write_iops_sec_max",
@ -1292,6 +1303,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "write-iops-sec-max", {.name = "write-iops-sec-max",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("write I/O operations max") .help = N_("write I/O operations max")
}, },
{.name = "size_iops_sec", {.name = "size_iops_sec",
@ -1300,6 +1312,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "size-iops-sec", {.name = "size-iops-sec",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("I/O size in bytes") .help = N_("I/O size in bytes")
}, },
{.name = "group_name", {.name = "group_name",
@ -1308,6 +1321,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "group-name", {.name = "group-name",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.flags = VSH_OFLAG_REQ_OPT,
.completer = virshCompleteEmpty, .completer = virshCompleteEmpty,
.help = N_("group name to share I/O quota between multiple drives") .help = N_("group name to share I/O quota between multiple drives")
}, },
@ -1317,6 +1331,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "total-bytes-sec-max-length", {.name = "total-bytes-sec-max-length",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("duration in seconds to allow total max bytes") .help = N_("duration in seconds to allow total max bytes")
}, },
{.name = "read_bytes_sec_max_length", {.name = "read_bytes_sec_max_length",
@ -1325,6 +1340,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "read-bytes-sec-max-length", {.name = "read-bytes-sec-max-length",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("duration in seconds to allow read max bytes") .help = N_("duration in seconds to allow read max bytes")
}, },
{.name = "write_bytes_sec_max_length", {.name = "write_bytes_sec_max_length",
@ -1333,6 +1349,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "write-bytes-sec-max-length", {.name = "write-bytes-sec-max-length",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("duration in seconds to allow write max bytes") .help = N_("duration in seconds to allow write max bytes")
}, },
{.name = "total_iops_sec_max_length", {.name = "total_iops_sec_max_length",
@ -1341,6 +1358,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "total-iops-sec-max-length", {.name = "total-iops-sec-max-length",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("duration in seconds to allow total I/O operations max") .help = N_("duration in seconds to allow total I/O operations max")
}, },
{.name = "read_iops_sec_max_length", {.name = "read_iops_sec_max_length",
@ -1349,6 +1367,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "read-iops-sec-max-length", {.name = "read-iops-sec-max-length",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("duration in seconds to allow read I/O operations max") .help = N_("duration in seconds to allow read I/O operations max")
}, },
{.name = "write_iops_sec_max_length", {.name = "write_iops_sec_max_length",
@ -1357,6 +1376,7 @@ static const vshCmdOptDef opts_blkdeviotune[] = {
}, },
{.name = "write-iops-sec-max-length", {.name = "write-iops-sec-max-length",
.type = VSH_OT_INT, .type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ_OPT,
.help = N_("duration in seconds to allow write I/O operations max") .help = N_("duration in seconds to allow write I/O operations max")
}, },
VIRSH_COMMON_OPT_DOMAIN_CONFIG, VIRSH_COMMON_OPT_DOMAIN_CONFIG,