qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V1 00/26] Live update: vfio and iommufd
@ 2025-01-29 14:42 Steve Sistare
  2025-01-29 14:42 ` [PATCH V1 01/26] migration: cpr helpers Steve Sistare
                   ` (25 more replies)
  0 siblings, 26 replies; 64+ messages in thread
From: Steve Sistare @ 2025-01-29 14:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alex Williamson, Cedric Le Goater, Yi Liu, Eric Auger,
	Zhenzhong Duan, Michael S. Tsirkin, Marcel Apfelbaum, Peter Xu,
	Fabiano Rosas, Steve Sistare

Support vfio and iommufd devices with the cpr-transfer live migration mode.
Devices that do not support live migration can still support cpr-transfer,
allowing live update to a new version of QEMU on the same host, with no loss
of guest connectivity.

No user-visible interfaces are added.

For legacy containers:

Pass vfio device descriptors to new QEMU.  In new QEMU, during vfio_realize,
skip the ioctls that configure the device, because it is already configured.

Use VFIO_DMA_UNMAP_FLAG_VADDR to abandon the old VA's for DMA mapped
regions, and use VFIO_DMA_MAP_FLAG_VADDR to register the new VA in new
QEMU and update the locked memory accounting.  The physical pages remain
pinned, because the descriptor of the device that locked them remains open,
so DMA to those pages continues without interruption.  Mediated devices are
not supported, however, because they require the VA to always be valid, and
there is a brief window where no VA is registered.

Save the MSI message area as part of vfio-pci vmstate, and pass the interrupt
and notifier eventfd's to new QEMU.  New QEMU loads the MSI data, then the
vfio-pci post_load handler finds the eventfds in CPR state, rebuilds vector
data structures, and attaches the interrupts to the new KVM instance.  This
logic also applies to iommufd containers.

For iommufd containers:

Use IOMMU_IOAS_MAP_FILE to register memory regions for DMA when they are
backed by a file (including a memfd), so DMA mappings do not depend on VA,
which can differ after live update.  This allows mediated devices to be
supported.

Pass the iommufd and vfio device descriptors from old to new QEMU.  In new
QEMU, during vfio_realize, skip the ioctls that configure the device, because
it is already configured.

In new QEMU, call ioctl(IOMMU_IOAS_CHANGE_PROCESS) to update mm ownership and
locked memory accounting.

Patches 3 to 7 are specific to legacy containers.
Patches 15 to 26 are specific to iommufd containers.
Patches 1, 2 and 8 to 14 apply to both.

Changes from previous versions:
  * This series contains minor changes from the "Live update: vfio" and
    "Live update: iommufd" series, mainly bug fixes and refactored patches.

Steve Sistare (26):
  migration: cpr helpers
  migration: lower handler priority
  vfio: vfio_find_ram_discard_listener
  vfio/container: register container for cpr
  vfio/container: preserve descriptors
  vfio/container: preserve DMA mappings
  vfio/container: recover from unmap-all-vaddr failure
  pci: skip reset during cpr
  pci: export msix_is_pending
  vfio-pci: refactor for cpr
  vfio-pci: skip reset during cpr
  vfio-pci: preserve MSI
  vfio-pci: preserve INTx
  migration: close kvm after cpr
  migration: cpr_get_fd_param helper
  vfio: return mr from vfio_get_xlat_addr
  vfio: pass ramblock to vfio_container_dma_map
  vfio/iommufd: define iommufd_cdev_make_hwpt
  vfio/iommufd: use IOMMU_IOAS_MAP_FILE
  vfio/iommufd: export iommufd_cdev_get_info_iova_range
  iommufd: change process ioctl
  vfio/iommufd: invariant device name
  vfio/iommufd: register container for cpr
  vfio/iommufd: preserve descriptors
  vfio/iommufd: reconstruct device
  iommufd: preserve DMA mappings

 accel/kvm/kvm-all.c                   |  20 +++
 backends/iommufd.c                    |  88 +++++++++-
 backends/trace-events                 |   2 +
 hw/pci/msix.c                         |   2 +-
 hw/pci/pci.c                          |  13 ++
 hw/vfio/common.c                      | 108 +++++++++---
 hw/vfio/container-base.c              |  12 +-
 hw/vfio/container.c                   | 155 ++++++++++++++---
 hw/vfio/cpr-iommufd.c                 | 161 ++++++++++++++++++
 hw/vfio/cpr-legacy.c                  | 161 ++++++++++++++++++
 hw/vfio/helpers.c                     |  28 ++--
 hw/vfio/iommufd.c                     | 156 ++++++++++++-----
 hw/vfio/meson.build                   |   4 +-
 hw/vfio/pci.c                         | 307 +++++++++++++++++++++++++++++-----
 hw/vfio/trace-events                  |   1 +
 hw/virtio/vhost-vdpa.c                |   2 +-
 include/exec/cpu-common.h             |   1 +
 include/exec/memory.h                 |   5 +-
 include/hw/pci/msix.h                 |   1 +
 include/hw/vfio/vfio-common.h         |  25 +++
 include/hw/vfio/vfio-container-base.h |   6 +-
 include/migration/cpr.h               |   7 +
 include/migration/vmstate.h           |   3 +-
 include/system/iommufd.h              |   6 +
 include/system/kvm.h                  |   1 +
 migration/cpr-transfer.c              |  18 ++
 migration/cpr.c                       |  70 ++++++++
 migration/migration.c                 |   1 +
 migration/savevm.c                    |   4 +-
 system/memory.c                       |   8 +-
 system/physmem.c                      |   5 +
 31 files changed, 1230 insertions(+), 151 deletions(-)
 create mode 100644 hw/vfio/cpr-iommufd.c
 create mode 100644 hw/vfio/cpr-legacy.c

