[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 4/6] Added domainMigrateStartPostCopy in qemu driver



Signed-off-by: Cristian Klein <cristian klein cs umu se>
---
 src/qemu/qemu_driver.c       | 44 ++++++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_monitor.c      | 19 +++++++++++++++++++
 src/qemu/qemu_monitor.h      |  2 ++
 src/qemu/qemu_monitor_json.c | 18 ++++++++++++++++++
 src/qemu/qemu_monitor_json.h |  1 +
 src/qemu/qemu_monitor_text.c | 11 +++++++++++
 src/qemu/qemu_monitor_text.h |  2 ++
 7 files changed, 97 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e73d4f9..02c9a3b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11861,6 +11861,49 @@ qemuDomainGetJobStats(virDomainPtr dom,
 }
 
 
+static int qemuMigrateStartPostCopy(virDomainPtr dom)
+{
+    virQEMUDriverPtr driver = dom->conn->privateData;
+    virDomainObjPtr vm;
+    int ret = -1;
+    qemuDomainObjPrivatePtr priv;
+
+    if (!(vm = qemuDomObjFromDomain(dom)))
+        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 migration is in progress"));
+        goto cleanup;
+    }
+
+    VIR_DEBUG("Starting post-copy");
+    qemuDomainObjEnterMonitor(driver, vm);
+    ret = qemuMonitorMigrateStartPostCopy(priv->mon);
+    qemuDomainObjExitMonitor(driver, vm);
+
+ endjob:
+    if (!qemuDomainObjEndJob(driver, vm))
+        vm = NULL;
+
+ cleanup:
+    if (vm)
+        virObjectUnlock(vm);
+    return ret;
+}
+
 static int qemuDomainAbortJob(virDomainPtr dom)
 {
     virQEMUDriverPtr driver = dom->conn->privateData;
@@ -18259,6 +18302,7 @@ static virDriver qemuDriver = {
     .nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
     .connectGetDomainCapabilities = qemuConnectGetDomainCapabilities, /* 1.2.7 */
     .connectGetAllDomainStats = qemuConnectGetAllDomainStats, /* 1.2.8 */
+    .domainMigrateStartPostCopy = qemuMigrateStartPostCopy, /* 1.2.9 */
 };
 
 
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 14688bf..0b230cc 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2384,6 +2384,25 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
     return ret;
 }
 
+int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon)
+{
+    int ret;
+    VIR_DEBUG("mon=%p", mon);
+
+    if (!mon) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("monitor must not be NULL"));
+        return -1;
+    }
+
+    if (mon->json)
+        ret = qemuMonitorJSONMigrateStartPostCopy(mon);
+    else
+        ret = qemuMonitorTextMigrateStartPostCopy(mon);
+    return ret;
+}
+
+
 int qemuMonitorMigrateCancel(qemuMonitorPtr mon)
 {
     int ret;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 587f779..97d980d 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -539,6 +539,8 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
                              unsigned int flags,
                              const char *unixfile);
 
+int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon);
+
 int qemuMonitorMigrateCancel(qemuMonitorPtr mon);
 
 int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e98962b..14e7f84 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2798,6 +2798,24 @@ int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
     return ret;
 }
 
+int qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon)
+{
+    int ret;
+    virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("migrate-start-postcopy", NULL);
+    virJSONValuePtr reply = NULL;
+    if (!cmd)
+        return -1;
+
+    ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+    if (ret == 0)
+        ret = qemuMonitorJSONCheckError(cmd, reply);
+
+    virJSONValueFree(cmd);
+    virJSONValueFree(reply);
+    return ret;
+}
+
 int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon)
 {
     int ret;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index d366179..54beb7f 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -151,6 +151,7 @@ int qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitorPtr mon,
                                            bool *spice_migrated);
 
 
+int qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon);
 int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon);
 
 int qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index a3c8aa5..1354651 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1613,6 +1613,17 @@ int qemuMonitorTextMigrate(qemuMonitorPtr mon,
     return ret;
 }
 
+int qemuMonitorTextMigrateStartPostCopy(qemuMonitorPtr mon)
+{
+    char *info = NULL;
+    int ret;
+
+    ret = qemuMonitorHMPCommand(mon, "migrate-start-postcopy", &info);
+
+    VIR_FREE(info);
+    return ret;
+}
+
 int qemuMonitorTextMigrateCancel(qemuMonitorPtr mon)
 {
     char *info = NULL;
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index 49d4b88..ae982d5 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -123,6 +123,8 @@ int qemuMonitorTextMigrate(qemuMonitorPtr mon,
                            unsigned int flags,
                            const char *uri);
 
+int qemuMonitorTextMigrateStartPostCopy(qemuMonitorPtr mon);
+
 int qemuMonitorTextMigrateCancel(qemuMonitorPtr mon);
 
 int qemuMonitorTextGraphicsRelocate(qemuMonitorPtr mon,
-- 
1.9.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]