mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
qemuMigrationSrcNBDCopyCancel: Use qemuBlockStorageSourceAttachRollback to detach migration NBD blockdevs
Rewrite the code to use the common tooling for removing blockdevs instead of the ad-hoc qemuBlockStorageSourceDetachOneBlockdev helper. Use of the common infrastructure will properly handle cases when the raw driver is ommited from the block graph. Since the TLS data object is shared for all migration QMP commands and objects we need to strip its alias from the definition of the storage source before attempting to detach it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
9ec0e28e87
commit
e534d19b5d
@ -938,12 +938,26 @@ qemuMigrationSrcNBDCopyCancel(virDomainObj *vm,
|
|||||||
for (i = 0; i < vm->def->ndisks; i++) {
|
for (i = 0; i < vm->def->ndisks; i++) {
|
||||||
virDomainDiskDef *disk = vm->def->disks[i];
|
virDomainDiskDef *disk = vm->def->disks[i];
|
||||||
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||||
|
g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
|
||||||
|
|
||||||
if (!diskPriv->migrSource)
|
if (!diskPriv->migrSource)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
qemuBlockStorageSourceDetachOneBlockdev(vm, asyncJob,
|
/* remove the alias of the TLS object when we're about to detach the
|
||||||
diskPriv->migrSource);
|
* migration NBD blockdev as the TLS object is shared for the migration
|
||||||
|
* and we don't want to detach it. The alias is not needed after
|
||||||
|
* the JSON object of the blockdev props is formatted */
|
||||||
|
g_clear_pointer(&diskPriv->migrSource->tlsAlias, g_free);
|
||||||
|
|
||||||
|
data = qemuBlockStorageSourceDetachPrepare(diskPriv->migrSource);
|
||||||
|
|
||||||
|
if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), data);
|
||||||
|
|
||||||
|
qemuDomainObjExitMonitor(vm);
|
||||||
|
|
||||||
g_clear_pointer(&diskPriv->migrSource, virObjectUnref);
|
g_clear_pointer(&diskPriv->migrSource, virObjectUnref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user