]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainDiskTranslateSourcePool: Translate 'volume' disks in whole backing chain
authorPeter Krempa <pkrempa@redhat.com>
Wed, 5 Feb 2020 12:05:05 +0000 (13:05 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 10 Feb 2020 16:26:27 +0000 (17:26 +0100)
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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c

index 0adccbdf6f8e2f3a58e5a2fc051de0e1a135dc38..de74a2a2d576df34e683759463a1b01249fcd988 100644 (file)
@@ -31562,18 +31562,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) {