Move the preparation steps from qemuDomainAttachDiskGeneric up into
qemuDomainAttachDeviceDiskLive so that also media changing can use the
prepared file.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index c46f27f4b4..87bc63e5e1 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -641,7 +641,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuHotplugDiskSourceDataPtr diskdata = NULL;
char *devstr = NULL;
- virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
if (qemuHotplugPrepareDiskAccess(driver, vm, disk, NULL, false) < 0)
goto cleanup;
@@ -649,9 +648,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
if (qemuAssignDeviceDiskAlias(vm->def, disk) < 0)
goto error;
- if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0)
- goto error;
-
if (!(diskdata = qemuHotplugDiskSourceAttachPrepare(disk, priv->qemuCaps)))
goto error;
@@ -686,7 +682,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
qemuHotplugDiskSourceDataFree(diskdata);
qemuDomainSecretDiskDestroy(disk);
VIR_FREE(devstr);
- virObjectUnref(cfg);
return ret;
exit_monitor:
@@ -927,6 +922,8 @@ qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr driver,
bool forceMediaChange)
{
size_t i;
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDiskDefPtr disk = dev->data.disk;
virDomainDiskDefPtr orig_disk = NULL;
int ret = -1;
@@ -943,6 +940,9 @@ qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr driver,
if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0)
goto cleanup;
+ if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0)
+ goto cleanup;
+
switch ((virDomainDiskDevice) disk->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
@@ -1013,6 +1013,7 @@ qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr driver,
cleanup:
if (ret != 0)
ignore_value(qemuRemoveSharedDevice(driver, dev, vm->def->name));
+ virObjectUnref(cfg);
return ret;
}
--
2.16.2