[libvirt] [PATCH 2/2] vsh: Cmd aliases lookups should return results for the aliased command

Erik Skultety posted 2 patches 7 years, 10 months ago
[libvirt] [PATCH 2/2] vsh: Cmd aliases lookups should return results for the aliased command
Posted by Erik Skultety 7 years, 10 months ago
Unfortunately, we have a number of aliases in virsh and even though
these are not visible any more, we have to support them. The problem is
that when trying to print help for the alias, we get SIGSEGV because
there isn't any @def structure anymore and we need to query the command
being aliased instead.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1538570

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 tools/vsh.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/vsh.c b/tools/vsh.c
index 761d2ec3a..37c292a03 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3194,6 +3194,8 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
     }
 
     if ((def = vshCmddefSearch(name))) {
+        if (def->flags & VSH_CMD_FLAG_ALIAS)
+            def = vshCmddefSearch(def->alias);
         return vshCmddefHelp(ctl, def);
     } else if ((grp = vshCmdGrpSearch(name))) {
         return vshCmdGrpHelp(ctl, grp);
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list