-- 
1.8.3.1



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

end of thread, other threads:[~2025-02-16 23:37 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-29 14:42 [PATCH V1 00/26] Live update: vfio and iommufd Steve Sistare
2025-01-29 14:42 ` [PATCH V1 01/26] migration: cpr helpers Steve Sistare
2025-01-29 14:42 ` [PATCH V1 02/26] migration: lower handler priority Steve Sistare
2025-02-03 16:21   ` Fabiano Rosas
2025-02-03 16:58   ` Peter Xu
2025-02-06 13:39     ` Steven Sistare
2025-01-29 14:42 ` [PATCH V1 03/26] vfio: vfio_find_ram_discard_listener Steve Sistare
2025-02-03 16:57   ` Cédric Le Goater
2025-01-29 14:43 ` [PATCH V1 04/26] vfio/container: register container for cpr Steve Sistare
2025-02-03 17:01   ` Cédric Le Goater
2025-02-03 22:26     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 05/26] vfio/container: preserve descriptors Steve Sistare
2025-02-03 17:48   ` Cédric Le Goater
2025-02-03 22:26     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 06/26] vfio/container: preserve DMA mappings Steve Sistare
2025-02-03 18:25   ` Cédric Le Goater
2025-02-03 22:27     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 07/26] vfio/container: recover from unmap-all-vaddr failure Steve Sistare
2025-02-04 14:10   ` Cédric Le Goater
2025-02-04 16:13     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 08/26] pci: skip reset during cpr Steve Sistare
2025-02-04 14:14   ` Cédric Le Goater
2025-02-04 16:13     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 09/26] pci: export msix_is_pending Steve Sistare
2025-01-29 14:43 ` [PATCH V1 10/26] vfio-pci: refactor for cpr Steve Sistare
2025-02-04 14:39   ` Cédric Le Goater
2025-02-04 16:14     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 11/26] vfio-pci: skip reset during cpr Steve Sistare
2025-02-04 14:56   ` Cédric Le Goater
2025-02-04 16:15     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 12/26] vfio-pci: preserve MSI Steve Sistare
2025-02-05 16:48   ` Cédric Le Goater
2025-02-06 14:41     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 13/26] vfio-pci: preserve INTx Steve Sistare
2025-02-05 17:13   ` Cédric Le Goater
2025-02-06 14:43     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 14/26] migration: close kvm after cpr Steve Sistare
2025-01-29 14:43 ` [PATCH V1 15/26] migration: cpr_get_fd_param helper Steve Sistare
2025-01-29 14:43 ` [PATCH V1 16/26] vfio: return mr from vfio_get_xlat_addr Steve Sistare
2025-02-04 15:47   ` Cédric Le Goater
2025-02-04 17:42     ` Steven Sistare
2025-02-16 23:19       ` John Levon
2025-01-29 14:43 ` [PATCH V1 17/26] vfio: pass ramblock to vfio_container_dma_map Steve Sistare
2025-01-29 14:43 ` [PATCH V1 18/26] vfio/iommufd: define iommufd_cdev_make_hwpt Steve Sistare
2025-02-04 16:22   ` Cédric Le Goater
2025-02-04 17:42     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 19/26] vfio/iommufd: use IOMMU_IOAS_MAP_FILE Steve Sistare
2025-02-05 17:23   ` Cédric Le Goater
2025-02-05 22:01     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 20/26] vfio/iommufd: export iommufd_cdev_get_info_iova_range Steve Sistare
2025-02-05 17:33   ` Cédric Le Goater
2025-02-05 22:01     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 21/26] iommufd: change process ioctl Steve Sistare
2025-02-05 17:34   ` Cédric Le Goater
2025-02-05 22:02     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 22/26] vfio/iommufd: invariant device name Steve Sistare
2025-02-05 17:42   ` Cédric Le Goater
2025-02-05 22:02     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 23/26] vfio/iommufd: register container for cpr Steve Sistare
2025-02-05 17:45   ` Cédric Le Goater
2025-02-05 22:03     ` Steven Sistare
2025-01-29 14:43 ` [PATCH V1 24/26] vfio/iommufd: preserve descriptors Steve Sistare
2025-01-29 14:43 ` [PATCH V1 25/26] vfio/iommufd: reconstruct device Steve Sistare
2025-01-29 14:43 ` [PATCH V1 26/26] iommufd: preserve DMA mappings Steve 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).