In case of real migration (not migrating to file on save, dump etc)
migration info is not complete at time qemu finishes migration
in normal (non postcopy) mode. We need to update disks stats,
downtime info etc. Thus let's not expose this job status as
completed.
To archive this let's set status to 'qemu completed' after
qemu reports migration is finished. It is not visible as complete
job to clients. Cookie code on confirm phase will finally turn
job into completed. As we don't need more things to do when
migrating to file status is set to 'completed' as before
in this case.
---
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 1 +
src/qemu/qemu_migration.c | 13 +++++++++----
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 18f91d2..a794673 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -421,6 +421,7 @@ qemuDomainJobStatusToType(qemuDomainJobStatus status)
case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
+ case QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED:
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 d517719..9c1f691 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -103,6 +103,7 @@ typedef enum {
QEMU_DOMAIN_JOB_STATUS_NONE = 0,
QEMU_DOMAIN_JOB_STATUS_ACTIVE,
QEMU_DOMAIN_JOB_STATUS_MIGRATING,
+ QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED,
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 ec5e0b1..f67d33d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12941,6 +12941,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
+ jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
/* Disks stats accounting presumes that fetching migration
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 54cfdd0..8f7825f 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1358,7 +1358,7 @@ qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
break;
case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
- jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
+ jobInfo->status = QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED;
break;
case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE:
@@ -1464,6 +1464,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_QEMU_COMPLETED:
case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
break;
}
@@ -1526,19 +1527,19 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
return 1;
}
- if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_COMPLETED)
+ if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED)
return 1;
else
return 0;
error:
- /* state can not be active at this point */
+ /* state can not be active or completed 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;
return -2;
- } else if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_COMPLETED) {
+ } else if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED) {
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
return -1;
} else {
@@ -1595,6 +1596,10 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
if (VIR_ALLOC(priv->job.completed) == 0)
*priv->job.completed = *jobInfo;
+ if (asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT &&
+ jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED)
+ jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
+
return 0;
}
--
1.8.3.1