When connection breaks during post-copy migration, QEMU enters
'postcopy-paused' state. We need to handle this state and make the
situation visible to upper layers.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Notes:
Version 2:
- rebased on top of newly added "qemu: Use switch in
qemuProcessHandleMigrationStatus"
src/hypervisor/domain_job.c | 1 +
src/hypervisor/domain_job.h | 1 +
src/qemu/qemu_driver.c | 1 +
src/qemu/qemu_migration.c | 11 +++++++++++
src/qemu/qemu_monitor.c | 1 +
src/qemu/qemu_monitor.h | 1 +
src/qemu/qemu_monitor_json.c | 1 +
src/qemu/qemu_process.c | 11 +++++++++++
8 files changed, 28 insertions(+)
diff --git a/src/hypervisor/domain_job.c b/src/hypervisor/domain_job.c
index ff4e008cb5..49867c3982 100644
--- a/src/hypervisor/domain_job.c
+++ b/src/hypervisor/domain_job.c
@@ -93,6 +93,7 @@ virDomainJobStatusToType(virDomainJobStatus status)
case VIR_DOMAIN_JOB_STATUS_MIGRATING:
case VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED:
case VIR_DOMAIN_JOB_STATUS_POSTCOPY:
+ case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED:
case VIR_DOMAIN_JOB_STATUS_PAUSED:
return VIR_DOMAIN_JOB_UNBOUNDED;
diff --git a/src/hypervisor/domain_job.h b/src/hypervisor/domain_job.h
index db8b8b1390..fce35ffbf5 100644
--- a/src/hypervisor/domain_job.h
+++ b/src/hypervisor/domain_job.h
@@ -78,6 +78,7 @@ typedef enum {
VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED,
VIR_DOMAIN_JOB_STATUS_PAUSED,
VIR_DOMAIN_JOB_STATUS_POSTCOPY,
+ VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED,
VIR_DOMAIN_JOB_STATUS_COMPLETED,
VIR_DOMAIN_JOB_STATUS_FAILED,
VIR_DOMAIN_JOB_STATUS_CANCELED,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4f9eb7b987..28cb454ab7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12540,6 +12540,7 @@ qemuDomainGetJobInfoMigrationStats(virQEMUDriver *driver,
case VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED:
case VIR_DOMAIN_JOB_STATUS_POSTCOPY:
case VIR_DOMAIN_JOB_STATUS_PAUSED:
+ case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED:
if (qemuMigrationAnyFetchStats(driver, vm, VIR_ASYNC_JOB_NONE,
jobData, NULL) < 0)
return -1;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f81d1e65ff..de4be0e7f9 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1747,6 +1747,10 @@ qemuMigrationUpdateJobType(virDomainJobData *jobData)
jobData->status = VIR_DOMAIN_JOB_STATUS_POSTCOPY;
break;
+ case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED:
+ jobData->status = VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED;
+ break;
+
case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
jobData->status = VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED;
break;
@@ -1871,6 +1875,12 @@ qemuMigrationJobCheckStatus(virQEMUDriver *driver,
qemuMigrationJobName(vm), _("canceled by client"));
return -1;
+ case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED:
+ virReportError(VIR_ERR_OPERATION_FAILED, _("%s: %s"),
+ qemuMigrationJobName(vm),
+ _("post-copy phase failed"));
+ return -1;
+
case VIR_DOMAIN_JOB_STATUS_COMPLETED:
case VIR_DOMAIN_JOB_STATUS_ACTIVE:
case VIR_DOMAIN_JOB_STATUS_MIGRATING:
@@ -1973,6 +1983,7 @@ qemuMigrationAnyCompleted(virQEMUDriver *driver,
case VIR_DOMAIN_JOB_STATUS_FAILED:
case VIR_DOMAIN_JOB_STATUS_CANCELED:
+ case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED:
/* QEMU aborted the migration. */
return -1;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2cfe9dbb00..8d0f54e4a0 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -149,6 +149,7 @@ VIR_ENUM_IMPL(qemuMonitorMigrationStatus,
"inactive", "setup",
"active", "pre-switchover",
"device", "postcopy-active",
+ "postcopy-paused",
"completed", "failed",
"cancelling", "cancelled",
"wait-unplug",
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index be341d5196..90532962fe 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -795,6 +795,7 @@ typedef enum {
QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER,
QEMU_MONITOR_MIGRATION_STATUS_DEVICE,
QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY,
+ QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED,
QEMU_MONITOR_MIGRATION_STATUS_COMPLETED,
QEMU_MONITOR_MIGRATION_STATUS_ERROR,
QEMU_MONITOR_MIGRATION_STATUS_CANCELLING,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index dc05dfd047..ffff9e7103 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3242,6 +3242,7 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValue *reply,
case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE:
case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY:
+ case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED:
case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
case QEMU_MONITOR_MIGRATION_STATUS_CANCELLING:
case QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f1264909de..6acf5c7881 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1513,6 +1513,17 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_GNUC_UNUSED,
}
break;
+ case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_PAUSED:
+ if (priv->job.asyncJob == VIR_ASYNC_JOB_MIGRATION_OUT &&
+ state == VIR_DOMAIN_PAUSED) {
+ /* At this point no thread is watching the migration progress on
+ * the source as it is just waiting for the Finish phase to end.
+ * Thus we need to handle the event here. */
+ qemuMigrationSrcPostcopyFailed(vm);
+ qemuDomainSaveStatus(vm);
+ }
+ break;
+
case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE:
case QEMU_MONITOR_MIGRATION_STATUS_SETUP:
case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE:
--
2.35.1