Re: [PATCH v9 06/10] migration: New migrate and migrate-incoming argument 'channels'

2023-07-26 Thread Het Gala



On 26/07/23 2:05 pm, Daniel P. Berrangé wrote:

On Wed, Jul 26, 2023 at 01:24:48AM +0530, Het Gala wrote:

Sorry, last reply on this patch was accidently replied only to Daniel.
Pasting the reply again so it is received by all the active maintianers
here. Apologies for the error 

On 26/07/23 12:07 am, Daniel P. Berrangé wrote:

On Tue, Jul 25, 2023 at 07:34:09PM +0100, Daniel P. Berrangé wrote:

On Fri, Jul 21, 2023 at 02:49:31PM +, Het Gala wrote:

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 
---
   migration/migration-hmp-cmds.c |   6 +-
   migration/migration.c  |  34 --
   qapi/migration.json| 109 -
   softmmu/vl.c   |   2 +-
   4 files changed, 139 insertions(+), 12 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 9885d7c9f7..49b150f33f 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -424,7 +424,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);
   }
@@ -705,8 +705,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 f37b388876..bd3a93fc8c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -466,10 +466,22 @@ 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 = g_new0(MigrationAddress, 1);
+/*
+ * Having preliminary checks for uri and channel
+ */
+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;
+}

This checks is both are present.

Also needs a check if neither are present as that's invalid.

Also it should (temporarily) raise an error if "has_channels" is
set, as while we've added the parameter in QAPI, we've not
implemented it yet. IOW, raise an error now, and remove the
error in a later patch.

Ack. So in total there should be 3 checks right. 1) if 'has_channels' is
set, 2) if 'uri' and 'channels' both are present, 3) if 'uri' and 'channels'
both are absent. Basically right now only uri should allowed and should
atleast be present.

Correct.

Ack.

I think overall only 1) would be enough and should be checked before
'migration_channels_and_uri_compatible()' and if 'has_channels' is set, just
return for now. With this 2) would not be necessary or not come into play in
this patch. 3) will be taken care by
'migration_channels_and_uri_compatible()' itself IMO.

I think all the checks should be in this method, as it is the entrypoint
for execution of the QMP command and thus where parameter validation
should live. Spreading it across methods will make it very easy to open
bugs by refactoring code and not realizing the new codepaths don't do
the right checks.
Okay, I got the concern here. Will add these 3 checks in this patch and 
later remove 'has_channels' check in the patch where we are implementing 
MigrateChannel.

With regards,
Daniel

Regards,
Het Gala



Re: [PATCH v9 06/10] migration: New migrate and migrate-incoming argument 'channels'

2023-07-26 Thread Daniel P . Berrangé
On Wed, Jul 26, 2023 at 01:24:48AM +0530, Het Gala wrote:
> Sorry, last reply on this patch was accidently replied only to Daniel.
> Pasting the reply again so it is received by all the active maintianers
> here. Apologies for the error 
> 
> On 26/07/23 12:07 am, Daniel P. Berrangé wrote:
> > On Tue, Jul 25, 2023 at 07:34:09PM +0100, Daniel P. Berrangé wrote:
> > > On Fri, Jul 21, 2023 at 02:49:31PM +, Het Gala wrote:
> > > > 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 
> > > > ---
> > > >   migration/migration-hmp-cmds.c |   6 +-
> > > >   migration/migration.c  |  34 --
> > > >   qapi/migration.json| 109 -
> > > >   softmmu/vl.c   |   2 +-
> > > >   4 files changed, 139 insertions(+), 12 deletions(-)
> > > > 
> > > > diff --git a/migration/migration-hmp-cmds.c 
> > > > b/migration/migration-hmp-cmds.c
> > > > index 9885d7c9f7..49b150f33f 100644
> > > > --- a/migration/migration-hmp-cmds.c
> > > > +++ b/migration/migration-hmp-cmds.c
> > > > @@ -424,7 +424,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);
> > > >   }
> > > > @@ -705,8 +705,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 f37b388876..bd3a93fc8c 100644
> > > > --- a/migration/migration.c
> > > > +++ b/migration/migration.c
> > > > @@ -466,10 +466,22 @@ 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 = g_new0(MigrationAddress, 1);
> > > > +/*
> > > > + * Having preliminary checks for uri and channel
> > > > + */
> > > > +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;
> > > > +}
> > > This checks is both are present.
> > > 
> > > Also needs a check if neither are present as that's invalid.
> > Also it should (temporarily) raise an error if "has_channels" is
> > set, as while we've added the parameter in QAPI, we've not
> > implemented it yet. IOW, raise an error now, and remove the
> > error in a later patch.
> Ack. So in total there should be 3 checks right. 1) if 'has_channels' is
> set, 2) if 'uri' and 'channels' both are present, 3) if 'uri' and 'channels'
> both are absent. Basically right now only uri should allowed and should
> atleast be present.

