diff mbox series

[RFC,v2,10/12] migration: Add start-migrate-incoming QMP command

Message ID 20210823141636.65975-11-dovmurik@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Confidential guest-assisted live migration | expand

Commit Message

Dov Murik Aug. 23, 2021, 2:16 p.m. UTC
This command forces a running VM into a migrate-incoming state.  When
using guest-assisted migration (for confidential guests), the target
must be started so that its memory has the necessary code for the
migration helper.  After it is ready we can start receiving the incoming
migration connection.

Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
---
 qapi/migration.json   | 26 ++++++++++++++++++++++++++
 migration/migration.c | 17 +++++++++++++++++
 2 files changed, 43 insertions(+)
diff mbox series

Patch

diff --git a/qapi/migration.json b/qapi/migration.json
index baff3c6bf7..da47b8534f 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1516,6 +1516,32 @@ 
 ##
 { 'command': 'start-migration-handler' }
 
+##
+# @start-migrate-incoming:
+#
+# Force start an incoming migration even in a running VM.  This is used by the
+# target VM in guest-assisted migration of a confidential guest.
+#
+# @uri: The Uniform Resource Identifier identifying the source or
+#       address to listen on
+#
+# Returns: nothing on success
+#
+# Since: 6.0
+#
+# Notes:
+#
+# The uri format is the same as the -incoming command-line option.
+#
+# Example:
+#
+# -> { "execute": "start-migrate-incoming",
+#      "arguments": { "uri": "tcp::4446" } }
+# <- { "return": {} }
+#
+##
+{ 'command': 'start-migrate-incoming', 'data': {'uri': 'str' } }
+
 ##
 # @xen-save-devices-state:
 #
diff --git a/migration/migration.c b/migration/migration.c
index a9f3a79e4f..0b9ab3decb 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2173,6 +2173,23 @@  void qmp_start_migration_handler(Error **errp)
     }
 }
 
+void qmp_start_migrate_incoming(const char *uri, Error **errp)
+{
+    Error *local_err = NULL;
+
+    if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) {
+        return;
+    }
+
+    vm_stop(RUN_STATE_PAUSED);
+    qemu_start_incoming_migration(uri, &local_err);
+
+    if (local_err) {
+        yank_unregister_instance(MIGRATION_YANK_INSTANCE);
+        error_propagate(errp, local_err);
+    }
+}
+
 void qmp_migrate_recover(const char *uri, Error **errp)
 {
     MigrationIncomingState *mis = migration_incoming_get_current();