All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] migration/cpr: Add HMP support for cpr-transfer
@ 2026-07-24  9:41 Dongli Zhang
  2026-07-27  0:46 ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 4+ messages in thread
From: Dongli Zhang @ 2026-07-24  9:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: dave, peterx, farosas, maciej.szmigiero, mark.kanda, bchaney

Currently the cpr-transfer source QEMU instance cannot be driven entirely
via HMP.  The source must use QMP in order to specify both the
main migration channel and the CPR channel.

Extend the HMP migrate command with an optional CPR channel URI. When the
migration mode is cpr-transfer, HMP uses this URI to build a
CPR MigrationChannel in addition to the main migration channel. The new
option is rejected unless the migration mode is cpr-transfer, so existing
HMP migrate usage is unchanged.

For example, source QEMU HMP commands can be something like below. The
"-c unix:/tmp/cpr.sock" is for CPR URI.

(qemu) migrate_set_parameter mode cpr-transfer
(qemu) migrate -c unix:/tmp/cpr.sock tcp:0:50002

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
v1->v2:
  - Use the '-c' option in the HMP command reference.
  - Use "a second uri can only be used in cpr-transfer mode" as error
    message.

 hmp-commands.hx                | 12 ++++++++----
 migration/migration-hmp-cmds.c | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 7ae2468a3d..7f43cf537f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -928,16 +928,17 @@ ERST
 
     {
         .name       = "migrate",
-        .args_type  = "detach:-d,resume:-r,uri:s",
-        .params     = "[-d] [-r] uri",
+        .args_type  = "detach:-d,resume:-r,uri-cpr:-cs,uri:s",
+        .params     = "[-d] [-r] [-c uri-cpr] uri",
         .help       = "migrate to URI (using -d to not wait for completion)"
-		      "\n\t\t\t -r to resume a paused postcopy migration",
+		      "\n\t\t\t -r to resume a paused postcopy migration"
+		      "\n\t\t\t -c to specify a CPR URI for cpr-transfer mode",
         .cmd        = hmp_migrate,
     },
 
 
 SRST
-``migrate [-d] [-r]`` *uri*
+``migrate [-d] [-r] [-c uri-cpr]`` *uri*
   Migrate the VM to *uri*.
 
   ``-d``
@@ -945,6 +946,9 @@ SRST
     query an ongoing migration process, use "info migrate".
   ``-r``
     Resume a paused postcopy migration.
+  ``-c`` *uri-cpr*
+    Specify the CPR URI for cpr-transfer mode. It must be a UNIX domain
+    socket.
 ERST
 
     {
diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index b04fc4489f..4ca2c962c2 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -837,9 +837,11 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
     bool detach = qdict_get_try_bool(qdict, "detach", false);
     bool resume = qdict_get_try_bool(qdict, "resume", false);
     const char *uri = qdict_get_str(qdict, "uri");
+    const char *uri_cpr = qdict_get_try_str(qdict, "uri-cpr");
     Error *err = NULL;
     g_autoptr(MigrationChannelList) caps = NULL;
     g_autoptr(MigrationChannel) channel = NULL;
+    g_autoptr(MigrationChannel) channel_cpr = NULL;
 
     if (!migrate_uri_parse(uri, &channel, &err)) {
         hmp_handle_error(mon, err);
@@ -847,6 +849,23 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
     }
     QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel));
 
+    if (uri_cpr) {
+        if (migrate_mode() != MIG_MODE_CPR_TRANSFER) {
+            error_setg(&err,
+                       "a second uri can only be used in cpr-transfer mode");
+            hmp_handle_error(mon, err);
+            return;
+        }
+
+        if (!migrate_uri_parse(uri_cpr, &channel_cpr, &err)) {
+            hmp_handle_error(mon, err);
+            return;
+        }
+
+        channel_cpr->channel_type = MIGRATION_CHANNEL_TYPE_CPR;
+        QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel_cpr));
+    }
+
     qmp_migrate(NULL, true, caps, true, resume, &err);
     if (hmp_handle_error(mon, err)) {
         return;
-- 
2.43.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] migration/cpr: Add HMP support for cpr-transfer
  2026-07-24  9:41 [PATCH v2 1/1] migration/cpr: Add HMP support for cpr-transfer Dongli Zhang