Correct.

> I think overall only 1) would be enough and should be checked before
> 'migration_channels_and_uri_compatible()' and if 'has_channels' is set, just
> return for now. With this 2) would not be necessary or not come into play in
> this patch. 3) will be taken care by
> 'migration_channels_and_uri_compatible()' itself IMO.

I think all the checks should be in this method, as it is the entrypoint
for execution of the QMP command and thus where parameter validation
should live. Spreading it across methods will make it very easy to open
bugs by refactoring code and not realizing the new codepaths don't do
the right checks.

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|




Re: [PATCH v9 06/10] migration: New migrate and migrate-incoming argument 'channels'

2023-07-25 Thread Het Gala
Sorry, last reply on this patch was accidently replied only to Daniel. 
Pasting the reply again so it is received by all the active maintianers 
here. Apologies for the error 


On 26/07/23 12:07 am, Daniel P. Berrangé wrote:

On Tue, Jul 25, 2023 at 07:34:09PM +0100, Daniel P. Berrangé wrote:

On Fri, Jul 21, 2023 at 02:49:31PM +, Het Gala wrote:

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 
---
  migration/migration-hmp-cmds.c |   6 +-
  migration/migration.c  |  34 --
  qapi/migration.json| 109 -
  softmmu/vl.c   |   2 +-
  4 files changed, 139 insertions(+), 12 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 9885d7c9f7..49b150f33f 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -424,7 +424,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);

  }
@@ -705,8 +705,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 f37b388876..bd3a93fc8c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -466,10 +466,22 @@ 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 = g_new0(MigrationAddress, 1);
  
+/*

+ * Having preliminary checks for uri and channel
+ */
+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;
+}

This checks is both are present.

Also needs a check if neither are present as that's invalid.

Also it should (temporarily) raise an error if "has_channels" is
set, as while we've added the parameter in QAPI, we've not
implemented it yet. IOW, raise an error now, and remove the
error in a later patch.
Ack. So in total there should be 3 checks right. 1) if 'has_channels' is 
set, 2) if 'uri' and 'channels' both are present, 3) if 'uri' and 
'channels' both are absent. Basically right now only uri should allowed 
and should atleast be present.
I think overall only 1) would be enough and should be checked before 
'migration_channels_and_uri_compatible()' and if 'has_channels' is set, 
just return for now. With this 2) would not be necessary or not come 
into play in this patch. 3) will be taken care by 
'migration_channels_and_uri_compatible()' itself IMO.

Let me know if I am missing something here.



@@ -1694,6 +1708,16 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
  MigrationState *s = migrate_get_current();
  g_autoptr(MigrationAddress) channel = g_new0(MigrationAddress, 1);
  
+/*

+ * Having preliminary checks for uri and channel
+ */
+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;
+}

Same here


With regards,
Daniel
--
|: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__berrange.com=DwIDaQ=s883GpUCOChKOHiocYtGcg=-qwZZzrw4EKSsq0BK7MBd3wW1WEpXmJeng3ZUT5uBCg=i0lmmIrs7N4r3uqLYCdRVXLFaEavt77Ltkec0hIlE4aUQITo9-8povsDHWELv-vE=AQ1C7WPg2jLYjNXU29Xw7trQcjmB96Yy3-God3-UaIQ=
   -o-
https://urldefense.proofpoint.com/v2/url?u=https-3A__www.flickr.com_photos_dberrange=DwIDaQ=s883GpUCOChKOHiocYtGcg=-qwZZzrw4EKSsq0BK7MBd3wW1WEpXmJeng3ZUT5uBCg=i0lmmIrs7N4r3uqLYCdRVXLFaEavt77Ltkec0hIlE4aUQITo9-8povsDHWELv-vE=aiGUx76ySVL-epTmaFIZUyZbkzeXGedVaXGvFw4xcgo=
  :|
|: 

Re: [PATCH v9 06/10] migration: New migrate and migrate-incoming argument 'channels'

