[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 36/40] migration: New migrate and migrate-incoming argument 'chann
From: |
Juan Quintela |
Subject: |
[PULL 36/40] migration: New migrate and migrate-incoming argument 'channels' |
Date: |
Thu, 2 Nov 2023 12:40:50 +0100 |
From: Het Gala <het.gala@nutanix.com>
MigrateChannelList allows to connect accross multiple interfaces.
Add MigrateChannelList struct as argument to migration QAPIs.
We plan to include multiple channels in future, to connnect
multiple interfaces. Hence, we choose 'MigrateChannelList'
as the new argument over 'MigrateChannel' to make migration
QAPIs future proof.
Suggested-by: Aravind Retnakaran <aravind.retnakaran@nutanix.com>
Signed-off-by: Het Gala <het.gala@nutanix.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231023182053.8711-10-farosas@suse.de>
---
qapi/migration.json | 113 ++++++++++++++++++++++++++++++++-
migration/migration-hmp-cmds.c | 6 +-
migration/migration.c | 56 ++++++++++++++--
system/vl.c | 2 +-
4 files changed, 167 insertions(+), 10 deletions(-)
diff --git a/qapi/migration.json b/qapi/migration.json
index 182b150b87..975761eebd 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1641,6 +1641,34 @@
'rdma': 'InetSocketAddress',
'file': 'FileMigrationArgs' } }
+##
+# @MigrationChannelType:
+#
+# The migration channel-type request options.
+#
+# @main: Main outbound migration channel.
+#
+# Since 8.1
+##
+{ 'enum': 'MigrationChannelType',
+ 'data': [ 'main' ] }
+
+##
+# @MigrationChannel:
+#
+# Migration stream channel parameters.
+#
+# @channel-type: Channel type for transfering packet information.
+#
+# @addr: Migration endpoint configuration on destination interface.
+#
+# Since 8.1
+##
+{ 'struct': 'MigrationChannel',
+ 'data': {
+ 'channel-type': 'MigrationChannelType',
+ 'addr': 'MigrationAddress' } }
+
##
# @migrate:
#
@@ -1648,6 +1676,9 @@
#
# @uri: the Uniform Resource Identifier of the destination VM
#
+# @channels: list of migration stream channels with each stream in the
+# list connected to a destination interface endpoint.
+#
# @blk: do block migration (full disk copy)
#
# @inc: incremental disk copy migration
@@ -1677,13 +1708,57 @@
# 3. The user Monitor's "detach" argument is invalid in QMP and should
# not be used
#
+# 4. The uri argument should have the Uniform Resource Identifier of
+# default destination VM. This connection will be bound to default
+# network.
+#
+# 5. For now, number of migration streams is restricted to one, i.e
+# number of items in 'channels' list is just 1.
+#
+# 6. The 'uri' and 'channels' arguments are mutually exclusive;
+# exactly one of the two should be present.
+#
# Example:
#
# -> { "execute": "migrate", "arguments": { "uri": "tcp:0:4446" } }
# <- { "return": {} }
+# -> { "execute": "migrate",
+# "arguments": {
+# "channels": [ { "channel-type": "main",
+# "addr": { "transport": "socket",
+# "type": "inet",
+# "host": "10.12.34.9",
+# "port": "1050" } } ] } }
+# <- { "return": {} }
+#
+# -> { "execute": "migrate",
+# "arguments": {
+# "channels": [ { "channel-type": "main",
+# "addr": { "transport": "exec",
+# "args": [ "/bin/nc", "-p", "6000",
+# "/some/sock" ] } } ] } }
+# <- { "return": {} }
+#
+# -> { "execute": "migrate",
+# "arguments": {
+# "channels": [ { "channel-type": "main",
+# "addr": { "transport": "rdma",
+# "host": "10.12.34.9",
+# "port": "1050" } } ] } }
+# <- { "return": {} }
+#
+# -> { "execute": "migrate",
+# "arguments": {
+# "channels": [ { "channel-type": "main",
+# "addr": { "transport": "file",
+# "filename": "/tmp/migfile",
+# "offset": "0x1000" } } ] } }
+# <- { "return": {} }
+#
##
{ 'command': 'migrate',
'data': {'uri': 'str',
+ '*channels': [ 'MigrationChannel' ],
'*blk': { 'type': 'bool', 'features': [ 'deprecated' ] },
'*inc': { 'type': 'bool', 'features': [ 'deprecated' ] },
'*detach': 'bool', '*resume': 'bool' } }
@@ -1697,6 +1772,9 @@
# @uri: The Uniform Resource Identifier identifying the source or
# address to listen on
#
+# @channels: list of migration stream channels with each stream in the
+# list connected to a destination interface endpoint.
+#
# Returns: nothing on success
#
# Since: 2.3
@@ -1712,13 +1790,46 @@
#
# 3. The uri format is the same as for -incoming
#
+# 5. For now, number of migration streams is restricted to one, i.e
+# number of items in 'channels' list is just 1.
+#
+# 4. The 'uri' and 'channels' arguments are mutually exclusive;
+# exactly one of the two should be present.
+#
# Example:
#
# -> { "execute": "migrate-incoming",
# "arguments": { "uri": "tcp::4446" } }
# <- { "return": {} }
+#
+# -> { "execute": "migrate",
+# "arguments": {
+# "channels": [ { "channel-type": "main",
+# "addr": { "transport": "socket",
+# "type": "inet",
+# "host": "10.12.34.9",
+# "port": "1050" } } ] } }
+# <- { "return": {} }
+#
+# -> { "execute": "migrate",
+# "arguments": {
+# "channels": [ { "channel-type": "main",
+# "addr": { "transport": "exec",
+# "args": [ "/bin/nc", "-p", "6000",
+# "/some/sock" ] } } ] } }
+# <- { "return": {} }
+#
+# -> { "execute": "migrate",
+# "arguments": {
+# "channels": [ { "channel-type": "main",
+# "addr": { "transport": "rdma",
+# "host": "10.12.34.9",
+# "port": "1050" } } ] } }
+# <- { "return": {} }
##
-{ 'command': 'migrate-incoming', 'data': {'uri': 'str' } }
+{ 'command': 'migrate-incoming',
+ 'data': {'*uri': 'str',
+ '*channels': [ 'MigrationChannel' ] } }
##
# @xen-save-devices-state:
diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index a170440991..6ec778a990 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -452,7 +452,7 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)
Error *err = NULL;
const char *uri = qdict_get_str(qdict, "uri");
- qmp_migrate_incoming(uri, &err);
+ qmp_migrate_incoming(uri, false, NULL, &err);
hmp_handle_error(mon, err);
}
@@ -764,8 +764,8 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
" use blockdev-mirror with NBD instead");
}
- qmp_migrate(uri, !!blk, blk, !!inc, inc,
- false, false, true, resume, &err);
+ qmp_migrate(uri, false, NULL, !!blk, blk, !!inc, inc,
+ false, false, true, resume, &err);
if (hmp_handle_error(mon, err)) {
return;
}
diff --git a/migration/migration.c b/migration/migration.c
index 04037b340c..a9cd5e2d5d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -506,11 +506,34 @@ static bool migrate_uri_parse(const char *uri,
return true;
}
-static void qemu_start_incoming_migration(const char *uri, Error **errp)
+static void qemu_start_incoming_migration(const char *uri, bool has_channels,
+ MigrationChannelList *channels,
+ Error **errp)
{
g_autoptr(MigrationAddress) channel = NULL;
MigrationIncomingState *mis = migration_incoming_get_current();
+ /*
+ * Having preliminary checks for uri and channel
+ */
+ if (has_channels) {
+ error_setg(errp, "'channels' argument should not be set yet.");
+ return;
+ }
+
+ if (uri && has_channels) {
+ error_setg(errp, "'uri' and 'channels' arguments are mutually "
+ "exclusive; exactly one of the two should be present in "
+ "'migrate-incoming' qmp command ");
+ return;
+ }
+
+ if (!uri && !has_channels) {
+ error_setg(errp, "neither 'uri' or 'channels' argument are "
+ "specified in 'migrate-incoming' qmp command ");
+ return;
+ }
+
/* URI is not suitable for migration? */
if (!migration_channels_and_uri_compatible(uri, errp)) {
return;
@@ -1681,7 +1704,8 @@ void migrate_del_blocker(Error **reasonp)
}
}
-void qmp_migrate_incoming(const char *uri, Error **errp)
+void qmp_migrate_incoming(const char *uri, bool has_channels,
+ MigrationChannelList *channels, Error **errp)
{
Error *local_err = NULL;
static bool once = true;
@@ -1699,7 +1723,7 @@ void qmp_migrate_incoming(const char *uri, Error **errp)
return;
}
- qemu_start_incoming_migration(uri, &local_err);
+ qemu_start_incoming_migration(uri, has_channels, channels, &local_err);
if (local_err) {
yank_unregister_instance(MIGRATION_YANK_INSTANCE);
@@ -1735,7 +1759,7 @@ void qmp_migrate_recover(const char *uri, Error **errp)
* only re-setup the migration stream and poke existing migration
* to continue using that newly established channel.
*/
- qemu_start_incoming_migration(uri, errp);
+ qemu_start_incoming_migration(uri, false, NULL, errp);
}
void qmp_migrate_pause(Error **errp)
@@ -1892,7 +1916,8 @@ static bool migrate_prepare(MigrationState *s, bool blk,
bool blk_inc,
return true;
}
-void qmp_migrate(const char *uri, bool has_blk, bool blk,
+void qmp_migrate(const char *uri, bool has_channels,
+ MigrationChannelList *channels, bool has_blk, bool blk,
bool has_inc, bool inc, bool has_detach, bool detach,
bool has_resume, bool resume, Error **errp)
{
@@ -1901,6 +1926,27 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
MigrationState *s = migrate_get_current();
g_autoptr(MigrationAddress) channel = NULL;
+ /*
+ * Having preliminary checks for uri and channel
+ */
+ if (has_channels) {
+ error_setg(errp, "'channels' argument should not be set yet.");
+ return;
+ }
+
+ if (uri && has_channels) {
+ error_setg(errp, "'uri' and 'channels' arguments are mutually "
+ "exclusive; exactly one of the two should be present in "
+ "'migrate' qmp command ");
+ return;
+ }
+
+ if (!uri && !has_channels) {
+ error_setg(errp, "neither 'uri' or 'channels' argument are "
+ "specified in 'migrate' qmp command ");
+ return;
+ }
+
/* URI is not suitable for migration? */
if (!migration_channels_and_uri_compatible(uri, errp)) {
return;
diff --git a/system/vl.c b/system/vl.c
index 92d29bf521..3fb569254a 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2702,7 +2702,7 @@ void qmp_x_exit_preconfig(Error **errp)
if (incoming) {
Error *local_err = NULL;
if (strcmp(incoming, "defer") != 0) {
- qmp_migrate_incoming(incoming, &local_err);
+ qmp_migrate_incoming(incoming, false, NULL, &local_err);
if (local_err) {
error_reportf_err(local_err, "-incoming %s: ", incoming);
exit(1);
--
2.41.0
- [PULL 26/40] migration: Refactor error handling in source return path, (continued)
- [PULL 26/40] migration: Refactor error handling in source return path, Juan Quintela, 2023/11/02
- [PULL 27/40] migration: Allow network to fail even during recovery, Juan Quintela, 2023/11/02
- [PULL 28/40] tests/migration-test: Add a test for postcopy hangs during RECOVER, Juan Quintela, 2023/11/02
- [PULL 29/40] migration: Change ram_dirty_bitmap_reload() retval to bool, Juan Quintela, 2023/11/02
- [PULL 30/40] migration: New QAPI type 'MigrateAddress', Juan Quintela, 2023/11/02
- [PULL 31/40] migration: convert migration 'uri' into 'MigrateAddress', Juan Quintela, 2023/11/02
- [PULL 32/40] migration: convert socket backend to accept MigrateAddress, Juan Quintela, 2023/11/02
- [PULL 34/40] migration: convert exec backend to accept MigrateAddress., Juan Quintela, 2023/11/02
- [PULL 33/40] migration: convert rdma backend to accept MigrateAddress, Juan Quintela, 2023/11/02
- [PULL 35/40] migration: Convert the file backend to the new QAPI syntax, Juan Quintela, 2023/11/02
- [PULL 36/40] migration: New migrate and migrate-incoming argument 'channels',
Juan Quintela <=
- [PULL 38/40] migration: Implement MigrateChannelList to qmp migration flow., Juan Quintela, 2023/11/02
- [PULL 39/40] migration: Implement MigrateChannelList to hmp migration flow., Juan Quintela, 2023/11/02
- [PULL 40/40] migration: modify test_multifd_tcp_none() to use new QAPI syntax., Juan Quintela, 2023/11/02
- [PULL 37/40] migration: modify migration_channels_and_uri_compatible() for new QAPI syntax, Juan Quintela, 2023/11/02
- Re: [PULL 00/40] Migration 20231102 patches, Stefan Hajnoczi, 2023/11/02