[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v12 08/10] migration: Implement MigrateChannelList to qmp migrati
From: |
Het Gala |
Subject: |
[PATCH v12 08/10] migration: Implement MigrateChannelList to qmp migration flow. |
Date: |
Mon, 9 Oct 2023 14:36:13 +0000 |
Integrate MigrateChannelList with all transport backends
(socket, exec and rdma) for both src and dest migration
endpoints for qmp migration.
For current series, limit the size of MigrateChannelList
to single element (single interface) as runtime check.
Suggested-by: Aravind Retnakaran <aravind.retnakaran@nutanix.com>
Signed-off-by: Het Gala <het.gala@nutanix.com>
---
migration/migration.c | 95 +++++++++++++++++++++++--------------------
1 file changed, 52 insertions(+), 43 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 23c3a1079f..ff04728b33 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -433,9 +433,10 @@ void migrate_add_address(SocketAddress *address)
}
static bool migrate_uri_parse(const char *uri,
- MigrationAddress **channel,
+ MigrationChannel **channel,
Error **errp)
{
+ g_autoptr(MigrationChannel) val = g_new0(MigrationChannel, 1);
g_autoptr(MigrationAddress) addr = g_new0(MigrationAddress, 1);
SocketAddress *saddr = NULL;
InetSocketAddress *isock = &addr->u.rdma;
@@ -473,7 +474,9 @@ static bool migrate_uri_parse(const char *uri,
return false;
}
- *channel = g_steal_pointer(&addr);
+ val->channel_type = MIGRATION_CHANNEL_TYPE_MAIN;
+ val->addr = g_steal_pointer (&addr);
+ *channel = g_steal_pointer (&val);
return true;
}
@@ -482,41 +485,44 @@ static void qemu_start_incoming_migration(const char
*uri, bool has_channels,
Error **errp)
{
const char *p = NULL;
- g_autoptr(MigrationAddress) channel = NULL;
+ MigrationChannel *channel = NULL;
+ MigrationAddress *addr = 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-incoming' qmp command ");
return;
- }
-
- if (!uri && !has_channels) {
+ } else if (channels) {
+ /* To verify that Migrate channel list has only item */
+ if (channels->next) {
+ error_setg(errp, "Channel list has more than one entries");
+ return;
+ }
+ channel = channels->value;
+ } else if (uri) {
+ /* caller uses the old URI syntax */
+ if (!migrate_uri_parse(uri, &channel, errp)) {
+ return;
+ }
+ } else {
error_setg(errp, "neither 'uri' or 'channels' argument are "
"specified in 'migrate-incoming' qmp command ");
return;
}
-
- if (uri && !migrate_uri_parse(uri, &channel, errp)) {
- return;
- }
+ addr = channel->addr;
/* transport mechanism not suitable for migration? */
- if (!migration_channels_and_transport_compatible(channel, errp)) {
+ if (!migration_channels_and_transport_compatible(addr, errp)) {
return;
}
qapi_event_send_migration(MIGRATION_STATUS_SETUP);
- if (channel->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
- SocketAddress *saddr = &channel->u.socket;
+ if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
+ SocketAddress *saddr = &addr->u.socket;
if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||
saddr->type == SOCKET_ADDRESS_TYPE_UNIX ||
saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) {
@@ -525,11 +531,11 @@ static void qemu_start_incoming_migration(const char
*uri, bool has_channels,
fd_start_incoming_migration(saddr->u.fd.str, errp);
}
#ifdef CONFIG_RDMA
- } else if (channel->transport == MIGRATION_ADDRESS_TYPE_RDMA) {
- rdma_start_incoming_migration(&channel->u.rdma, errp);
-#endif
- } else if (channel->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
- exec_start_incoming_migration(channel->u.exec.args, errp);
+ } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) {
+ rdma_start_incoming_migration(&addr->u.rdma, errp);
+ #endif
+ } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
+ exec_start_incoming_migration(addr->u.exec.args, errp);
} else if (strstart(uri, "file:", &p)) {
file_start_incoming_migration(p, errp);
} else {
@@ -1756,35 +1762,38 @@ void qmp_migrate(const char *uri, bool has_channels,
Error *local_err = NULL;
MigrationState *s = migrate_get_current();
const char *p = NULL;
- g_autoptr(MigrationAddress) channel = NULL;
+ MigrationChannel *channel = NULL;
+ MigrationAddress *addr = 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) {
+ } else if (channels) {
+ /* To verify that Migrate channel list has only item */
+ if (channels->next) {
+ error_setg(errp, "Channel list has more than one entries");
+ return;
+ }
+ channel = channels->value;
+ } else if (uri) {
+ /* caller uses the old URI syntax */
+ if (!migrate_uri_parse(uri, &channel, errp)) {
+ return;
+ }
+ } else {
error_setg(errp, "neither 'uri' or 'channels' argument are "
"specified in 'migrate' qmp command ");
return;
}
-
- if (!migrate_uri_parse(uri, &channel, errp)) {
- return;
- }
+ addr = channel->addr;
/* transport mechanism not suitable for migration? */
- if (!migration_channels_and_transport_compatible(channel, errp)) {
+ if (!migration_channels_and_transport_compatible(addr, errp)) {
return;
}
@@ -1801,8 +1810,8 @@ void qmp_migrate(const char *uri, bool has_channels,
}
}
- if (channel->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
- SocketAddress *saddr = &channel->u.socket;
+ if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
+ SocketAddress *saddr = &addr->u.socket;
if (saddr->type == SOCKET_ADDRESS_TYPE_INET ||
saddr->type == SOCKET_ADDRESS_TYPE_UNIX ||
saddr->type == SOCKET_ADDRESS_TYPE_VSOCK) {
@@ -1811,11 +1820,11 @@ void qmp_migrate(const char *uri, bool has_channels,
fd_start_outgoing_migration(s, saddr->u.fd.str, &local_err);
}
#ifdef CONFIG_RDMA
- } else if (channel->transport == MIGRATION_ADDRESS_TYPE_RDMA) {
- rdma_start_outgoing_migration(s, &channel->u.rdma, &local_err);
+ } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) {
+ rdma_start_outgoing_migration(s, &addr->u.rdma, &local_err);
#endif
- } else if (channel->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
- exec_start_outgoing_migration(s, channel->u.exec.args, &local_err);
+ } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
+ exec_start_outgoing_migration(s, addr->u.exec.args, &local_err);
} else if (strstart(uri, "file:", &p)) {
file_start_outgoing_migration(s, p, &local_err);
} else {
--
2.22.3
- [PATCH v12 00/10] migration: Modify 'migrate' and 'migrate-incoming' QAPI commands for migration, Het Gala, 2023/10/09
- [PATCH v12 04/10] migration: convert rdma backend to accept MigrateAddress, Het Gala, 2023/10/09
- [PATCH v12 03/10] migration: convert socket backend to accept MigrateAddress, Het Gala, 2023/10/09
- [PATCH v12 01/10] migration: New QAPI type 'MigrateAddress', Het Gala, 2023/10/09
- [PATCH v12 02/10] migration: convert migration 'uri' into 'MigrateAddress', Het Gala, 2023/10/09
- [PATCH v12 07/10] migration: modify migration_channels_and_uri_compatible() for new QAPI syntax, Het Gala, 2023/10/09
- [PATCH v12 06/10] migration: New migrate and migrate-incoming argument 'channels', Het Gala, 2023/10/09
- [PATCH v12 08/10] migration: Implement MigrateChannelList to qmp migration flow.,
Het Gala <=
- [PATCH v12 09/10] migration: Implement MigrateChannelList to hmp migration flow., Het Gala, 2023/10/09
- [PATCH v12 10/10] migration: modify test_multifd_tcp_none() to use new QAPI syntax., Het Gala, 2023/10/09
- [PATCH v12 05/10] migration: convert exec backend to accept MigrateAddress., Het Gala, 2023/10/09
- Re: [PATCH v12 00/10] migration: Modify 'migrate' and 'migrate-incoming' QAPI commands for migration, Fabiano Rosas, 2023/10/09