In some cases backing chain needs to be cleared prior to re-detection.
Move this step out of qemuDomainDetermineDiskChain as only certain
places need it and the function itself is able to skip to the end of the
chain to perform detection.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_blockjob.c | 4 ++--
src/qemu/qemu_domain.c | 4 ----
src/qemu/qemu_domain.h | 1 -
src/qemu/qemu_driver.c | 4 ++--
src/qemu/qemu_hotplug.c | 2 +-
src/qemu/qemu_process.c | 7 +++++--
6 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index b08e047490..0f52996ade 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -175,8 +175,8 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver,
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
disk->src->id = 0;
- ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk,
- true, true));
+ virStorageSourceBackingStoreClear(disk->src);
+ ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk, true));
ignore_value(qemuBlockNodeNamesDetect(driver, vm, asyncJob));
diskPriv->blockjob = false;
break;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ed76495309..c92ac8c926 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8352,7 +8352,6 @@ int
qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
- bool force_probe,
bool report_broken)
{
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
@@ -8368,9 +8367,6 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
goto cleanup;
}
- if (force_probe)
- virStorageSourceBackingStoreClear(src);
-
/* There is no need to check the backing chain for disks without backing
* support */
if (virStorageSourceIsLocalStorage(src) &&
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index e748d78adb..1692fa9838 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -718,7 +718,6 @@ int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
- bool force_probe,
bool report_broken);
bool qemuDomainDiskSourceDiffers(virDomainDiskDefPtr disk,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4f2855a26b..64e2c274c2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7850,7 +7850,7 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
if (virDomainDiskTranslateSourcePool(disk) < 0)
goto cleanup;
- if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
+ if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0)
goto cleanup;
if (!(orig_disk = virDomainDiskFindByBusAndDst(vm->def,
@@ -16931,7 +16931,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
oldsrc = disk->src;
disk->src = disk->mirror;
- if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
+ if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0)
goto cleanup;
if (disk->mirror->format &&
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 2b6633a998..98f7a28826 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -669,7 +669,7 @@ qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr driver,
if (qemuSetUnprivSGIO(dev) < 0)
goto cleanup;
- if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
+ if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0)
goto cleanup;
switch ((virDomainDiskDevice) disk->device) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c903a8e5c8..138e128807 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6015,7 +6015,9 @@ qemuProcessPrepareHostStorage(virQEMUDriverPtr driver,
if (virStorageSourceIsEmpty(disk->src))
continue;
- if (qemuDomainDetermineDiskChain(driver, vm, disk, true, true) >= 0)
+ virStorageSourceBackingStoreClear(disk->src);
+
+ if (qemuDomainDetermineDiskChain(driver, vm, disk, true) >= 0)
continue;
if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) >= 0)
@@ -7691,7 +7693,8 @@ qemuProcessReconnect(void *opaque)
/* This should be the only place that calls
* qemuDomainDetermineDiskChain with @report_broken == false
* to guarantee best-effort domain reconnect */
- if (qemuDomainDetermineDiskChain(driver, obj, disk, true, false) < 0)
+ virStorageSourceBackingStoreClear(disk->src);
+ if (qemuDomainDetermineDiskChain(driver, obj, disk, false) < 0)
goto error;
} else {
VIR_DEBUG("skipping backing chain detection for '%s'",
disk->dst);
--
2.16.2