[libvirt] [PATCH v2 1/4] util: storage: Fix virStorageSourceGetActualType if volume was not translated

Peter Krempa posted 4 patches 6 years, 7 months ago
[libvirt] [PATCH v2 1/4] util: storage: Fix virStorageSourceGetActualType if volume was not translated
Posted by Peter Krempa 6 years, 7 months ago
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>
---
 src/util/virstoragefile.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index f7495ab6da..269d0050fd 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -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;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 1/4] util: storage: Fix virStorageSourceGetActualType if volume was not translated
Posted by Ján Tomko 6 years, 7 months ago
On Tue, Jun 25, 2019 at 04:30:30PM +0200, Peter Krempa wrote:
>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>
>---
> src/util/virstoragefile.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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