diff options
author | Peter Krempa <pkrempa@redhat.com> | 2016-05-02 13:42:32 +0200 |
---|---|---|
committer | Peter Krempa <pkrempa@redhat.com> | 2016-05-09 12:36:52 +0200 |
commit | 3ec7bb354a94c343c3c0da8b799c24d2144e7871 (patch) | |
tree | 1376ad1024f2bce91975fbb33bafb70e3bd78802 /src/util | |
parent | e85d3e1bbe0b0762920f999b8bbfc127bf86d701 (diff) | |
download | libvirt-3ec7bb354a94c343c3c0da8b799c24d2144e7871.tar.gz |
util: Replace virDomainDiskSourceIsBlockType with a new helper
For disks sources described by a libvirt volume we don't need to do a
complicated check since virStorageTranslateDiskSourcePool already
correctly determines the actual disk type.
Replace the checks using a new accessor that does not open-code the
whole logic.
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/virstoragefile.c | 16 | ||||
-rw-r--r-- | src/util/virstoragefile.h | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 05ac2546bd..4f44e05de5 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1955,7 +1955,7 @@ virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def) int -virStorageSourceGetActualType(virStorageSourcePtr def) +virStorageSourceGetActualType(const virStorageSource *def) { if (def->type == VIR_STORAGE_TYPE_VOLUME && def->srcpool) return def->srcpool->actualtype; @@ -2012,6 +2012,20 @@ virStorageSourceIsEmpty(virStorageSourcePtr src) /** + * virStorageSourceIsBlockLocal: + * @src: disk source definition + * + * Returns true if @src describes a locally accessible block storage source. + * This includes block devices and host-mapped iSCSI volumes. + */ +bool +virStorageSourceIsBlockLocal(const virStorageSource *src) +{ + return virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_BLOCK; +} + + +/** * virStorageSourceBackingStoreClear: * * @src: disk source to clear diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index b98fe25871..17e12779c1 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -357,9 +357,10 @@ int virStorageSourceInitChainElement(virStorageSourcePtr newelem, bool force); void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def); void virStorageSourceClear(virStorageSourcePtr def); -int virStorageSourceGetActualType(virStorageSourcePtr def); +int virStorageSourceGetActualType(const virStorageSource *def); bool virStorageSourceIsLocalStorage(virStorageSourcePtr src); bool virStorageSourceIsEmpty(virStorageSourcePtr src); +bool virStorageSourceIsBlockLocal(const virStorageSource *src); void virStorageSourceFree(virStorageSourcePtr def); void virStorageSourceBackingStoreClear(virStorageSourcePtr def); int virStorageSourceUpdateBlockPhysicalSize(virStorageSourcePtr src, |