[PATCH 9/9] virDomainDiskTranslateSourcePool: Translate 'VOLUME' disks in whole backing chain

Peter Krempa posted 9 patches 6 years ago
[PATCH 9/9] virDomainDiskTranslateSourcePool: Translate 'VOLUME' disks in whole backing chain
Posted by Peter Krempa 6 years ago
Now that we accept full backing chains on input nothing should prevent
users from also using disk type 'VOLUME' for specifying the backing
images.

Do the translation for the whole backing chain.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/conf/domain_conf.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7bd86d67e5..46062e3969 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -31560,18 +31560,20 @@ int
 virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
 {
     g_autoptr(virConnect) conn = NULL;
+    virStorageSourcePtr n;

-    if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
-        return 0;
-
-    if (!def->src->srcpool)
-        return 0;
+    for (n = def->src; virStorageSourceIsBacking(n); n = n->backingStore) {
+        if (n->type != VIR_STORAGE_TYPE_VOLUME || !n-> srcpool)
+            continue;

-    if (!(conn = virGetConnectStorage()))
-        return -1;
+        if (!conn) {
+            if (!(conn = virGetConnectStorage()))
+                return -1;
+        }

-    if (virDomainStorageSourceTranslateSourcePool(def->src, conn) < 0)
-        return -1;
+        if (virDomainStorageSourceTranslateSourcePool(n, conn) < 0)
+            return -1;
+    }

     if (def->startupPolicy != 0 &&
         virStorageSourceGetActualType(def->src) != VIR_STORAGE_VOL_FILE) {
-- 
2.24.1

Re: [PATCH 9/9] virDomainDiskTranslateSourcePool: Translate 'VOLUME' disks in whole backing chain
Posted by Ján Tomko 6 years ago
On Wed, Feb 05, 2020 at 02:41:00PM +0100, Peter Krempa wrote:
>Now that we accept full backing chains on input nothing should prevent
>users from also using disk type 'VOLUME' for specifying the backing
>images.

s/VOLUME/volume/g

No need to yell in the commit summary if the XML value is lowercase.

>
>Do the translation for the whole backing chain.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/conf/domain_conf.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 7bd86d67e5..46062e3969 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -31560,18 +31560,20 @@ int
> virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
> {
>     g_autoptr(virConnect) conn = NULL;
>+    virStorageSourcePtr n;
>
>-    if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
>-        return 0;
>-
>-    if (!def->src->srcpool)
>-        return 0;
>+    for (n = def->src; virStorageSourceIsBacking(n); n = n->backingStore) {
>+        if (n->type != VIR_STORAGE_TYPE_VOLUME || !n-> srcpool)

Extra space ------------------------------------------```

>+            continue;
>

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

Jano