Don't even try to setup storage migration if there are no eligible disks. This also fixes migration from older libvirts which didn't format an empty <nbd/> element in the migration cookie if there weren't any disks to migrate. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_migration.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 9ea008836c..119459342e 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -312,6 +312,22 @@ qemuMigrationAnyCopyDisk(virDomainDiskDef const *disk, } +static bool +qemuMigrationHasAnyStorageMigrationDisks(virDomainDef *def, + const char **migrate_disks, + size_t nmigrate_disks) +{ + size_t i; + + for (i = 0; i < def->ndisks; i++) { + if (qemuMigrationAnyCopyDisk(def->disks[i], nmigrate_disks, migrate_disks)) + return true; + } + + return false; +} + + static int qemuMigrationDstPrecreateStorage(virDomainObj *vm, qemuMigrationCookieNBD *nbd, @@ -4011,6 +4027,11 @@ qemuMigrationSrcRun(virQEMUDriver *driver, spec, spec->destType, spec->fwdType, dconn, NULLSTR(graphicsuri), nmigrate_disks, migrate_disks); + if (storageMigration) + storageMigration = qemuMigrationHasAnyStorageMigrationDisks(vm->def, + migrate_disks, + nmigrate_disks); + if (storageMigration) { cookieFlags |= QEMU_MIGRATION_COOKIE_NBD; -- 2.30.2