@ 2026-07-27  0:46 ` Dr. David Alan Gilbert
  2026-07-27 12:14   ` Maciej S. Szmigiero
  0 siblings, 1 reply; 4+ messages in thread
From: Dr. David Alan Gilbert @ 2026-07-27  0:46 UTC (permalink / raw)
  To: Dongli Zhang
  Cc: qemu-devel, peterx, farosas, maciej.szmigiero, mark.kanda,
	bchaney

* Dongli Zhang (dongli.zhang@oracle.com) wrote:
> Currently the cpr-transfer source QEMU instance cannot be driven entirely
> via HMP.  The source must use QMP in order to specify both the
> main migration channel and the CPR channel.
> 
> Extend the HMP migrate command with an optional CPR channel URI. When the
> migration mode is cpr-transfer, HMP uses this URI to build a
> CPR MigrationChannel in addition to the main migration channel. The new
> option is rejected unless the migration mode is cpr-transfer, so existing
> HMP migrate usage is unchanged.
> 
> For example, source QEMU HMP commands can be something like below. The
> "-c unix:/tmp/cpr.sock" is for CPR URI.
> 
> (qemu) migrate_set_parameter mode cpr-transfer
> (qemu) migrate -c unix:/tmp/cpr.sock tcp:0:50002
> 
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
> v1->v2:
>   - Use the '-c' option in the HMP command reference.
>   - Use "a second uri can only be used in cpr-transfer mode" as error
>     message.

Thanks for making those changes; minor note below.

