]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: storage: Fix virStorageSourceGetActualType if volume was not translated
authorPeter Krempa <pkrempa@redhat.com>
Tue, 25 Jun 2019 10:59:07 +0000 (12:59 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 26 Jun 2019 10:28:31 +0000 (12:28 +0200)
virStorageSourceGetActualType would return VIR_STORAGE_TYPE_NONE in case
when a virStorageSource of (top level) type VIR_STORAGE_TYPE_VOLUME was
not prepared to use by the vm by calling
virDomainDiskTranslateSourcePool.

Fix this issue by returning VIR_STORAGE_TYPE_VOLUME in case when the
volume was not translated yet.

Additionally also add documentation for the function describing the
quirk.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virstoragefile.c

index f7495ab6da1234f332f4a113421c4b20fcdcf4fb..269d0050fd3d3ce2730d792e0e7e357236407fb9 100644 (file)
@@ -2430,10 +2430,20 @@ virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def)
 }
 
 
+/**
+ * virStorageSourceGetActualType:
+ * @def: storage source definition
+ *
+ * Returns type of @def. In case when the type is VIR_STORAGE_TYPE_VOLUME
+ * and virDomainDiskTranslateSourcePool was called on @def the actual type
+ * of the storage volume is returned rather than VIR_STORAGE_TYPE_VOLUME.
+ */
 int
 virStorageSourceGetActualType(const virStorageSource *def)
 {
-    if (def->type == VIR_STORAGE_TYPE_VOLUME && def->srcpool)
+    if (def->type == VIR_STORAGE_TYPE_VOLUME &&
+        def->srcpool &&
+        def->srcpool->actualtype != VIR_STORAGE_TYPE_NONE)
         return def->srcpool->actualtype;
 
     return def->type;