[PATCH 5/8] qemuMigrationDstPrepareStorage: Rework storage existence check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check the existance of storage per-type rather than trying to come up
with a common "path".

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 2ac10ab5ff..d248f87c2d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -434,8 +434,7 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm,

     for (i = 0; i < nbd->ndisks; i++) {
         virDomainDiskDef *disk;
-        const char *diskSrcPath = NULL;
-        g_autofree char *nvmePath = NULL;
+        bool exists = false;

         VIR_DEBUG("Looking up disk target '%s' (capacity=%llu)",
                   nbd->disks[i].target, nbd->disks[i].capacity);
@@ -471,21 +470,27 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm,
                     diskPriv->migrationslice = true;
                 }
             }
-            G_GNUC_FALLTHROUGH;
+
+            exists = virFileExists(disk->src->path);
+            break;
+
         case VIR_STORAGE_TYPE_FILE:
         case VIR_STORAGE_TYPE_DIR:
-            diskSrcPath = virDomainDiskGetSource(disk);
+            exists = virFileExists(disk->src->path);
             break;

-        case VIR_STORAGE_TYPE_NVME:
-            /* While NVMe disks are local, they are not accessible via src->path.
-             * Therefore, we have to return false here. */
+        case VIR_STORAGE_TYPE_NVME: {
+            /* While NVMe disks are local, they are not accessible via src->path */
+            g_autofree char *nvmePath = NULL;
+
             virPCIDeviceAddressGetSysfsFile(&disk->src->nvme->pciAddr, &nvmePath);
-            diskSrcPath = nvmePath;
+
+            exists = virFileExists(nvmePath);
             break;
+        }

         case VIR_STORAGE_TYPE_VHOST_VDPA:
-            diskSrcPath = disk->src->vdpadev;
+            exists = virFileExists(disk->src->vdpadev);
             break;

         case VIR_STORAGE_TYPE_NETWORK:
@@ -496,20 +501,17 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm,
             break;
         }

-        if (diskSrcPath) {
-            /* don't pre-create existing disks */
-            if (virFileExists(diskSrcPath)) {
-                VIR_DEBUG("Skipping pre-create of existing source for disk '%s'", disk->dst);
-                continue;
-            }
-        }
+        VIR_DEBUG("target='%s' exists='%d'", disk->dst, exists);
+
+        if (exists)
+            continue;

         /* create the storage - if supported */

         if (incremental) {
             virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
-                           _("pre-creation of storage target '%1$s' for incremental storage migration of disk '%2$s' is not supported"),
-                           NULLSTR(diskSrcPath), nbd->disks[i].target);
+                           _("pre-creation of storage target for incremental storage migration of disk '%1$s' is not supported"),
+                           nbd->disks[i].target);
             return -1;
         }

-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux