From ea43f5f9b3a3899704d01aabfd3184fd0ef5c076 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 25 Jun 2014 13:47:32 +0200 Subject: [PATCH] util: storage: Add helper to determine whether storage is local 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 8c02df17a..29e9db930 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1922,6 +1922,7 @@ virStorageSourceClear; virStorageSourceFree; virStorageSourceGetActualType; virStorageSourceGetSecurityLabelDef; +virStorageSourceIsLocalStorage; virStorageSourceNewFromBacking; virStorageSourcePoolDefFree; virStorageSourcePoolModeTypeFromString; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 15043827b..9208b7747 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1742,6 +1742,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 833fbe1c0..4f7357b22 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -339,6 +339,7 @@ virStorageNetHostDefPtr virStorageNetHostDefCopy(size_t nhosts, 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); -- 2.39.5