@@ -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;
@@ -479,7 +480,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;
}
@@ -487,44 +490,47 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels,
MigrationChannelList *channels,
Error **errp)
{
- g_autoptr(MigrationAddress) channel = NULL;
+ MigrationChannel *channel = NULL;
+ MigrationAddress *addr = 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) {
+ } 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;
}
migrate_set_state(&mis->state, MIGRATION_STATUS_NONE,
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) {
@@ -533,13 +539,13 @@ 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);
+ } else if (addr->transport == MIGRATION_ADDRESS_TYPE_RDMA) {
+ rdma_start_incoming_migration(&addr->u.rdma, errp);
#endif
- } else if (channel->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
- exec_start_incoming_migration(channel->u.exec.args, errp);
- } else if (channel->transport == MIGRATION_ADDRESS_TYPE_FILE) {
- file_start_incoming_migration(&channel->u.file, errp);
+ } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
+ exec_start_incoming_migration(addr->u.exec.args, errp);
+ } else if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) {
+ file_start_incoming_migration(&addr->u.file, errp);
} else {
error_setg(errp, "unknown migration protocol: %s", uri);
}
@@ -1774,35 +1780,38 @@ void qmp_migrate(const char *uri, bool has_channels,
bool resume_requested;
Error *local_err = NULL;
MigrationState *s = migrate_get_current();
- 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;
}
@@ -1819,8 +1828,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) {
@@ -1829,13 +1838,13 @@ 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 (channel->transport == MIGRATION_ADDRESS_TYPE_FILE) {
- file_start_outgoing_migration(s, &channel->u.file, &local_err);
+ } else if (addr->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
+ exec_start_outgoing_migration(s, addr->u.exec.args, &local_err);
+ } else if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) {
+ file_start_outgoing_migration(s, &addr->u.file, &local_err);
} else {
error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, "uri",
"a valid migration protocol");