[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V1 00/26] Live update: vfio and iommufd
From: |
Steve Sistare |
Subject: |
[PATCH V1 00/26] Live update: vfio and iommufd |
Date: |
Wed, 29 Jan 2025 06:42:56 -0800 |
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
- [PATCH V1 00/26] Live update: vfio and iommufd,
Steve Sistare <=
- [PATCH V1 01/26] migration: cpr helpers, Steve Sistare, 2025/01/29
- [PATCH V1 06/26] vfio/container: preserve DMA mappings, Steve Sistare, 2025/01/29
- [PATCH V1 04/26] vfio/container: register container for cpr, Steve Sistare, 2025/01/29
- [PATCH V1 02/26] migration: lower handler priority, Steve Sistare, 2025/01/29
- [PATCH V1 07/26] vfio/container: recover from unmap-all-vaddr failure, Steve Sistare, 2025/01/29
- [PATCH V1 11/26] vfio-pci: skip reset during cpr, Steve Sistare, 2025/01/29
- [PATCH V1 03/26] vfio: vfio_find_ram_discard_listener, Steve Sistare, 2025/01/29
- [PATCH V1 20/26] vfio/iommufd: export iommufd_cdev_get_info_iova_range, Steve Sistare, 2025/01/29
- [PATCH V1 08/26] pci: skip reset during cpr, Steve Sistare, 2025/01/29
- [PATCH V1 05/26] vfio/container: preserve descriptors, Steve Sistare, 2025/01/29