From: Peter Krempa Date: Fri, 24 Nov 2017 11:09:53 +0000 (+0100) Subject: qemu: domain: Refactor control flow in qemuDomainDetermineDiskChain X-Git-Tag: v3.10.0-rc2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b19710b9b6039728620a8d557a322ef139529226;p=thirdparty%2Flibvirt.git 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. --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d1e391f481..5dc3d73f48 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6369,29 +6369,26 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, goto cleanup; } - if (virStorageSourceHasBacking(src)) { - if (force_probe) { - virStorageSourceBackingStoreClear(src); - } else { - /* skip to the end of the chain */ - while (virStorageSourceIsBacking(src)) { - if (report_broken && - virStorageFileSupportsAccess(src)) { - - if (qemuDomainStorageFileInit(driver, vm, src, disk->src) < 0) - goto cleanup; - - if (virStorageFileAccess(src, F_OK) < 0) { - virStorageFileReportBrokenChain(errno, src, disk->src); - virStorageFileDeinit(src); - goto cleanup; - } + if (force_probe) + virStorageSourceBackingStoreClear(src); - virStorageFileDeinit(src); - } - src = src->backingStore; + /* skip to the end of the chain if there is any */ + while (virStorageSourceHasBacking(src)) { + if (report_broken && + virStorageFileSupportsAccess(src)) { + + if (qemuDomainStorageFileInit(driver, vm, src, disk->src) < 0) + goto cleanup; + + if (virStorageFileAccess(src, F_OK) < 0) { + virStorageFileReportBrokenChain(errno, src, disk->src); + virStorageFileDeinit(src); + goto cleanup; } + + virStorageFileDeinit(src); } + src = src->backingStore; } /* We skipped to the end of the chain. Skip detection if there's the