[PATCH v4 07/13] qemu: simplify getting completed job stats

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

 



---
 src/qemu/qemu_driver.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 43244d0..fe41b9f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12987,12 +12987,17 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
                               qemuDomainJobInfoPtr jobInfo)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    qemuDomainJobInfoPtr info;
     bool fetch = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
     int ret = -1;
 
-    if (completed)
-        fetch = false;
+    if (completed) {
+        if (priv->job.completed && !priv->job.current)
+            *jobInfo = *priv->job.completed;
+        else
+            jobInfo->status = QEMU_DOMAIN_JOB_STATUS_NONE;
+
+        return 0;
+    }
 
     /* Do not ask QEMU if migration is not even running yet  */
     if (!priv->job.current || !priv->job.current->stats.status)
@@ -13009,26 +13014,18 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
             return -1;
     }
 
-    if (!completed &&
-        !virDomainObjIsActive(vm)) {
+    if (!virDomainObjIsActive(vm)) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
                        _("domain is not running"));
         goto cleanup;
     }
 
-    if (completed && priv->job.current)
-        info = NULL;
-    else if (completed)
-        info = priv->job.completed;
-    else
-        info = priv->job.current;
-
-    if (!info) {
+    if (!priv->job.current) {
         jobInfo->status = QEMU_DOMAIN_JOB_STATUS_NONE;
         ret = 0;
         goto cleanup;
     }
-    *jobInfo = *info;
+    *jobInfo = *priv->job.current;
 
     if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-- 
1.8.3.1

--
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