From: Steven Sistare <steven.sistare@oracle.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, Fabiano Rosas <farosas@suse.de>,
David Hildenbrand <david@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Eduardo Habkost <eduardo@habkost.net>,
Philippe Mathieu-Daude <philmd@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH V4 19/19] migration: cpr-transfer documentation
Date: Thu, 19 Dec 2024 17:35:18 -0500 [thread overview]
Message-ID: <c94ed602-76a8-497f-a64d-16f49e067f9f@oracle.com> (raw)
In-Reply-To: <Z2RRvnsYZ7t3f8-b@x1n>
On 12/19/2024 12:02 PM, Peter Xu wrote:
> On Mon, Dec 02, 2024 at 05:20:11AM -0800, Steve Sistare wrote:
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>
> I think this one is already good enough, so:
>
> Reviewed-by: Peter Xu <peterx@redhat.com>
>
> But still, a few comments inline.
>
>> ---
>> docs/devel/migration/CPR.rst | 176 ++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 174 insertions(+), 2 deletions(-)
>>
>> diff --git a/docs/devel/migration/CPR.rst b/docs/devel/migration/CPR.rst
>> index 63c3647..a8a57c0 100644
>> --- a/docs/devel/migration/CPR.rst
>> +++ b/docs/devel/migration/CPR.rst
>> @@ -5,7 +5,7 @@ CPR is the umbrella name for a set of migration modes in which the
>> VM is migrated to a new QEMU instance on the same host. It is
>> intended for use when the goal is to update host software components
>> that run the VM, such as QEMU or even the host kernel. At this time,
>> -cpr-reboot is the only available mode.
>> +the cpr-reboot and cpr-transfer modes are available.
>>
>> Because QEMU is restarted on the same host, with access to the same
>> local devices, CPR is allowed in certain cases where normal migration
>> @@ -53,7 +53,7 @@ RAM is copied to the migration URI.
>> Outgoing:
>> * Set the migration mode parameter to ``cpr-reboot``.
>> * Set the ``x-ignore-shared`` capability if desired.
>> - * Issue the ``migrate`` command. It is recommended the the URI be a
>> + * Issue the ``migrate`` command. It is recommended the URI be a
>> ``file`` type, but one can use other types such as ``exec``,
>> provided the command captures all the data from the outgoing side,
>> and provides all the data to the incoming side.
>> @@ -145,3 +145,175 @@ Caveats
>>
>> cpr-reboot mode may not be used with postcopy, background-snapshot,
>> or COLO.
>> +
>> +cpr-transfer mode
>> +-----------------
>> +
>> +This mode allows the user to transfer a guest to a new QEMU instance
>> +on the same host with minimal guest pause time, by preserving guest
>> +RAM in place, albeit with new virtual addresses in new QEMU.
>
> IMHO it's important to have some words discussing the diff
> v.s. ignore-shared, because from above it's undistinguishable from it.
>
> The important bit could be that cpr-transfer allows pinning. If that's too
> internal a concept, we could mention "unlike an ignore-shared migration,
> cpr-transfer will start to enable local migrations to work seamlessly with
> all kinds of device assignments like VFIO, vDPA and so on".
OK, I'll add something like that.
>> +
>> +The user starts new QEMU on the same host as old QEMU, with the
>> +same arguments as old QEMU, plus the ``-incoming option``. The user
>> +issues the migrate command to old QEMU, which stops the VM, saves
>> +state to the migration channels, and enters the postmigrate state.
>> +Execution resumes in new QEMU.
>> +
>> +This mode requires a second migration channel type "cpr" in the
>> +channel arguments on the outgoing side. The channel must be a type,
>> +such as unix socket, that supports SCM_RIGHTS. However, the cpr
>> +channel cannot be added to the list of channels for a migrate-incoming
>> +command, because it must be read before new QEMU opens a monitor.
>> +Instead, the user passes the channel as a second -incoming
>> +command-line argument to new QEMU using JSON syntax.
>> +
>> +Usage
>> +^^^^^
>> +
>> +Memory backend objects must have the ``share=on`` attribute.
>> +
>> +The VM must be started with the ``-machine aux-ram-share=on``
>> +option. This causes implicit RAM blocks (those not described by
>> +a memory-backend object) to be allocated by mmap'ing a memfd.
>> +Examples include VGA and ROM.
>> +
>> +Outgoing:
>> + * Set the migration mode parameter to ``cpr-transfer``.
>> + * Issue the ``migrate`` command, containing a main channel and
>> + a cpr channel.
>> +
>> +Incoming:
>> + * Start new QEMU with two ``-incoming`` options.
>> + * If the VM was running when the outgoing ``migrate`` command was
>> + issued, then QEMU automatically resumes VM execution.
>> +
>> +Caveats
>> +^^^^^^^
>> +
>> +cpr-transfer mode may not be used with postcopy, background-snapshot,
>> +or COLO.
>
> Maybe we can even remove this line. It's not like someone could think
> about supporting any of above; they just don't apply in cpr context.
The same caveat is listed for cpr-reboot mode. We should either delete both
or keep both. But IMO many aspects of migration are confusing for beginners,
and more detail rather than less would be helpful.
- Steve
>> +
>> +memory-backend-epc is not supported.
>> +
>> +The main incoming migration channel cannot be a file type.
>> +
>> +If the main incoming migration channel is a tcp type, then the port
>> +cannot be 0 (meaning dynamically choose a port).
>> +
>> +When using ``-incoming defer``, you must issue the migrate command to
>> +old QEMU before issuing any monitor commands to new QEMU, because new
>> +QEMU blocks waiting to read from the cpr channel before starting its
>> +monitor, and old QEMU does not write to the channel until the migrate
>> +command is issued. However, new QEMU does not open and read the
>> +main migration channel until you issue the migrate incoming command.
>> +
>> +Example 1: incoming channel
>> +^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> +
>> +In these examples, we simply restart the same version of QEMU, but
>> +in a real scenario one would start new QEMU on the incoming side.
>> +Note that new QEMU does not print the monitor prompt until old QEMU
>> +has issued the migrate command. The outgoing side uses QMP because
>> +HMP cannot specify a CPR channel. Some QMP responses are omitted for
>> +brevity.
>> +
>> +::
>> +
>> + Outgoing: Incoming:
>> +
>> + # qemu-kvm -qmp stdio
>> + -object memory-backend-file,id=ram0,size=4G,
>> + mem-path=/dev/shm/ram0,share=on -m 4G
>> + -machine aux-ram-share=on
>> + ...
>> + # qemu-kvm -monitor stdio
>> + -incoming tcp:0:44444
>> + -incoming '{"channel-type": "cpr",
>> + "addr": { "transport": "socket",
>> + "type": "unix", "path": "cpr.sock"}}'
>> + ...
>> + {"execute":"qmp_capabilities"}
>> +
>> + {"execute": "query-status"}
>> + {"return": {"status": "running",
>> + "running": true}}
>> +
>> + {"execute":"migrate-set-parameters",
>> + "arguments":{"mode":"cpr-transfer"}}
>> +
>> + {"execute": "migrate", "arguments": { "channels": [
>> + {"channel-type": "main",
>> + "addr": { "transport": "socket", "type": "inet",
>> + "host": "0", "port": "44444" }},
>> + {"channel-type": "cpr",
>> + "addr": { "transport": "socket", "type": "unix",
>> + "path": "cpr.sock" }}]}}
>> +
>> + QEMU 10.0.50 monitor
>> + (qemu) info status
>> + VM status: running
>> +
>> + {"execute": "query-status"}
>> + {"return": {"status": "postmigrate",
>> + "running": false}}
>> +
>> +Example 2: incoming defer
>> +^^^^^^^^^^^^^^^^^^^^^^^^^
>> +
>> +This example uses ``-incoming defer`` to hot plug a device before
>> +accepting the main migration channel. Again note you must issue the
>> +migrate command to old QEMU before you can issue any monitor
>> +commands to new QEMU.
>> +
>> +
>> +::
>> +
>> + Outgoing: Incoming:
>> +
>> + # qemu-kvm -monitor stdio
>> + -object memory-backend-file,id=ram0,size=4G,
>> + mem-path=/dev/shm/ram0,share=on -m 4G
>> + -machine aux-ram-share=on
>> + ...
>> + # qemu-kvm -monitor stdio
>> + -incoming defer
>> + -incoming '{"channel-type": "cpr",
>> + "addr": { "transport": "socket",
>> + "type": "unix", "path": "cpr.sock"}}'
>> + ...
>> + {"execute":"qmp_capabilities"}
>> +
>> + {"execute": "device_add",
>> + "arguments": {"driver": "pcie-root-port"}}
>> +
>> + {"execute":"migrate-set-parameters",
>> + "arguments":{"mode":"cpr-transfer"}}
>> +
>> + {"execute": "migrate", "arguments": { "channels": [
>> + {"channel-type": "main",
>> + "addr": { "transport": "socket", "type": "inet",
>> + "host": "0", "port": "44444" }},
>> + {"channel-type": "cpr",
>> + "addr": { "transport": "socket", "type": "unix",
>> + "path": "cpr.sock" }}]}}
>> +
>> + QEMU 10.0.50 monitor
>> + (qemu) info status
>> + VM status: paused (inmigrate)
>> + (qemu) device_add pcie-root-port
>> + (qemu) migrate_incoming tcp:0:44444
>> + (qemu) info status
>> + VM status: running
>> +
>> + {"execute": "query-status"}
>> + {"return": {"status": "postmigrate",
>> + "running": false}}
>> +
>> +Futures
>> +^^^^^^^
>> +
>> +cpr-transfer mode is based on a capability to transfer open file
>> +descriptors from old to new QEMU. In the future, descriptors for
>> +vfio, iommufd, vhost, and char devices could be transferred,
>> +preserving those devices and their kernel state without interruption,
>> +even if they do not explicitly support live migration.
>> --
>> 1.8.3.1
>>
>
prev parent reply other threads:[~2024-12-19 22:36 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 13:19 [PATCH V4 00/19] Live update: cpr-transfer Steve Sistare
2024-12-02 13:19 ` [PATCH V4 01/19] backends/hostmem-shm: factor out allocation of "anonymous shared memory with an fd" Steve Sistare
2024-12-09 17:36 ` Peter Xu
2024-12-12 20:37 ` Steven Sistare
2024-12-02 13:19 ` [PATCH V4 02/19] physmem: fd-based shared memory Steve Sistare
2024-12-09 19:42 ` Peter Xu
2024-12-12 20:38 ` Steven Sistare
2024-12-12 21:22 ` Peter Xu
2024-12-13 16:41 ` Steven Sistare
2024-12-13 17:05 ` Steven Sistare
2024-12-16 18:19 ` Peter Xu
2024-12-17 21:54 ` Steven Sistare
2024-12-17 22:46 ` Peter Xu
2024-12-18 16:34 ` Steven Sistare
2024-12-02 13:19 ` [PATCH V4 03/19] memory: add RAM_PRIVATE Steve Sistare
2024-12-09 19:45 ` Peter Xu
2024-12-02 13:19 ` [PATCH V4 04/19] machine: aux-ram-share option Steve Sistare
2024-12-05 8:25 ` Markus Armbruster
2024-12-05 14:24 ` Steven Sistare
2024-12-05 12:08 ` Markus Armbruster
2024-12-05 12:19 ` Markus Armbruster
2024-12-05 14:24 ` Steven Sistare
2024-12-09 19:54 ` Peter Xu
2024-12-12 20:38 ` Steven Sistare
2024-12-12 21:22 ` Peter Xu
2024-12-02 13:19 ` [PATCH V4 05/19] migration: cpr-state Steve Sistare
2024-12-02 13:19 ` [PATCH V4 06/19] physmem: preserve ram blocks for cpr Steve Sistare
2024-12-09 20:07 ` Peter Xu
2024-12-12 20:38 ` Steven Sistare
2024-12-12 22:48 ` Peter Xu
2024-12-13 15:21 ` Peter Xu
2024-12-13 15:30 ` Steven Sistare
2024-12-18 16:34 ` Steven Sistare
2024-12-18 17:00 ` Peter Xu
2024-12-18 20:22 ` Steven Sistare
2024-12-18 20:33 ` Peter Xu
2024-12-02 13:19 ` [PATCH V4 07/19] hostmem-memfd: preserve " Steve Sistare
2024-12-18 19:53 ` Steven Sistare
2024-12-18 20:23 ` Peter Xu
2024-12-02 13:20 ` [PATCH V4 08/19] hostmem-shm: " Steve Sistare
2024-12-12 17:38 ` Peter Xu
2024-12-02 13:20 ` [PATCH V4 09/19] migration: incoming channel Steve Sistare
2024-12-05 15:23 ` Markus Armbruster
2024-12-05 20:45 ` Steven Sistare
2024-12-09 12:12 ` Markus Armbruster
2024-12-09 16:36 ` Peter Xu
2024-12-11 9:18 ` Markus Armbruster
2024-12-11 18:58 ` Steven Sistare
2024-12-10 12:46 ` Markus Armbruster
2024-12-02 13:20 ` [PATCH V4 10/19] migration: cpr channel Steve Sistare
2024-12-05 15:37 ` Markus Armbruster
2024-12-05 20:46 ` Steven Sistare
2024-12-06 9:31 ` Markus Armbruster
2024-12-18 19:53 ` Steven Sistare
2024-12-18 20:27 ` Peter Xu
2024-12-18 20:31 ` Steven Sistare
2024-12-02 13:20 ` [PATCH V4 11/19] migration: SCM_RIGHTS for QEMUFile Steve Sistare
2024-12-02 13:20 ` [PATCH V4 12/19] migration: VMSTATE_FD Steve Sistare
2024-12-02 13:20 ` [PATCH V4 13/19] migration: cpr-transfer save and load Steve Sistare
2024-12-02 13:20 ` [PATCH V4 14/19] migration: cpr-transfer mode Steve Sistare
2024-12-04 16:10 ` Steven Sistare
2024-12-10 12:26 ` Markus Armbruster
2024-12-11 22:05 ` Steven Sistare
2024-12-02 13:20 ` [PATCH V4 15/19] tests/migration-test: memory_backend Steve Sistare
2024-12-02 13:20 ` [PATCH V4 16/19] tests/qtest: defer connection Steve Sistare
2024-12-18 21:02 ` Steven Sistare
2024-12-19 15:46 ` Peter Xu
2024-12-19 22:33 ` Steven Sistare
2024-12-02 13:20 ` [PATCH V4 17/19] tests/migration-test: " Steve Sistare
2024-12-02 13:20 ` [PATCH V4 18/19] migration-test: cpr-transfer Steve Sistare
2024-12-18 21:03 ` Steven Sistare
2024-12-19 16:56 ` Peter Xu
2024-12-19 22:34 ` Steven Sistare
2024-12-20 15:41 ` Peter Xu
2024-12-02 13:20 ` [PATCH V4 19/19] migration: cpr-transfer documentation Steve Sistare
2024-12-18 21:03 ` Steven Sistare
2024-12-19 17:02 ` Peter Xu
2024-12-19 22:35 ` Steven Sistare [this message]
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=c94ed602-76a8-497f-a64d-16f49e067f9f@oracle.com \
--to=steven.sistare@oracle.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=david@redhat.com \
--cc=eduardo@habkost.net \
--cc=farosas@suse.de \
--cc=marcel.apfelbaum@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).