Add a simple helper that returns true if a storage vol definition points
to a volume accessible as a file in the host.
---
src/conf/storage_conf.c | 19 +++++++++++++++++++
src/conf/storage_conf.h | 2 ++
src/libvirt_private.syms | 1 +
3 files changed, 22 insertions(+)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9ac5975..55e44b2 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -335,6 +335,25 @@ virStorageVolDefFree(virStorageVolDefPtr def)
VIR_FREE(def);
}
+/* Returns true if storage volume can be accessed as a file in the host */
+bool
+virStorageVolIsLocalStorage(virStorageVolDefPtr vol)
+{
+ switch ((virStorageVolType) vol->type) {
+ case VIR_STORAGE_VOL_FILE:
+ case VIR_STORAGE_VOL_BLOCK:
+ case VIR_STORAGE_VOL_DIR:
+ return true;
+
+ case VIR_STORAGE_VOL_NETWORK:
+ case VIR_STORAGE_VOL_NETDIR:
+ case VIR_STORAGE_VOL_LAST:
+ return false;
+ }
+
+ return false;
+}
+
static void
virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapter adapter)
{
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 47f769b..175c3b7 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -328,6 +328,8 @@ virStorageVolDefPtr
virStorageVolDefFindByName(virStoragePoolObjPtr pool,
const char *name);
+bool virStorageVolIsLocalStorage(virStorageVolDefPtr vol);
+
void virStoragePoolObjClearVols(virStoragePoolObjPtr pool);
virStoragePoolDefPtr virStoragePoolDefParseString(const char *xml);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e59ea4c..ccb1de7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -764,6 +764,7 @@ virStorageVolDefFree;
virStorageVolDefParseFile;
virStorageVolDefParseNode;
virStorageVolDefParseString;
+virStorageVolIsLocalStorage;
virStorageVolTypeFromString;
virStorageVolTypeToString;
--
2.0.0