Blob Blame History Raw
From 4e9c6305c18f2501c21fef08c9b9589ef87dce1f Mon Sep 17 00:00:00 2001
Message-Id: <4e9c6305c18f2501c21fef08c9b9589ef87dce1f@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 26 Feb 2014 14:55:14 +0100
Subject: [PATCH] storage: Add gluster pool filter and fix virsh pool listing

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

Recent addition of the gluster pool type omitted fixing the virsh and
virConnectListAllStoragePool filters. A typecast of the converting
function in virsh showed that also the sheepdog pool was omitted in the
command parser.

This patch adds gluster pool filtering support and fixes virsh to
properly convert all supported storage pool types. The added typecast
should avoid doing such mistakes in the future.

(cherry picked from commit b560946c19dfdf1ab04ad01baf4cf9624e6399cc)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 include/libvirt/libvirt.h.in |  1 +
 src/conf/storage_conf.c      |  4 +++-
 tools/virsh-pool.c           | 10 ++++++++--
 tools/virsh.pod              |  2 +-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 4e98bcc..3cacfcd 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3042,6 +3042,7 @@ typedef enum {
     VIR_CONNECT_LIST_STORAGE_POOLS_MPATH         = 1 << 13,
     VIR_CONNECT_LIST_STORAGE_POOLS_RBD           = 1 << 14,
     VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG      = 1 << 15,
+    VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER       = 1 << 16,
 } virConnectListAllStoragePoolsFlags;
 
 int                     virConnectListAllStoragePools(virConnectPtr conn,
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index e64b331..8f9d820 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -2217,7 +2217,9 @@ virStoragePoolMatch(virStoragePoolObjPtr poolobj,
               (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_RBD) &&
                (poolobj->def->type == VIR_STORAGE_POOL_RBD))     ||
               (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG) &&
-               (poolobj->def->type == VIR_STORAGE_POOL_SHEEPDOG))))
+               (poolobj->def->type == VIR_STORAGE_POOL_SHEEPDOG)) ||
+              (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER) &&
+               (poolobj->def->type == VIR_STORAGE_POOL_GLUSTER))))
             return false;
     }
 
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index e52d676..0aaee43 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -1006,7 +1006,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
                 return false;
             }
 
-            switch (poolType) {
+            switch ((enum virStoragePoolType) poolType) {
             case VIR_STORAGE_POOL_DIR:
                 flags |= VIR_CONNECT_LIST_STORAGE_POOLS_DIR;
                 break;
@@ -1034,7 +1034,13 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
             case VIR_STORAGE_POOL_RBD:
                 flags |= VIR_CONNECT_LIST_STORAGE_POOLS_RBD;
                 break;
-            default:
+            case VIR_STORAGE_POOL_SHEEPDOG:
+                flags |= VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG;
+                break;
+            case VIR_STORAGE_POOL_GLUSTER:
+                flags |= VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER;
+                break;
+            case VIR_STORAGE_POOL_LAST:
                 break;
             }
         }
diff --git a/tools/virsh.pod b/tools/virsh.pod
index e866217..f1b09d9 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2584,7 +2584,7 @@ with autostarting disabled.
 You may also want to list pools with specified types using I<type>, the
 pool types must be separated by comma, e.g. --type dir,disk. The valid pool
 types include 'dir', 'fs', 'netfs', 'logical', 'disk', 'iscsi', 'scsi',
-'mpath', 'rbd', and 'sheepdog'.
+'mpath', 'rbd', 'sheepdog' and 'gluster'.
 
 The I<--details> option instructs virsh to additionally
 display pool persistence and capacity related information where available.
-- 
1.9.0