[PATCH v3 10/16] qemu: introduce migrating job status

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

 



Instead of checking stat.status let's set status to migrating
as soon as migrate command is send (waiting for completion
is a good place too).
---
 src/qemu/qemu_domain.c    | 1 +
 src/qemu/qemu_domain.h    | 1 +
 src/qemu/qemu_driver.c    | 4 +++-
 src/qemu/qemu_migration.c | 9 +++++++--
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2a14499..c023e0e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -410,6 +410,7 @@ qemuDomainJobStatusToType(qemuDomainJobStatus status)
         break;
 
     case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
+    case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
     case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
         return VIR_DOMAIN_JOB_UNBOUNDED;
 
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 58715c2..564da49 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -102,6 +102,7 @@ VIR_ENUM_DECL(qemuDomainAsyncJob)
 typedef enum {
     QEMU_DOMAIN_JOB_STATUS_NONE = 0,
     QEMU_DOMAIN_JOB_STATUS_ACTIVE,
+    QEMU_DOMAIN_JOB_STATUS_MIGRATING,
     QEMU_DOMAIN_JOB_STATUS_POSTCOPY,
     QEMU_DOMAIN_JOB_STATUS_COMPLETED,
     QEMU_DOMAIN_JOB_STATUS_FAILED,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3854a41..b592abe 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12762,7 +12762,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
     }
 
     /* Do not ask QEMU if migration is not even running yet  */
-    if (!priv->job.current || !priv->job.current->stats.status)
+    if (!priv->job.current ||
+        priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE)
         fetch = false;
 
     if (fetch && qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
@@ -12782,6 +12783,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
     *jobInfo = *priv->job.current;
 
     if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
+        jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
         if (fetch &&
             qemuMigrationFetchMigrationStats(driver, vm, QEMU_ASYNC_JOB_NONE,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 388f770..35c86bb 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1421,6 +1421,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
 
     case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
     case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
+    case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
     case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
         break;
     }
@@ -1489,7 +1490,8 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
         return 0;
 
  error:
-    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
+    /* state can not be active at this point */
+    if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
         jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
         /* The migration was aborted by us rather than QEMU itself. */
         jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
@@ -1518,6 +1520,8 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
     bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
     int rv;
 
+    jobInfo->status = QEMU_DOMAIN_JOB_STATUS_MIGRATING;
+
     while ((rv = qemuMigrationCompleted(driver, vm, asyncJob,
                                         dconn, flags)) != 1) {
         if (rv < 0)
@@ -3833,7 +3837,8 @@ qemuMigrationRun(virQEMUDriverPtr driver,
         ignore_value(virTimeMillisNow(&priv->job.completed->sent));
     }
 
-    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE)
+    if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
+        priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING)
         priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
 
     cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK |
-- 
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