All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dave@treblig.org>
To: Dongli Zhang <dongli.zhang@oracle.com>
Cc: qemu-devel@nongnu.org, peterx@redhat.com, farosas@suse.de,
	maciej.szmigiero@oracle.com, mark.kanda@oracle.com,
	bchaney@akamai.com
Subject: Re: [PATCH 1/1] migration/cpr: Add HMP support for cpr-transfer
Date: Tue, 23 Jun 2026 12:24:57 +0000	[thread overview]
Message-ID: <ajp7GduDZGjei3Gz@gallifrey> (raw)
In-Reply-To: <20260621072646.517545-1-dongli.zhang@oracle.com>

* 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
> argument 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
> "unix:/tmp/cpr.sock" is for CPR URI.
> 
> (qemu) migrate_set_parameter mode cpr-transfer
> (qemu) migrate tcp:0:50002 unix:/tmp/cpr.sock
> 
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>

Yeh this looks OK to me; I don't see a check for if you do:
(qemu) migrate_set_parameter mode cpr-transfer
(qemu) migrate tcp:0:50002

Does that get caught by the qmp_migrate or should you add a check here?

I do have a slight preference for using flag optional parameters rather 
than positional, e.g.

   migrate -c unix:/tmp/cpr.sock tcp:0:50002

but I wouldn't insist on it.

Dave


> ---
>  hmp-commands.hx                | 11 +++++++----
>  migration/migration-hmp-cmds.c | 18 ++++++++++++++++++
>  2 files changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 7ae2468a3d..021e51b142 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:s,uri-cpr:s?",
> +        .params     = "[-d] [-r] uri [uri-cpr]",
>          .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 uri-cpr specifies CPR URI for cpr-transfer mode",
>          .cmd        = hmp_migrate,
>      },
>  
>  
>  SRST
> -``migrate [-d] [-r]`` *uri*
> +``migrate [-d] [-r]`` *uri* [*uri-cpr*]
>    Migrate the VM to *uri*.
>  
>    ``-d``
> @@ -945,6 +946,8 @@ SRST
>      query an ongoing migration process, use "info migrate".
>    ``-r``
>      Resume a paused postcopy migration.
> +  ``uri-cpr``
> +    Specify 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 8b385f560e..42ca652bb3 100644
> --- a/migration/migration-hmp-cmds.c
> +++ b/migration/migration-hmp-cmds.c
> @@ -836,9 +836,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);
> @@ -846,6 +848,22 @@ 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, "uri-cpr requires 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.7
> 
-- 
 -----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   |_______/


  reply	other threads:[~2026-06-23 12:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-21  7:26 [PATCH 1/1] migration/cpr: Add HMP support for cpr-transfer Dongli Zhang
2026-06-23 12:24 ` Dr. David Alan Gilbert [this message]
2026-06-23 13:03   ` Peter Xu
2026-06-24 15:26 ` Fabiano Rosas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ajp7GduDZGjei3Gz@gallifrey \
    --to=dave@treblig.org \
    --cc=bchaney@akamai.com \
    --cc=dongli.zhang@oracle.com \
    --cc=farosas@suse.de \
    --cc=maciej.szmigiero@oracle.com \
    --cc=mark.kanda@oracle.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.