2023-07-25 Thread Het Gala



On 26/07/23 12:07 am, Daniel P. Berrangé wrote:

On Tue, Jul 25, 2023 at 07:34:09PM +0100, Daniel P. Berrangé wrote:

On Fri, Jul 21, 2023 at 02:49:31PM +, Het Gala wrote:

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 
---
  migration/migration-hmp-cmds.c |   6 +-
  migration/migration.c  |  34 --
  qapi/migration.json| 109 -
  softmmu/vl.c   |   2 +-
  4 files changed, 139 insertions(+), 12 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 9885d7c9f7..49b150f33f 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -424,7 +424,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);

  }
@@ -705,8 +705,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 f37b388876..bd3a93fc8c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -466,10 +466,22 @@ 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 = g_new0(MigrationAddress, 1);
  
+/*

+ * Having preliminary checks for uri and channel
+ */
+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;
+}

This checks is both are present.

Also needs a check if neither are present as that's invalid.

Also it should (temporarily) raise an error if "has_channels" is
set, as while we've added the parameter in QAPI, we've not
implemented it yet. IOW, raise an error now, and remove the
error in a later patch.
Ack. So in total there should be 3 checks right. 1) if 'has_channels' is 
set, 2) if 'uri' and 'channels' both are present, 3) if 'uri' and 
'channels' both are absent. Basically right now only uri should allowed 
and should atleast be present.
I think overall only 1) would be enough and should be checked before 
'migration_channels_and_uri_compatible()' and if 'has_channels' is set, 
just return for now. With this 2) would not be necessary or not come 
into play in this patch. 3) will be taken care by 
'migration_channels_and_uri_compatible()' itself IMO.

Let me know if I am missing something here.



@@ -1694,6 +1708,16 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
  MigrationState *s = migrate_get_current();
  g_autoptr(MigrationAddress) channel = g_new0(MigrationAddress, 1);
  
+/*

+ * Having preliminary checks for uri and channel
+ */
+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;
+}

Same here


With regards,
Daniel
--
|: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__berrange.com=DwIDaQ=s883GpUCOChKOHiocYtGcg=-qwZZzrw4EKSsq0BK7MBd3wW1WEpXmJeng3ZUT5uBCg=i0lmmIrs7N4r3uqLYCdRVXLFaEavt77Ltkec0hIlE4aUQITo9-8povsDHWELv-vE=AQ1C7WPg2jLYjNXU29Xw7trQcjmB96Yy3-God3-UaIQ=
   -o-
https://urldefense.proofpoint.com/v2/url?u=https-3A__www.flickr.com_photos_dberrange=DwIDaQ=s883GpUCOChKOHiocYtGcg=-qwZZzrw4EKSsq0BK7MBd3wW1WEpXmJeng3ZUT5uBCg=i0lmmIrs7N4r3uqLYCdRVXLFaEavt77Ltkec0hIlE4aUQITo9-8povsDHWELv-vE=aiGUx76ySVL-epTmaFIZUyZbkzeXGedVaXGvFw4xcgo=
  :|
|: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__libvirt.org=DwIDaQ=s883GpUCOChKOHiocYtGcg=-qwZZzrw4EKSsq0BK7MBd3wW1WEpXmJeng3ZUT5uBCg=i0lmmIrs7N4r3uqLYCdRVXLFaEavt77Ltkec0hIlE4aUQITo9-8povsDHWELv-vE=beFwppzRJ_eYlYPZKHlSZpaysLC5AExPh5_inAZBu_k=
  -o-  

Re: [PATCH v9 06/10] migration: New migrate and migrate-incoming argument 'channels'

2023-07-25 Thread Daniel P . Berrangé
On Tue, Jul 25, 2023 at 07:34:09PM +0100, Daniel P. Berrangé wrote:
> On Fri, Jul 21, 2023 at 02:49:31PM +, Het Gala wrote:
> > 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 
> > ---
> >  migration/migration-hmp-cmds.c |   6 +-
> >  migration/migration.c  |  34 --
> >  qapi/migration.json| 109 -
> >  softmmu/vl.c   |   2 +-
> >  4 files changed, 139 insertions(+), 12 deletions(-)
> > 
> > diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> > index 9885d7c9f7..49b150f33f 100644
> > --- a/migration/migration-hmp-cmds.c
> > +++ b/migration/migration-hmp-cmds.c
> > @@ -424,7 +424,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);
> >  }
> > @@ -705,8 +705,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 f37b388876..bd3a93fc8c 100644
> > --- a/migration/migration.c
> > +++ b/migration/migration.c
> > @@ -466,10 +466,22 @@ 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 = g_new0(MigrationAddress, 1);
> >  
> > +/*
> > + * Having preliminary checks for uri and channel
> > + */
> > +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;
> > +}
> 
> This checks is both are present.
> 
> Also needs a check if neither are present as that's invalid.

