From 59dfc370693ee7631f7b538660cfd30f213b0a86 Mon Sep 17 00:00:00 2001
Message-Id: <59dfc370693ee7631f7b538660cfd30f213b0a86@dist-git>
From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Date: Fri, 1 Sep 2017 09:49:28 +0300
Subject: [PATCH] qemu: introduce migrating job status
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).
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 5a274d4fdc0015909fa95e6667922bb249a95bd5)
https://bugzilla.redhat.com/show_bug.cgi?id=1530130
Conflicts:
src/qemu/qemu_migration.c
- commit e87d4b9e2f is not backported
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
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 4b1ead7d0a..e81d682c00 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -397,6 +397,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 c8b3873b9f..0cf54d99ae 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 8972897a28..931f3d344d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12934,7 +12934,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
fetch = false;
/* 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) {
@@ -12970,6 +12971,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
*jobInfo = *info;
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
+ jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
if (fetch)
ret = qemuMigrationFetchJobStatus(driver, vm, QEMU_ASYNC_JOB_NONE,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 9f7aad6680..c8cd7ebfa3 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1460,6 +1460,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
break;
case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
+ case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
break;
}
@@ -1532,7 +1533,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;
@@ -1563,6 +1565,8 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
flags |= QEMU_MIGRATION_COMPLETED_UPDATE_STATS;
+ jobInfo->status = QEMU_DOMAIN_JOB_STATUS_MIGRATING;
+
while ((rv = qemuMigrationCompleted(driver, vm, asyncJob,
dconn, flags)) != 1) {
if (rv < 0)
@@ -3879,7 +3883,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 |
--
2.15.1