[PATCH 1/3] qemu: domain: Refactor control flow in qemuDomainDetermineDiskChain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 src/qemu/qemu_domain.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2bda4a726b..0e6ebdc0a8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6151,29 +6151,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
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux