]> xenbits.xensource.com Git - libvirt.git/commitdiff
vsh: Fix broken assumption that required VSH_OT_INT must be positional
authorPeter Krempa <pkrempa@redhat.com>
Tue, 5 Mar 2024 15:00:41 +0000 (16:00 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Mar 2024 14:02:52 +0000 (15:02 +0100)
In at least one case we've wanted a mandatory argument which requires
the explicit flag. Fix the assumption before converting everything over
to the new flags.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virt-admin.c
tools/vsh.c

index d266d824cb4f2f4b70941057c70aadd79978af15..2e8895956d56e9c6a6fce3ca3c724bb0e6c298ed 100644 (file)
@@ -1011,7 +1011,6 @@ static const vshCmdInfo info_daemon_log_outputs = {
 static const vshCmdOptDef opts_daemon_timeout[] = {
     {.name = "timeout",
      .type = VSH_OT_INT,
-     .positional = true,
      .required = true,
      .help = N_("number of seconds the daemon will run without any active connection"),
      .flags = VSH_OFLAG_REQ | VSH_OFLAG_REQ_OPT
index f059434b1a2a6951c178e32c73664374682818bb..33a9dcdfe87ad5d9de9496f99b467a1cb421472e 100644 (file)
@@ -426,9 +426,14 @@ vshCmddefCheckInternals(vshControl *ctl,
                              opt->name, cmd->name);
                     return -1;
                 }
-                seenPositionalOption = true;
-                isPositional = true;
+
                 isRequired = true;
+
+                /* allow INT arguments which are required and non-positional */
+                if (!(opt->flags & VSH_OFLAG_REQ_OPT)) {
+                    seenPositionalOption = true;
+                    isPositional = true;
+                }
             } else {
                 isPositional = false;
                 isRequired = false;