Instead of redoing the same filtering over and over everytime we need to walk through all disks which are being migrated. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_migration.c | 23 ++++++----------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2cd105a7..391f49a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -703,6 +703,8 @@ struct _virDomainDiskDef { int blockJobStatus; /* status of the finished block job */ bool blockJobSync; /* the block job needs synchronized termination */ + bool migrating; /* the disk is being migrated */ + struct { unsigned int cylinders; unsigned int heads; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c1af704..7448794 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1744,13 +1744,7 @@ qemuMigrationCheckDriveMirror(virQEMUDriverPtr driver, for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk = vm->def->disks[i]; - /* skip shared, RO and source-less disks */ - if (disk->src->shared || disk->src->readonly || - !virDomainDiskGetSource(disk)) - continue; - - /* skip disks that didn't start mirroring */ - if (!disk->blockJobSync) + if (!disk->migrating || !disk->blockJobSync) continue; /* process any pending event */ @@ -1872,17 +1866,13 @@ qemuMigrationCancelDriveMirror(virQEMUDriverPtr driver, for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk = vm->def->disks[i]; - /* skip shared, RO and source-less disks */ - if (disk->src->shared || disk->src->readonly || - !virDomainDiskGetSource(disk)) - continue; - - /* skip disks that didn't start mirroring */ - if (!disk->blockJobSync) + if (!disk->migrating || !disk->blockJobSync) continue; if (qemuMigrationCancelOneDriveMirror(driver, vm, disk) < 0) return -1; + + disk->migrating = false; } return 0; @@ -1973,6 +1963,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver, qemuBlockJobSyncEnd(driver, vm, disk, NULL); goto cleanup; } + disk->migrating = true; } /* Wait for each disk to become ready in turn, but check the status @@ -1980,9 +1971,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver, for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk = vm->def->disks[i]; - /* skip shared, RO and source-less disks */ - if (disk->src->shared || disk->src->readonly || - !virDomainDiskGetSource(disk)) + if (!disk->migrating) continue; while (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY) { -- 2.4.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list