]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuMigrationDstPrepareStorage: Use 'switch' statement to include all storage types
authorPeter Krempa <pkrempa@redhat.com>
Thu, 8 Feb 2024 15:48:25 +0000 (16:48 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 21 Feb 2024 13:15:48 +0000 (14:15 +0100)
Decrease the likelyhood that addition of a new storage type will be
forgotten.

This patch also unifies the type check to consult the 'actual' type of
the storage in both cases as the NVMe check looked for the XML declared
type while virStorageSourceIsLocalStorage() looks for the
actual/translated type.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_migration.c

index 01ab80384233d1e26022eb7f09242bbbd18bade5..3e0aae4e7c93b2e7fadce5e2bf4f82b7c17e89a9 100644 (file)
@@ -465,11 +465,27 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm,
         if (!qemuMigrationAnyCopyDisk(disk, nmigrate_disks, migrate_disks))
             continue;
 
-        if (disk->src->type == VIR_STORAGE_TYPE_NVME) {
+        switch (virStorageSourceGetActualType(disk->src)) {
+        case VIR_STORAGE_TYPE_FILE:
+        case VIR_STORAGE_TYPE_BLOCK:
+        case VIR_STORAGE_TYPE_DIR:
+            diskSrcPath = virDomainDiskGetSource(disk);
+            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. */
             virPCIDeviceAddressGetSysfsFile(&disk->src->nvme->pciAddr, &nvmePath);
             diskSrcPath = nvmePath;
-        } else if (virStorageSourceIsLocalStorage(disk->src)) {
-            diskSrcPath = virDomainDiskGetSource(disk);
+            break;
+
+        case VIR_STORAGE_TYPE_NETWORK:
+        case VIR_STORAGE_TYPE_VOLUME:
+        case VIR_STORAGE_TYPE_VHOST_USER:
+        case VIR_STORAGE_TYPE_VHOST_VDPA:
+        case VIR_STORAGE_TYPE_LAST:
+        case VIR_STORAGE_TYPE_NONE:
+            break;
         }
 
         if (diskSrcPath) {