Also it should (temporarily) raise an error if "has_channels" is
set, as while we've added the parameter in QAPI, we've not
implemented it yet. IOW, raise an error now, and remove the
error in a later patch.

> 
> 
> > @@ -1694,6 +1708,16 @@ void qmp_migrate(const char *uri, bool has_blk, bool 
> > blk,
> >  MigrationState *s = migrate_get_current();
> >  g_autoptr(MigrationAddress) channel = g_new0(MigrationAddress, 1);
> >  
> > +/*
> > + * Having preliminary checks for uri and channel
> > + */
> > +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;
> > +}
> 
> Same here 
> 
> 
> With regards,
> Daniel
> -- 
> |: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o-https://fstop138.berrange.com :|
> |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|




Re: [PATCH v9 06/10] migration: New migrate and migrate-incoming argument 'channels'

2023-07-25 Thread Daniel P . Berrangé
On Fri, Jul 21, 2023 at 02:49:31PM +, Het Gala wrote:
> 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 
> ---
>  migration/migration-hmp-cmds.c |   6 +-
>  migration/migration.c  |  34 --
>  qapi/migration.json| 109 -
>  softmmu/vl.c   |   2 +-
>  4 files changed, 139 insertions(+), 12 deletions(-)
> 
> diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> index 9885d7c9f7..49b150f33f 100644
> --- a/migration/migration-hmp-cmds.c
> +++ b/migration/migration-hmp-cmds.c
> @@ -424,7 +424,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);
>  }
> @@ -705,8 +705,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 f37b388876..bd3a93fc8c 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -466,10 +466,22 @@ 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 = g_new0(MigrationAddress, 1);
>  
> +/*
> + * Having preliminary checks for uri and channel
> + */
> +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;
> +}

This checks is both are present.

Also needs a check if neither are present as that's invalid.


> @@ -1694,6 +1708,16 @@ void qmp_migrate(const char *uri, bool has_blk, bool 
> blk,
>  MigrationState *s = migrate_get_current();
>  g_autoptr(MigrationAddress) channel = g_new0(MigrationAddress, 1);
>  
> +/*
> + * Having preliminary checks for uri and channel
> + */
> +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;
> +}

Same here 


With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|




[PATCH v9 06/10] migration: New migrate and migrate-incoming argument 'channels'

2023-07-21 Thread 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 
---
 migration/migration-hmp-cmds.c |   6 +-
 migration/migration.c  |  34 --
 qapi/migration.json| 109 -
 softmmu/vl.c   |   2 +-
 4 files changed, 139 insertions(+), 12 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 9885d7c9f7..49b150f33f 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -424,7 +424,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);
 }
@@ -705,8 +705,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 f37b388876..bd3a93fc8c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -466,10 +466,22 @@ 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 = g_new0(MigrationAddress, 1);
 
+/*
+ * Having preliminary checks for uri and channel
+ */
+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;
+}
+
 /* URI is not suitable for migration? */
 if (!migration_channels_and_uri_compatible(uri, errp)) {
 return;
@@ -1497,7 +1509,8 @@ void migrate_del_blocker(Error *reason)
 migration_blockers = g_slist_remove(migration_blockers, reason);
 }
 
-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;
@@ -1515,7 +1528,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);
@@ -1551,7 +1564,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)
@@ -1685,7 +1698,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)
 {
@@ -1694,6 +1708,16 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
 MigrationState *s = migrate_get_current();
 g_autoptr(MigrationAddress) channel = g_new0(MigrationAddress, 1);
 
+/*
+ * Having preliminary checks for uri and channel
+ */
+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;
+}
+
 /* URI is not suitable for migration? */
 if (!migration_channels_and_uri_compatible(uri, errp)) {
 return;
diff --git a/qapi/migration.json b/qapi/migration.json
index 0f4a54a7ed..9a365ac774 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1458,6 +1458,34 @@
 'exec': 'MigrationExecCommand',