>  hmp-commands.hx                | 12 ++++++++----
>  migration/migration-hmp-cmds.c | 19 +++++++++++++++++++
>  2 files changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 7ae2468a3d..7f43cf537f 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -928,16 +928,17 @@ ERST
>  
>      {
>          .name       = "migrate",
> -        .args_type  = "detach:-d,resume:-r,uri:s",
> -        .params     = "[-d] [-r] uri",
> +        .args_type  = "detach:-d,resume:-r,uri-cpr:-cs,uri:s",
> +        .params     = "[-d] [-r] [-c uri-cpr] uri",
>          .help       = "migrate to URI (using -d to not wait for completion)"
> -		      "\n\t\t\t -r to resume a paused postcopy migration",
> +		      "\n\t\t\t -r to resume a paused postcopy migration"
> +		      "\n\t\t\t -c to specify a CPR URI for cpr-transfer mode",
>          .cmd        = hmp_migrate,
>      },
>  
>  
>  SRST
> -``migrate [-d] [-r]`` *uri*
> +``migrate [-d] [-r] [-c uri-cpr]`` *uri*
>    Migrate the VM to *uri*.
>  
>    ``-d``
> @@ -945,6 +946,9 @@ SRST
>      query an ongoing migration process, use "info migrate".
>    ``-r``
>      Resume a paused postcopy migration.
> +  ``-c`` *uri-cpr*
> +    Specify the CPR URI for cpr-transfer mode. It must be a UNIX domain
> +    socket.
>  ERST
>  
>      {
> diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> index b04fc4489f..4ca2c962c2 100644
> --- a/migration/migration-hmp-cmds.c
> +++ b/migration/migration-hmp-cmds.c
> @@ -837,9 +837,11 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
>      bool detach = qdict_get_try_bool(qdict, "detach", false);
>      bool resume = qdict_get_try_bool(qdict, "resume", false);
>      const char *uri = qdict_get_str(qdict, "uri");
> +    const char *uri_cpr = qdict_get_try_str(qdict, "uri-cpr");
>      Error *err = NULL;
>      g_autoptr(MigrationChannelList) caps = NULL;
>      g_autoptr(MigrationChannel) channel = NULL;
> +    g_autoptr(MigrationChannel) channel_cpr = NULL;
>  
>      if (!migrate_uri_parse(uri, &channel, &err)) {
>          hmp_handle_error(mon, err);
> @@ -847,6 +849,23 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
>      }
>      QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel));
>  
> +    if (uri_cpr) {
> +        if (migrate_mode() != MIG_MODE_CPR_TRANSFER) {
> +            error_setg(&err,
> +                       "a second uri can only be used in cpr-transfer mode");

That should probably be changed to something like
  "-c can only be used in cpr-transfer mode"

but other than that,

Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
(Feel free to take it via cpr or migration).

Dave


> +            hmp_handle_error(mon, err);
> +            return;
> +        }
> +
> +        if (!migrate_uri_parse(uri_cpr, &channel_cpr, &err)) {
> +            hmp_handle_error(mon, err);
> +            return;
> +        }
> +
> +        channel_cpr->channel_type = MIGRATION_CHANNEL_TYPE_CPR;
> +        QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel_cpr));
> +    }
> +
>      qmp_migrate(NULL, true, caps, true, resume, &err);
>      if (hmp_handle_error(mon, err)) {
>          return;
> -- 
> 2.43.5
> 
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] migration/cpr: Add HMP support for cpr-transfer
  2026-07-27  0:46 ` Dr. David Alan Gilbert
@ 2026-07-27 12:14   ` Maciej S. Szmigiero
  2026-07-27 12:50     ` Peter Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Maciej S. Szmigiero @ 2026-07-27 12:14 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, Dongli Zhang
  Cc: qemu-devel, peterx, farosas, mark.kanda, bchaney

On 27.07.2026 02:46, Dr. David Alan Gilbert wrote:
> * Dongli Zhang (dongli.zhang@oracle.com) wrote:
>> Currently the cpr-transfer source QEMU instance cannot be driven entirely
>> via HMP.  The source must use QMP in order to specify both the
>> main migration channel and the CPR channel.
>>
>> Extend the HMP migrate command with an optional CPR channel URI. When the
>> migration mode is cpr-transfer, HMP uses this URI to build a
>> CPR MigrationChannel in addition to the main migration channel. The new
>> option is rejected unless the migration mode is cpr-transfer, so existing
>> HMP migrate usage is unchanged.
>>
>> For example, source QEMU HMP commands can be something like below. The
>> "-c unix:/tmp/cpr.sock" is for CPR URI.
>>
>> (qemu) migrate_set_parameter mode cpr-transfer
>> (qemu) migrate -c unix:/tmp/cpr.sock tcp:0:50002
>>
>> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
>> ---
>> v1->v2:
>>    - Use the '-c' option in the HMP command reference.
>>    - Use "a second uri can only be used in cpr-transfer mode" as error
>>      message.
> 
> Thanks for making those changes; minor note below.
> 
>>   hmp-commands.hx                | 12 ++++++++----
>>   migration/migration-hmp-cmds.c | 19 +++++++++++++++++++
>>   2 files changed, 27 insertions(+), 4 deletions(-)
>>
>> diff --git a/hmp-commands.hx b/hmp-commands.hx
>> index 7ae2468a3d..7f43cf537f 100644
>> --- a/hmp-commands.hx
>> +++ b/hmp-commands.hx
>> @@ -928,16 +928,17 @@ ERST
>>   
>>       {
>>           .name       = "migrate",
>> -        .args_type  = "detach:-d,resume:-r,uri:s",
>> -        .params     = "[-d] [-r] uri",
>> +        .args_type  = "detach:-d,resume:-r,uri-cpr:-cs,uri:s",
>> +        .params     = "[-d] [-r] [-c uri-cpr] uri",
>>           .help       = "migrate to URI (using -d to not wait for completion)"
>> -		      "\n\t\t\t -r to resume a paused postcopy migration",
>> +		      "\n\t\t\t -r to resume a paused postcopy migration"
>> +		      "\n\t\t\t -c to specify a CPR URI for cpr-transfer mode",
>>           .cmd        = hmp_migrate,
>>       },
>>   
>>   
>>   SRST
>> -``migrate [-d] [-r]`` *uri*
>> +``migrate [-d] [-r] [-c uri-cpr]`` *uri*
>>     Migrate the VM to *uri*.
>>   
>>     ``-d``
>> @@ -945,6 +946,9 @@ SRST
>>       query an ongoing migration process, use "info migrate".
>>     ``-r``
>>       Resume a paused postcopy migration.
>> +  ``-c`` *uri-cpr*
>> +    Specify the CPR URI for cpr-transfer mode. It must be a UNIX domain
>> +    socket.
>>   ERST
>>   
>>       {
>> diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
>> index b04fc4489f..4ca2c962c2 100644
>> --- a/migration/migration-hmp-cmds.c
>> +++ b/migration/migration-hmp-cmds.c
>> @@ -837,9 +837,11 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
>>       bool detach = qdict_get_try_bool(qdict, "detach", false);
>>       bool resume = qdict_get_try_bool(qdict, "resume", false);
>>       const char *uri = qdict_get_str(qdict, "uri");
>> +    const char *uri_cpr = qdict_get_try_str(qdict, "uri-cpr");
>>       Error *err = NULL;
>>       g_autoptr(MigrationChannelList) caps = NULL;
>>       g_autoptr(MigrationChannel) channel = NULL;
>> +    g_autoptr(MigrationChannel) channel_cpr = NULL;
>>   
>>       if (!migrate_uri_parse(uri, &channel, &err)) {
>>           hmp_handle_error(mon, err);
>> @@ -847,6 +849,23 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
>>       }
>>       QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel));
>>   
>> +    if (uri_cpr) {
>> +        if (migrate_mode() != MIG_MODE_CPR_TRANSFER) {
>> +            error_setg(&err,
>> +                       "a second uri can only be used in cpr-transfer mode");
> 
> That should probably be changed to something like
>    "-c can only be used in cpr-transfer mode"
> 
> but other than that,
> 
> Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
> (Feel free to take it via cpr or migration).

Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com> # for CPR

I am fine with this going in through migration tree if that's not
a problem since there's currently nothing else for CPR.
> Dave

Thanks,
Maciej



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] migration/cpr: Add HMP support for cpr-transfer
  2026-07-27 12:14   ` Maciej S. Szmigiero
