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 c023e0e..a61ee81 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -411,6 +411,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 b002184..983ca4e 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 9a706d5..e7a0687 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12779,6 +12779,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 1703274..dfecc96 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1327,7 +1327,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:
@@ -1433,6 +1433,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;
}
@@ -1495,19 +1496,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 {
@@ -1564,6 +1565,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