render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
7a3408
From 891e04fccd80d2773e177858da80210800ebbad5 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <891e04fccd80d2773e177858da80210800ebbad5@dist-git>
7a3408
From: Jiri Denemark <jdenemar@redhat.com>
7a3408
Date: Tue, 26 May 2015 13:42:06 +0200
7a3408
Subject: [PATCH] qemuDomainGetJobStatsInternal: Support migration events
7a3408
7a3408
When QEMU supports migration events the qemuDomainJobInfo structure will
7a3408
no longer be updated with migration statistics. We have to enter a job
7a3408
and explicitly ask QEMU every time virDomainGetJob{Info,Stats} is
7a3408
called.
7a3408
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
(cherry picked from commit 66c95964a5706c223f4857e55396318c857abb6f)
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1212077
7a3408
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_driver.c | 27 +++++++++++++++++++++++----
7a3408
 1 file changed, 23 insertions(+), 4 deletions(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
7a3408
index 6dafbec..b3e9e63 100644
7a3408
--- a/src/qemu/qemu_driver.c
7a3408
+++ b/src/qemu/qemu_driver.c
7a3408
@@ -13021,15 +13021,27 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
7a3408
 
7a3408
 
7a3408
 static int
7a3408
-qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
7a3408
+qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
7a3408
                               virDomainObjPtr vm,
7a3408
                               bool completed,
7a3408
                               qemuDomainJobInfoPtr jobInfo)
7a3408
 {
7a3408
     qemuDomainObjPrivatePtr priv = vm->privateData;
7a3408
     qemuDomainJobInfoPtr info;
7a3408
+    bool fetch = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
7a3408
     int ret = -1;
7a3408
 
7a3408
+    if (completed)
7a3408
+        fetch = false;
7a3408
+
7a3408
+    /* Do not ask QEMU if migration is not even running yet  */
7a3408
+    if (!priv->job.current || !priv->job.current->status.status)
7a3408
+        fetch = false;
7a3408
+
7a3408
+    if (fetch &&
7a3408
+        qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
7a3408
+        return -1;
7a3408
+
7a3408
     if (!completed &&
7a3408
         !virDomainObjIsActive(vm)) {
7a3408
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
7a3408
@@ -13050,12 +13062,19 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
7a3408
     *jobInfo = *info;
7a3408
 
7a3408
     if (jobInfo->type == VIR_DOMAIN_JOB_BOUNDED ||
7a3408
-        jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED)
7a3408
-        ret = qemuDomainJobInfoUpdateTime(jobInfo);
7a3408
-    else
7a3408
+        jobInfo->type == VIR_DOMAIN_JOB_UNBOUNDED) {
7a3408
+        if (fetch)
7a3408
+            ret = qemuMigrationFetchJobStatus(driver, vm, QEMU_ASYNC_JOB_NONE,
7a3408
+                                              jobInfo);
7a3408
+        else
7a3408
+            ret = qemuDomainJobInfoUpdateTime(jobInfo);
7a3408
+    } else {
7a3408
         ret = 0;
7a3408
+    }
7a3408
 
7a3408
  cleanup:
7a3408
+    if (fetch)
7a3408
+        qemuDomainObjEndJob(driver, vm);
7a3408
     return ret;
7a3408
 }
7a3408
 
7a3408
-- 
7a3408
2.4.5
7a3408