[PATCH] virsh: fixing segfault by pool autocompleter function.

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

 



The commands which requires a pool to perform any action for a volume is
throwing a segfault when you pass the volume name before a pool name or
without the argument '--pool'.

An example that works:
virsh # vol-list loops-pool
 Name                 Path
-------------------------------------------------------------------
 loop0                /mnt/loop0

virsh # vol-info --pool loops-pool lo<TAB>

An example that does not work:
virsh # vol-list loops-pool
 Name                 Path
-------------------------------------------------------------------
 loop0                /mnt/loop0

virsh # vol-info lo<TAB>
Segmentation Fault

The example 'vol-info' can be executed as 'vol-info loop0 --pool
loops-pool'. So, this commit fixes this problem when the arguments are
inverted and avoids the segfault.

Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx>
---
 tools/virsh-pool.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 56b6cfc73..24a4d1ee7 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -143,6 +143,9 @@ virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname,
     if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0)
         return NULL;
 
+    if (!n)
+        return NULL;
+
     vshDebug(ctl, VSH_ERR_INFO, "%s: found option <%s>: %s\n",
              cmd->def->name, optname, n);
 
-- 
2.14.1

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



[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