[PATCH 1/3] vsh: Fix '--help' option for virsh/virt-admin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
Reported-by:  Lili Zhu <lizhu@xxxxxxxxxx>
Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tools/vsh.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index e74045c24e..61a3066f49 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -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;

-- 
2.45.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux