]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virt-admin: Annodate 'unwanted_positional' arguments
authorPeter Krempa <pkrempa@redhat.com>
Thu, 14 Mar 2024 16:17:19 +0000 (17:17 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2024 12:24:30 +0000 (14:24 +0200)
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
 <domainsnapshot>
   <name>2</name>
   <description>3</description>
 </domainsnapshot>

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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virt-admin.c

index 6392caf854e2ad388c924be798814b4f7c01d15c..e369c02f6cd0d8b5eea01bc6e4514ba7efa7a997 100644 (file)
@@ -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
     },