From 53c49c88f0a1a5eba29054c0967cbea5abbc33ed Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 13 Apr 2021 17:31:53 +0200 Subject: [PATCH] qemuMigrationSrcBeginPhase: Don't offer 'nbd' in cookie if there are no disks to migrate 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 Tested-by: Andrea Bolognani Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 119459342e..3a622d38cd 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -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; } }