@ 2026-07-27 12:50     ` Peter Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Xu @ 2026-07-27 12:50 UTC (permalink / raw)
  To: Maciej S. Szmigiero
  Cc: Dr. David Alan Gilbert, Dongli Zhang, qemu-devel, farosas,
	mark.kanda, bchaney

On Mon, Jul 27, 2026 at 02:14:27PM +0200, Maciej S. Szmigiero wrote:
> On 27.07.2026 02:46, Dr. David Alan Gilbert wrote:
> > * Dongli Zhang (dongli.zhang@oracle.com) wrote:
> > > Currently the cpr-transfer source QEMU instance cannot be driven entirely
> > > via HMP.  The source must use QMP in order to specify both the
> > > main migration channel and the CPR channel.
> > > 
> > > Extend the HMP migrate command with an optional CPR channel URI. When the
> > > migration mode is cpr-transfer, HMP uses this URI to build a
> > > CPR MigrationChannel in addition to the main migration channel. The new
> > > option is rejected unless the migration mode is cpr-transfer, so existing
> > > HMP migrate usage is unchanged.
> > > 
> > > For example, source QEMU HMP commands can be something like below. The
> > > "-c unix:/tmp/cpr.sock" is for CPR URI.
> > > 
> > > (qemu) migrate_set_parameter mode cpr-transfer
> > > (qemu) migrate -c unix:/tmp/cpr.sock tcp:0:50002
> > > 
> > > Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> > > ---
> > > v1->v2:
> > >    - Use the '-c' option in the HMP command reference.
> > >    - Use "a second uri can only be used in cpr-transfer mode" as error
> > >      message.
> > 
> > Thanks for making those changes; minor note below.
> > 
> > >   hmp-commands.hx                | 12 ++++++++----
> > >   migration/migration-hmp-cmds.c | 19 +++++++++++++++++++
> > >   2 files changed, 27 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/hmp-commands.hx b/hmp-commands.hx
> > > index 7ae2468a3d..7f43cf537f 100644
> > > --- a/hmp-commands.hx
> > > +++ b/hmp-commands.hx
> > > @@ -928,16 +928,17 @@ ERST
> > >       {
> > >           .name       = "migrate",
> > > -        .args_type  = "detach:-d,resume:-r,uri:s",
> > > -        .params     = "[-d] [-r] uri",
> > > +        .args_type  = "detach:-d,resume:-r,uri-cpr:-cs,uri:s",
> > > +        .params     = "[-d] [-r] [-c uri-cpr] uri",
> > >           .help       = "migrate to URI (using -d to not wait for completion)"
> > > -		      "\n\t\t\t -r to resume a paused postcopy migration",
> > > +		      "\n\t\t\t -r to resume a paused postcopy migration"
> > > +		      "\n\t\t\t -c to specify a CPR URI for cpr-transfer mode",
> > >           .cmd        = hmp_migrate,
> > >       },
> > >   SRST
> > > -``migrate [-d] [-r]`` *uri*
> > > +``migrate [-d] [-r] [-c uri-cpr]`` *uri*
> > >     Migrate the VM to *uri*.
> > >     ``-d``
> > > @@ -945,6 +946,9 @@ SRST
> > >       query an ongoing migration process, use "info migrate".
> > >     ``-r``
> > >       Resume a paused postcopy migration.
> > > +  ``-c`` *uri-cpr*
> > > +    Specify the CPR URI for cpr-transfer mode. It must be a UNIX domain
> > > +    socket.
> > >   ERST
> > >       {
> > > diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> > > index b04fc4489f..4ca2c962c2 100644
> > > --- a/migration/migration-hmp-cmds.c
> > > +++ b/migration/migration-hmp-cmds.c
> > > @@ -837,9 +837,11 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
> > >       bool detach = qdict_get_try_bool(qdict, "detach", false);
> > >       bool resume = qdict_get_try_bool(qdict, "resume", false);
> > >       const char *uri = qdict_get_str(qdict, "uri");
> > > +    const char *uri_cpr = qdict_get_try_str(qdict, "uri-cpr");
> > >       Error *err = NULL;
> > >       g_autoptr(MigrationChannelList) caps = NULL;
> > >       g_autoptr(MigrationChannel) channel = NULL;
> > > +    g_autoptr(MigrationChannel) channel_cpr = NULL;
> > >       if (!migrate_uri_parse(uri, &channel, &err)) {
> > >           hmp_handle_error(mon, err);
> > > @@ -847,6 +849,23 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
> > >       }
> > >       QAPI_LIST_PREPEND(caps, g_steal_pointer(&channel));
> > > +    if (uri_cpr) {
> > > +        if (migrate_mode() != MIG_MODE_CPR_TRANSFER) {
> > > +            error_setg(&err,
> > > +                       "a second uri can only be used in cpr-transfer mode");
> > 
> > That should probably be changed to something like
> >    "-c can only be used in cpr-transfer mode"
> > 
> > but other than that,
> > 
> > Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
> > (Feel free to take it via cpr or migration).
> 
> Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com> # for CPR
> 
> I am fine with this going in through migration tree if that's not
> a problem since there's currently nothing else for CPR.

Yep I'll pick this up for 11.2, thanks all.

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-27 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24  9:41 [PATCH v2 1/1] migration/cpr: Add HMP support for cpr-transfer Dongli Zhang
2026-07-27  0:46 ` Dr. David Alan Gilbert
2026-07-27 12:14   ` Maciej S. Szmigiero
2026-07-27 12:50     ` Peter Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.