]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMigrationSrcBeginPhase: Don't offer 'nbd' in cookie if there are no disks to...
authorPeter Krempa <pkrempa@redhat.com>
Tue, 13 Apr 2021 15:31:53 +0000 (17:31 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 26 Apr 2021 15:22:30 +0000 (17:22 +0200)
Don't try to setup disk migration and the NBD stuff if we end up
migrating nothing.

The destination side has luckily no setup for the non-NBD cases so
omitting the element fully is okay.

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

index 119459342e1dcf974b5305a9d70a8c4ac42defad..3a622d38cd79e3a021b62b2b475c9849a5636f35 100644 (file)
@@ -2365,26 +2365,30 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver,
                 return NULL;
             }
         } else {
-            cookieFlags |= QEMU_MIGRATION_COOKIE_NBD;
-            priv->nbdPort = 0;
-        }
-
-        if (nmigrate_disks) {
-            size_t i, j;
-            /* Check user requested only known disk targets. */
-            for (i = 0; i < nmigrate_disks; i++) {
-                for (j = 0; j < vm->def->ndisks; j++) {
-                    if (STREQ(vm->def->disks[j]->dst, migrate_disks[i]))
-                        break;
-                }
+            if (nmigrate_disks) {
+                size_t i, j;
+                /* Check user requested only known disk targets. */
+                for (i = 0; i < nmigrate_disks; i++) {
+                    for (j = 0; j < vm->def->ndisks; j++) {
+                        if (STREQ(vm->def->disks[j]->dst, migrate_disks[i]))
+                            break;
+                    }
 
-                if (j == vm->def->ndisks) {
-                    virReportError(VIR_ERR_INVALID_ARG,
-                                   _("disk target %s not found"),
-                                   migrate_disks[i]);
-                    return NULL;
+                    if (j == vm->def->ndisks) {
+                        virReportError(VIR_ERR_INVALID_ARG,
+                                       _("disk target %s not found"),
+                                       migrate_disks[i]);
+                        return NULL;
+                    }
                 }
             }
+
+            priv->nbdPort = 0;
+
+            if (qemuMigrationHasAnyStorageMigrationDisks(vm->def,
+                                                         migrate_disks,
+                                                         nmigrate_disks))
+                cookieFlags |= QEMU_MIGRATION_COOKIE_NBD;
         }
     }