To avoid polling for asyncAbort flag changes.

Signed-off-by: Jiri Denemark <jdene...@redhat.com>
---

Notes:
    Version 2:
    - rewritten using domain condition

 src/qemu/qemu_domain.c    |  5 +++--
 src/qemu/qemu_domain.h    |  2 +-
 src/qemu/qemu_migration.c | 11 ++++-------
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8cb4daa..a1ce988 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -169,7 +169,7 @@ qemuDomainObjResetAsyncJob(qemuDomainObjPrivatePtr priv)
     job->phase = 0;
     job->mask = QEMU_JOB_DEFAULT_MASK;
     job->dump_memory_only = false;
-    job->asyncAbort = false;
+    job->abortJob = false;
     VIR_FREE(job->current);
 }
 
@@ -1652,7 +1652,8 @@ qemuDomainObjAbortAsyncJob(virDomainObjPtr obj)
               qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
               obj, obj->def->name);
 
-    priv->job.asyncAbort = true;
+    priv->job.abortJob = true;
+    virDomainObjBroadcast(obj);
 }
 
 /*
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 7f06cb8..7479f70 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -135,7 +135,7 @@ struct qemuDomainJobObj {
     bool dump_memory_only;              /* use dump-guest-memory to do dump */
     qemuDomainJobInfoPtr current;       /* async job progress data */
     qemuDomainJobInfoPtr completed;     /* statistics data of a recently 
completed job */
-    bool asyncAbort;                    /* abort of async job requested */
+    bool abortJob;                      /* abort of the job requested */
 };
 
 typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f6b9aa0..74c2657 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2043,12 +2043,10 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
     }
 
     while ((rv = qemuMigrationDriveMirrorReady(driver, vm)) != 1) {
-        unsigned long long now;
-
         if (rv < 0)
             goto cleanup;
 
-        if (priv->job.asyncAbort) {
+        if (priv->job.abortJob) {
             priv->job.current->type = VIR_DOMAIN_JOB_CANCELLED;
             virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"),
                            qemuDomainAsyncJobTypeToString(priv->job.asyncJob),
@@ -2056,8 +2054,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
             goto cleanup;
         }
 
-        if (virTimeMillisNow(&now) < 0 ||
-            virDomainObjWaitUntil(vm, now + 500) < 0)
+        if (virDomainObjWait(vm) < 0)
             goto cleanup;
     }
 
@@ -4054,10 +4051,10 @@ qemuMigrationRun(virQEMUDriverPtr driver,
                                        QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
         goto cleanup;
 
-    if (priv->job.asyncAbort) {
+    if (priv->job.abortJob) {
         /* explicitly do this *after* we entered the monitor,
          * as this is a critical section so we are guaranteed
-         * priv->job.asyncAbort will not change */
+         * priv->job.abortJob will not change */
         ignore_value(qemuDomainObjExitMonitor(driver, vm));
         priv->job.current->type = VIR_DOMAIN_JOB_CANCELLED;
         virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"),
-- 
2.4.1

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

Reply via email to