[libvirt] [PATCH v6 06/13] virstoragefile: Add virStorageSourceIsRAID

Matthias Gatto matthias.gatto at outscale.com
Thu Oct 29 13:43:13 UTC 2015


Add a new function which return true if a virStorageSourcePtr is
a RAID.

For now, quorum is the only RAID we have.

This function is usefull, because, a lot of code access directly
to a virStorageSource internal member (like path) with some functions
like "virDomainDiskGetSource".
This beavious won't work with Quorum, and so we need to add
exeptions for these functions, but I'm not convinced by the idea to add a lot
of "disk->format == QUORUM" in all the code that deserve
exeption for Quorum, so I've add a generic function for this.

Signed-off-by: Matthias Gatto <matthias.gatto at outscale.com>
---
 src/libvirt_private.syms  |  1 +
 src/util/virstoragefile.c | 27 +++++++++++++++++++++++++++
 src/util/virstoragefile.h |  2 ++
 3 files changed, 30 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 4aa923a..efcea49 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2168,6 +2168,7 @@ virStorageSourceGetSecurityLabelDef;
 virStorageSourceInitChainElement;
 virStorageSourceIsEmpty;
 virStorageSourceIsLocalStorage;
+virStorageSourceIsRAID;
 virStorageSourceNewFromBacking;
 virStorageSourceParseRBDColonString;
 virStorageSourcePoolDefFree;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 44bce91..a9cc0c8 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1808,6 +1808,33 @@ virStorageSourcePoolDefCopy(const virStorageSourcePoolDef *src)
     return NULL;
 }
 
+/**
+ * virStorageSourceIsRAID:
+ * return true if the backingStores field inside @src is use
+ * as a child of a contener
+ */
+bool virStorageSourceIsRAID(virStorageSourcePtr src)
+{
+    virStorageType type;
+
+    if (!src)
+        return false;
+    type = virStorageSourceGetActualType(src);
+    switch (type) {
+    case VIR_STORAGE_TYPE_NONE:
+    case VIR_STORAGE_TYPE_FILE:
+    case VIR_STORAGE_TYPE_BLOCK:
+    case VIR_STORAGE_TYPE_DIR:
+    case VIR_STORAGE_TYPE_NETWORK:
+    case VIR_STORAGE_TYPE_VOLUME:
+    case VIR_STORAGE_TYPE_LAST:
+        return false;
+
+    case VIR_STORAGE_TYPE_QUORUM:
+        return true;
+    }
+    return false;
+}
 
 /**
  * virStorageSourceGetBackingStore:
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 5f76b4b..c9f2afa 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -290,6 +290,8 @@ struct _virStorageSource {
 #  define DEV_BSIZE 512
 # endif
 
+bool virStorageSourceIsRAID(virStorageSourcePtr src);
+
 bool virStorageSourceSetBackingStore(virStorageSourcePtr src,
                                      virStorageSourcePtr backingStore,
                                      size_t pos);
-- 
2.6.1




More information about the libvir-list mailing list