[libvirt PATCH 2/4] qemu: Refactor qemuDomainGetJobInfoMigrationStats

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

 



The code was a bit too complicated, especially after removing the check
for QEMU_CAPS_MIGRATION_EVENT.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d75606f78c..b8af1d6817 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12505,26 +12505,32 @@ qemuDomainGetJobInfoMigrationStats(virQEMUDriver *driver,
 {
     qemuDomainJobDataPrivate *privStats = jobData->privateData;
 
-    if (jobData->status == VIR_DOMAIN_JOB_STATUS_ACTIVE ||
-        jobData->status == VIR_DOMAIN_JOB_STATUS_MIGRATING ||
-        jobData->status == VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED ||
-        jobData->status == VIR_DOMAIN_JOB_STATUS_POSTCOPY) {
-        if (jobData->status != VIR_DOMAIN_JOB_STATUS_ACTIVE &&
-            qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_NONE,
-                                       jobData, NULL) < 0)
-            return -1;
-
-        if (jobData->status == VIR_DOMAIN_JOB_STATUS_ACTIVE &&
-            privStats->statsType == QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION &&
+    switch (jobData->status) {
+    case VIR_DOMAIN_JOB_STATUS_ACTIVE:
+        if (privStats->statsType == QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION &&
             qemuMigrationSrcFetchMirrorStats(driver, vm, VIR_ASYNC_JOB_NONE,
                                              jobData) < 0)
             return -1;
+        break;
 
-        if (qemuDomainJobDataUpdateTime(jobData) < 0)
+    case VIR_DOMAIN_JOB_STATUS_MIGRATING:
+    case VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED:
+    case VIR_DOMAIN_JOB_STATUS_POSTCOPY:
+        if (qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_NONE,
+                                       jobData, NULL) < 0)
             return -1;
+        break;
+
+    case VIR_DOMAIN_JOB_STATUS_NONE:
+    case VIR_DOMAIN_JOB_STATUS_PAUSED:
+    case VIR_DOMAIN_JOB_STATUS_COMPLETED:
+    case VIR_DOMAIN_JOB_STATUS_FAILED:
+    case VIR_DOMAIN_JOB_STATUS_CANCELED:
+    default:
+        return 0;
     }
 
-    return 0;
+    return qemuDomainJobDataUpdateTime(jobData);
 }
 
 
-- 
2.35.1




[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