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

[libvirt] [PATCH 02/11] qemu: added low-level post-copy migration functions



Signed-off-by: Cristian Klein <cristiklein gmail com>
---
 src/qemu/qemu_monitor.c      | 24 ++++++++++++++++++++++--
 src/qemu/qemu_monitor.h      |  4 ++++
 src/qemu/qemu_monitor_json.c | 23 ++++++++++++++++++++++-
 src/qemu/qemu_monitor_json.h |  1 +
 4 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index c9c84f9..6ecc35c 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -117,11 +117,11 @@ VIR_ONCE_GLOBAL_INIT(qemuMonitor)
 
 VIR_ENUM_IMPL(qemuMonitorMigrationStatus,
               QEMU_MONITOR_MIGRATION_STATUS_LAST,
-              "inactive", "active", "completed", "failed", "cancelled", "setup")
+              "inactive", "active", "completed", "failed", "cancelled", "setup", "postcopy-active")
 
 VIR_ENUM_IMPL(qemuMonitorMigrationCaps,
               QEMU_MONITOR_MIGRATION_CAPS_LAST,
-              "xbzrle", "auto-converge", "rdma-pin-all")
+              "xbzrle", "auto-converge", "rdma-pin-all", "x-postcopy-ram")
 
 VIR_ENUM_IMPL(qemuMonitorVMStatus,
               QEMU_MONITOR_VM_STATUS_LAST,
@@ -2422,6 +2422,26 @@ int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
     return ret;
 }
 
+int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon)
+{
+    VIR_DEBUG("mon=%p", mon);
+
+    if (!mon) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("monitor must not be NULL"));
+        return -1;
+    }
+
+    if (!mon->json) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                       _("JSON monitor is required"));
+        return -1;
+    }
+
+    return qemuMonitorJSONMigrateStartPostCopy(mon);
+}
+
+
 int qemuMonitorMigrateCancel(qemuMonitorPtr mon)
 {
     int ret;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 21533a4..17bf879 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -452,6 +452,7 @@ enum {
     QEMU_MONITOR_MIGRATION_STATUS_ERROR,
     QEMU_MONITOR_MIGRATION_STATUS_CANCELLED,
     QEMU_MONITOR_MIGRATION_STATUS_SETUP,
+    QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_ACTIVE,
 
     QEMU_MONITOR_MIGRATION_STATUS_LAST
 };
@@ -505,6 +506,7 @@ typedef enum {
     QEMU_MONITOR_MIGRATION_CAPS_XBZRLE,
     QEMU_MONITOR_MIGRATION_CAPS_AUTO_CONVERGE,
     QEMU_MONITOR_MIGRATION_CAPS_RDMA_PIN_ALL,
+    QEMU_MONITOR_MIGRATION_CAPS_POSTCOPY,
 
     QEMU_MONITOR_MIGRATION_CAPS_LAST
 } qemuMonitorMigrationCaps;
@@ -561,6 +563,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 6e251b3..c83f738 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2557,7 +2557,8 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
         status->setup_time_set = true;
 
     if (status->status == QEMU_MONITOR_MIGRATION_STATUS_ACTIVE ||
-        status->status == QEMU_MONITOR_MIGRATION_STATUS_COMPLETED) {
+        status->status == QEMU_MONITOR_MIGRATION_STATUS_COMPLETED ||
+        status->status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_ACTIVE)  {
         virJSONValuePtr ram = virJSONValueObjectGet(ret, "ram");
         if (!ram) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -2797,6 +2798,26 @@ int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
     return ret;
 }
 
+int qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon)
+{
+    int ret;
+    virJSONValuePtr cmd;
+    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 ae20fb1..71558c6 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -152,6 +152,7 @@ int qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitorPtr mon,
                                            bool *spice_migrated);
 
 
+int qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon);
 int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon);
 
 int qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
-- 
1.9.1


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