From: Cristian Klein <cristiklein(a)gmail.com>
Signed-off-by: Cristian Klein <cristiklein(a)gmail.com>
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Notes:
Version 3:
- no change
Version 2:
- no change
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_migration.c | 2 ++
4 files changed, 62 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5165c97..c663eb5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -214,6 +214,7 @@ qemuDomainObjResetAsyncJob(qemuDomainObjPrivatePtr priv)
job->dump_memory_only = false;
job->abortJob = false;
job->spiceMigrated = false;
+ job->postcopyEnabled = false;
VIR_FREE(job->current);
}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index b6f493e..e8c9254 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -140,6 +140,7 @@ struct qemuDomainJobObj {
bool spiceMigration; /* we asked for spice migration and we
* should wait for it to finish */
bool spiceMigrated; /* spice migration completed */
+ bool postcopyEnabled; /* post-copy migration was enabled */
};
typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 460232a..83d7dd7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13409,6 +13409,63 @@ qemuDomainMigrateGetMaxSpeed(virDomainPtr dom,
}
+static int
+qemuDomainMigrateStartPostCopy(virDomainPtr dom,
+ unsigned int flags)
+{
+ virQEMUDriverPtr driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ qemuDomainObjPrivatePtr priv;
+ int ret = -1;
+
+ virCheckFlags(0, -1);
+
+ if (!(vm = qemuDomObjFromDomain(dom)))
+ goto cleanup;
+
+ if (virDomainMigrateStartPostCopyEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("domain is not running"));
+ goto endjob;
+ }
+
+ priv = vm->privateData;
+
+ if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("post-copy can only be started while "
+ "outgoing migration is in progress"));
+ goto endjob;
+ }
+
+ if (!priv->job.postcopyEnabled) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("switching to post-copy requires migration to be "
+ "started with VIR_MIGRATE_POSTCOPY flag"));
+ goto endjob;
+ }
+
+ VIR_DEBUG("Starting post-copy");
+ qemuDomainObjEnterMonitor(driver, vm);
+ ret = qemuMonitorMigrateStartPostCopy(priv->mon);
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ ret = -1;
+
+ endjob:
+ qemuDomainObjEndJob(driver, vm);
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
typedef enum {
VIR_DISK_CHAIN_NO_ACCESS,
VIR_DISK_CHAIN_READ_ONLY,
@@ -20225,6 +20282,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
.domainInterfaceAddresses = qemuDomainInterfaceAddresses, /* 1.2.14 */
.domainSetUserPassword = qemuDomainSetUserPassword, /* 1.2.16 */
.domainRename = qemuDomainRename, /* 1.2.19 */
+ .domainMigrateStartPostCopy = qemuDomainMigrateStartPostCopy, /* 1.3.2 */
};
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index e9f44a5..202e955 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2452,6 +2452,8 @@ qemuMigrationSetPostCopy(virQEMUDriverPtr driver,
cleanup:
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
+ if (ret == 0)
+ priv->job.postcopyEnabled = state;
return ret;
}
--
2.7.2