qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V5 00/19] Live update: cpr-exec
@ 2025-10-01 15:33 Steve Sistare
  2025-10-01 15:33 ` [PATCH V5 01/19] migration: multi-mode notifier Steve Sistare
                   ` (19 more replies)
  0 siblings, 20 replies; 34+ messages in thread
From: Steve Sistare @ 2025-10-01 15:33 UTC (permalink / raw)
  To: qemu-devel
  Cc: Fabiano Rosas, Peter Xu, Markus Armbruster, Paolo Bonzini,
	Eric Blake, Dr. David Alan Gilbert, Cedric Le Goater,
	Alex Williamson, Steve Sistare

This patch series adds the live migration cpr-exec mode.

The new user-visible interfaces are:
  * cpr-exec (MigMode migration parameter)
  * cpr-exec-command (migration parameter)

cpr-exec mode is similar in most respects to cpr-transfer mode, with the
primary difference being that old QEMU directly exec's new QEMU.  The user
specifies the command to exec new QEMU in the migration parameter
cpr-exec-command.

Why?

In a containerized QEMU environment, cpr-exec reuses an existing QEMU
container and its assigned resources.  By contrast, cpr-transfer mode
requires a new container to be created on the same host as the target of
the CPR operation.  Resources must be reserved for the new container, while
the old container still reserves resources until the operation completes.
Avoiding over commitment requires extra work in the management layer.
This is one reason why a cloud provider may prefer cpr-exec.  A second reason
is that the container may include agents with their own connections to the
outside world, and such connections remain intact if the container is reused.

How?

cpr-exec preserves descriptors across exec by clearing the CLOEXEC flag,
and by sending the unique name and value of each descriptor to new QEMU
via CPR state.

CPR state cannot be sent over the normal migration channel, because devices
and backends are created prior to reading the channel, so this mode sends
CPR state over a second migration channel that is not visible to the user.
New QEMU reads the second channel prior to creating devices or backends.

The exec itself is trivial.  After writing to the migration channels, the
migration code calls a new main-loop hook to perform the exec.

Example:

In this example, we simply restart the same version of QEMU, but in
a real scenario one would use a new QEMU binary path in cpr-exec-command.

  # qemu-kvm -monitor stdio
  -object memory-backend-memfd,id=ram0,size=1G
  -machine memory-backend=ram0 -machine aux-ram-share=on ...

  QEMU 10.1.50 monitor - type 'help' for more information
  (qemu) info status
  VM status: running
  (qemu) migrate_set_parameter mode cpr-exec
  (qemu) migrate_set_parameter cpr-exec-command qemu-kvm ... -incoming file:vm.state
  (qemu) migrate -d file:vm.state

  (qemu) QEMU 10.1.50 monitor - type 'help' for more information
  (qemu) info status
  VM status: running

Changes in V5:
  * included error-report.h, and used qemu_memfd_create to fix windows build
  * documented cpr-exec environment variable in CPR.rst
  * fixed err leak
  * defined cpr_exec_unpreserve_fds helper
  * misc cosmetic changes in cpr-exec.c
  * added patches from the series "migration-test: test cpr-exec", with
    comments addressed:
    - renamed qts parameter
    - fixed migrate_args bug
    - added code comments
    - re-privatized QEMU_ENV_DST
    - added RB's

