提交 5139924b 编写于 作者: J Jiri Denemark

qemu: Keep track of what disks are being migrated

Instead of redoing the same filtering over and over everytime we need to
walk through all disks which are being migrated.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 46a7a495
......@@ -218,6 +218,8 @@ struct _qemuDomainDiskPrivate {
int blockJobType; /* type of the block job from the event */
int blockJobStatus; /* status of the finished block job */
bool blockJobSync; /* the block job needs synchronized termination */
bool migrating; /* the disk is being migrated */
};
typedef enum {
......
......@@ -1745,13 +1745,7 @@ qemuMigrationCheckDriveMirror(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk = vm->def->disks[i];
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
/* 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 (!diskPriv->blockJobSync)
if (!diskPriv->migrating || !diskPriv->blockJobSync)
continue;
/* process any pending event */
......@@ -1874,17 +1868,13 @@ qemuMigrationCancelDriveMirror(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk = vm->def->disks[i];
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
/* 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 (!diskPriv->blockJobSync)
if (!diskPriv->migrating || !diskPriv->blockJobSync)
continue;
if (qemuMigrationCancelOneDriveMirror(driver, vm, disk) < 0)
return -1;
diskPriv->migrating = false;
}
return 0;
......@@ -1945,6 +1935,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
for (i = 0; i < vm->def->ndisks; i++) {
virDomainDiskDefPtr disk = vm->def->disks[i];
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
int mon_ret;
/* skip shared, RO and source-less disks */
......@@ -1975,16 +1966,16 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
qemuBlockJobSyncEnd(driver, vm, disk, NULL);
goto cleanup;
}
diskPriv->migrating = true;
}
/* Wait for each disk to become ready in turn, but check the status
* for *all* mirrors to determine if any have aborted. */
for (i = 0; i < vm->def->ndisks; i++) {
virDomainDiskDefPtr disk = vm->def->disks[i];
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
/* skip shared, RO and source-less disks */
if (disk->src->shared || disk->src->readonly ||
!virDomainDiskGetSource(disk))
if (!diskPriv->migrating)
continue;
while (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册