There's a lot of places where we skip doing actions based on the
locality of given storage type. The usual pattern is to skip it if:

virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK

Add a simple helper to simplify the pattern to
virStorageSourceIsLocalStorage(src)
---
 src/libvirt_private.syms  | 1 +
 src/util/virstoragefile.c | 7 +++++++
 src/util/virstoragefile.h | 1 +
 3 files changed, 9 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 98595e1..889ae04 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1915,6 +1915,7 @@ virStorageSourceCopy;
 virStorageSourceFree;
 virStorageSourceGetActualType;
 virStorageSourceGetSecurityLabelDef;
+virStorageSourceIsLocalStorage;
 virStorageSourceNewFromBacking;
 virStorageSourcePoolDefFree;
 virStorageSourcePoolModeTypeFromString;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 5f8e02d..965c3ea 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1718,6 +1718,13 @@ virStorageSourceGetActualType(virStorageSourcePtr def)
 }


+bool
+virStorageSourceIsLocalStorage(virStorageSourcePtr src)
+{
+    return virStorageSourceGetActualType(src) != VIR_STORAGE_TYPE_NETWORK;
+}
+
+
 /**
  * virStorageSourceBackingStoreClear:
  *
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 3e13071..ee85ca5 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -329,6 +329,7 @@ void virStorageSourceAuthClear(virStorageSourcePtr def);
 void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def);
 void virStorageSourceClear(virStorageSourcePtr def);
 int virStorageSourceGetActualType(virStorageSourcePtr def);
+bool virStorageSourceIsLocalStorage(virStorageSourcePtr src);
 void virStorageSourceFree(virStorageSourcePtr def);
 void virStorageSourceBackingStoreClear(virStorageSourcePtr def);
 virStorageSourcePtr virStorageSourceNewFromBacking(virStorageSourcePtr parent);
-- 
1.9.3

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

Reply via email to