Steve Sistare (19):
  migration: multi-mode notifier
  migration: add cpr_walk_fd
  oslib: qemu_clear_cloexec
  migration: cpr-exec-command parameter
  migration: cpr-exec save and load
  migration: cpr-exec mode
  migration: cpr-exec docs
  vfio: cpr-exec mode
  tests/qtest: export qtest_qemu_binary
  tests/qtest: qtest_qemu_args
  tests/qtest: qtest_create_test_state
  tests/qtest: qtest_qemu_spawn_func
  tests/qtest: qtest_init_after_exec
  migration-test: only_source option
  migration-test: shm path accessor
  migration-test: misc exports
  migration-test: migrate_args
  migration-test: strv parameter
  migration-test: test cpr-exec

 docs/devel/migration/CPR.rst          | 112 +++++++++++++++++++-
 qapi/migration.json                   |  46 ++++++++-
 include/migration/cpr.h               |  10 ++
 include/migration/misc.h              |  12 +++
 include/qemu/osdep.h                  |   9 ++
 tests/qtest/libqtest.h                |  25 +++++
 tests/qtest/migration/bootfile.h      |   1 +
 tests/qtest/migration/framework.h     |   5 +
 tests/qtest/migration/migration-qmp.h |   2 +
 hw/vfio/container.c                   |   3 +-
 hw/vfio/cpr-iommufd.c                 |   3 +-
 hw/vfio/cpr-legacy.c                  |   9 +-
 hw/vfio/cpr.c                         |  13 +--
 migration/cpr-exec.c                  | 188 ++++++++++++++++++++++++++++++++++
 migration/cpr.c                       |  36 ++++++-
 migration/migration-hmp-cmds.c        |  30 ++++++
 migration/migration.c                 |  70 ++++++++++---
 migration/options.c                   |  14 +++
 migration/ram.c                       |   1 +
 migration/vmstate-types.c             |   8 ++
 system/vl.c                           |   4 +-
 tests/qtest/libqtest.c                | 108 +++++++++++++------
 tests/qtest/migration/bootfile.c      |   5 +
 tests/qtest/migration/cpr-tests.c     | 133 ++++++++++++++++++++++++
 tests/qtest/migration/framework.c     | 101 ++++++++++++------
 tests/qtest/migration/migration-qmp.c |  16 +++
 util/oslib-posix.c                    |   9 ++
 util/oslib-win32.c                    |   4 +
 hmp-commands.hx                       |   2 +-
 migration/meson.build                 |   1 +
 migration/trace-events                |   1 +
 31 files changed, 879 insertions(+), 102 deletions(-)
 create mode 100644 migration/cpr-exec.c

-- 
1.8.3.1



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

end of thread, other threads:[~2025-10-03 13:38 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-01 15:33 [PATCH V5 00/19] Live update: cpr-exec Steve Sistare
2025-10-01 15:33 ` [PATCH V5 01/19] migration: multi-mode notifier Steve Sistare
2025-10-01 15:33 ` [PATCH V5 02/19] migration: add cpr_walk_fd Steve Sistare
2025-10-01 15:33 ` [PATCH V5 03/19] oslib: qemu_clear_cloexec Steve Sistare
2025-10-01 15:33 ` [PATCH V5 04/19] migration: cpr-exec-command parameter Steve Sistare
2025-10-01 15:33 ` [PATCH V5 05/19] migration: cpr-exec save and load Steve Sistare
2025-10-01 16:36   ` Peter Xu
2025-10-01 15:33 ` [PATCH V5 06/19] migration: cpr-exec mode Steve Sistare
2025-10-01 15:33 ` [PATCH V5 07/19] migration: cpr-exec docs Steve Sistare
2025-10-01 15:34 ` [PATCH V5 08/19] vfio: cpr-exec mode Steve Sistare
2025-10-01 15:34 ` [PATCH V5 09/19] tests/qtest: export qtest_qemu_binary Steve Sistare
2025-10-01 15:34 ` [PATCH V5 10/19] tests/qtest: qtest_qemu_args Steve Sistare
2025-10-01 15:34 ` [PATCH V5 11/19] tests/qtest: qtest_create_test_state Steve Sistare
2025-10-01 15:34 ` [PATCH V5 12/19] tests/qtest: qtest_qemu_spawn_func Steve Sistare
2025-10-01 15:34 ` [PATCH V5 13/19] tests/qtest: qtest_init_after_exec Steve Sistare
2025-10-01 15:34 ` [PATCH V5 14/19] migration-test: only_source option Steve Sistare
2025-10-01 15:34 ` [PATCH V5 15/19] migration-test: shm path accessor Steve Sistare
2025-10-01 15:34 ` [PATCH V5 16/19] migration-test: misc exports Steve Sistare
2025-10-01 15:34 ` [PATCH V5 17/19] migration-test: migrate_args Steve Sistare
2025-10-01 15:34 ` [PATCH V5 18/19] migration-test: strv parameter Steve Sistare
2025-10-01 15:34 ` [PATCH V5 19/19] migration-test: test cpr-exec Steve Sistare
2025-10-01 18:56 ` [PATCH V5 00/19] Live update: cpr-exec Peter Xu
2025-10-01 19:07   ` Steven Sistare
2025-10-01 19:24     ` Steven Sistare
2025-10-01 20:05       ` Peter Xu
2025-10-02 12:44         ` Steven Sistare
2025-10-02  8:48       ` Cédric Le Goater
2025-10-01 20:03     ` Peter Xu
2025-10-02  8:50       ` Cédric Le Goater
2025-10-02 13:45         ` Steven Sistare
2025-10-02 13:44       ` Steven Sistare
2025-10-03 11:36         ` Steven Sistare
2025-10-03 13:11           ` Peter Xu
2025-10-03 13:36             ` Steven Sistare

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).