]> xenbits.xensource.com Git - libvirt.git/commitdiff
vsh: Fix '--help' option for virsh/virt-admin
authorPeter Krempa <pkrempa@redhat.com>
Wed, 15 May 2024 06:42:57 +0000 (08:42 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 16 May 2024 07:03:48 +0000 (09:03 +0200)
The refactor of the libvirt tools command parser introduced a bug where
the '--help' option would cause an error:

 $ virsh list --help
 error: command 'list' doesn't support option --help

rather than printing the help for the command as the help option is
supposed to be handled separately from the real options.

Re-introduce the separate handling to the new parser code.

Fixes: 5540c3d2415c194b206f8946cf74b13648163332
Resolves: https://issues.redhat.com/browse/RHEL-36565
Reported-by: Lili Zhu <lizhu@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
tools/vsh.c

index e74045c24eba9c6a80d5946355f188c2f1556923..61a3066f49faec49bc21c60ca7323c4c66c47074 100644 (file)
@@ -1655,7 +1655,10 @@ vshCommandParse(vshControl *ctl,
 
             /* lookup the option. Note that vshCmdGetOption also resolves aliases
              * and thus the value possibly contained in the alias */
-            if (!(opt = vshCmdGetOption(ctl, cmd, optionname, &optionvalue, report))) {
+            if (STREQ(optionname, "help")) {
+                cmd->helpOptionSeen = true;
+                g_clear_pointer(&optionvalue, g_free);
+            } else if (!(opt = vshCmdGetOption(ctl, cmd, optionname, &optionvalue, report))) {
                 if (STRNEQ(cmd->def->name, "help"))
                     goto out;