From a67f737ddfc59b0f5b3905bd1c0935ced82de3d0 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 14 Mar 2024 17:17:19 +0100 Subject: [PATCH] virt-admin: Annodate 'unwanted_positional' arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Historically the command parser in virsh parses/fills even optional arguments with values as if they were positional unless opted out using VSH_OFLAG_REQ_OPT. This creates unexpected situations when commands can break in this unwanted semantics: $ virsh snapshot-create-as --print-xml 1 2 3 2 3 To prevent any further addition annotate the rest of the arguments with the 'unwanted_positional' flag, so that the parser can keep parsing them as such but any further optional argument will not have this behaviour. Certain arguments where it makes sense are annotated as 'positional' too in this patch. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tools/virt-admin.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 6392caf854..e369c02f6c 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -425,14 +425,17 @@ static const vshCmdOptDef opts_srv_threadpool_set[] = { }, {.name = "min-workers", .type = VSH_OT_INT, + .unwanted_positional = true, .help = N_("Change bottom limit to number of workers."), }, {.name = "max-workers", .type = VSH_OT_INT, + .unwanted_positional = true, .help = N_("Change upper limit to number of workers."), }, {.name = "priority-workers", .type = VSH_OT_INT, + .unwanted_positional = true, .help = N_("Change the current number of priority workers"), }, {.name = NULL} @@ -812,11 +815,13 @@ static const vshCmdOptDef opts_srv_clients_set[] = { }, {.name = "max-clients", .type = VSH_OT_INT, + .unwanted_positional = true, .help = N_("Change the upper limit to overall number of clients " "connected to the server."), }, {.name = "max-unauth-clients", .type = VSH_OT_INT, + .unwanted_positional = true, .help = N_("Change the upper limit to number of clients waiting for " "authentication to be connected to the server"), }, @@ -954,6 +959,7 @@ static const vshCmdInfo info_daemon_log_filters = { static const vshCmdOptDef opts_daemon_log_filters[] = { {.name = "filters", .type = VSH_OT_STRING, + .positional = true, .help = N_("redefine the existing set of logging filters"), .flags = VSH_OFLAG_EMPTY_OK }, @@ -1037,6 +1043,7 @@ static const vshCmdInfo info_daemon_timeout = { static const vshCmdOptDef opts_daemon_log_outputs[] = { {.name = "outputs", .type = VSH_OT_STRING, + .positional = true, .help = N_("redefine the existing set of logging outputs"), .flags = VSH_OFLAG_EMPTY_OK },