Similarly to previous refactors we want to move all hotplug related setup which isn't strictly relevant to attaching the disk into qemuDomainAttachDeviceDiskLiveInternal. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_hotplug.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 25e845dc83..f8c741c683 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -724,9 +724,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps))) return -1; - if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_NONE) < 0) - return -1; - qemuDomainObjEnterMonitor(driver, vm); if (qemuBlockStorageSourceChainAttach(priv->mon, data) < 0) @@ -766,10 +763,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (qemuDomainObjExitMonitor(driver, vm) < 0) return -2; - if (virStorageSourceChainHasManagedPR(disk->src) && - qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) - return -2; - return -1; } @@ -1026,6 +1019,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver, if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0) goto cleanup; + if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_NONE) < 0) + goto cleanup; + ret = qemuDomainAttachDiskGeneric(driver, vm, disk); virDomainAuditDisk(vm, NULL, disk->src, "attach", ret == 0); @@ -1047,6 +1043,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver, if (releaseSeclabel) ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src)); + + if (virStorageSourceChainHasManagedPR(disk->src)) + ignore_value(qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE)); } qemuDomainSecretDiskDestroy(disk); -- 2.31.1