qemu: domain: Refactor control flow in qemuDomainDetermineDiskChain

Split out clearing of the backing chain prior to other code since it
will be required later and optimize few layers of nested conditions and
loops.
This commit is contained in:
Peter Krempa 2017-11-24 12:09:53 +01:00
parent cb06ea57ad
commit b19710b9b6

View File

@ -6369,12 +6369,11 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
goto cleanup;
}
if (virStorageSourceHasBacking(src)) {
if (force_probe) {
if (force_probe)
virStorageSourceBackingStoreClear(src);
} else {
/* skip to the end of the chain */
while (virStorageSourceIsBacking(src)) {
/* skip to the end of the chain if there is any */
while (virStorageSourceHasBacking(src)) {
if (report_broken &&
virStorageFileSupportsAccess(src)) {
@ -6391,8 +6390,6 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
}
src = src->backingStore;
}
}
}
/* We skipped to the end of the chain. Skip detection if there's the
* terminator. (An allocated but empty backingStore) */