Re: [PATCH v15 09/14] migration: New migrate and migrate-incoming argument 'channels'

2023-10-31 Thread Juan Quintela
Fabiano Rosas  wrote:
> From: Het Gala 
>
> 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 
> Signed-off-by: Het Gala 
> Acked-by: Markus Armbruster 
> Reviewed-by: Daniel P. Berrangé 
> Signed-off-by: Fabiano Rosas 

Reviewed-by: Juan Quintela 




[PATCH v15 09/14] migration: New migrate and migrate-incoming argument 'channels'

2023-10-23 Thread Fabiano Rosas
From: Het Gala 

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 
Signed-off-by: Het Gala 
Acked-by: Markus Armbruster 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Fabiano Rosas 
---
 migration/migration-hmp-cmds.c |   6 +-
 migration/migration.c  |  56 +++--
 qapi/migration.json| 109 -
 system/vl.c|   2 +-
 4 files changed, 161 insertions(+), 12 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index a82597f18e..c1a73df7c0 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -447,7 +447,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, );
+qmp_migrate_incoming(uri, false, NULL, );
 
 hmp_handle_error(mon, err);
 }
@@ -745,8 +745,8 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
 const char *uri = qdict_get_str(qdict, "uri");
 Error *err = NULL;
 
-qmp_migrate(uri, !!blk, blk, !!inc, inc,
-false, false, true, resume, );
+qmp_migrate(uri, false, NULL, !!blk, blk, !!inc, inc,
+ false, false, true, resume, );
 if (hmp_handle_error(mon, err)) {
 return;
 }
diff --git a/migration/migration.c b/migration/migration.c
index c8b50b1dd5..4356d9e701 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -481,11 +481,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;
@@ -1572,7 +1595,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;
@@ -1590,7 +1614,7 @@ void qmp_migrate_incoming(const char *uri, Error **errp)
 return;
 }
 
-qemu_start_incoming_migration(uri, _err);
+qemu_start_incoming_migration(uri, has_channels, channels, _err);
 
 if (local_err) {
 yank_unregister_instance(MIGRATION_YANK_INSTANCE);
@@ -1626,7 +1650,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)
@@ -1757,7 +1781,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)
 {
@@ -1766,6 +1791,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