[RFC V2 6/8] tap: common return label

2025-07-17 Thread Steve Sistare
Modify net_init_tap so every return branches to a common label, for common cleanup in a subsequent patch. No functional change. Signed-off-by: Steve Sistare --- net/tap.c | 54 -- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git

[RFC V2 4/8] cpr: delete all fds

2025-07-17 Thread Steve Sistare
Add the cpr_delete_fd_all function to delete all fds associated with a device. Signed-off-by: Steve Sistare --- include/migration/cpr.h | 1 + migration/cpr.c | 13 + 2 files changed, 14 insertions(+) diff --git a/include/migration/cpr.h b/include/migration/cpr.h index

[RFC V2 0/8] Live update: tap and vhost

2025-07-17 Thread Steve Sistare
d the file descriptors to new QEMU, with no special management actions required. The user enables this behavior by specifing '-netdev tap,cpr=on'. The default is cpr=off. Steve Sistare (8): migration: stop vm earlier for cpr migration: cpr setup notifier vhost: reset vhost devices for cpr

[RFC V2 3/8] vhost: reset vhost devices for cpr

2025-07-17 Thread Steve Sistare
When preserving a vhost fd using CPR, call VHOST_RESET_OWNER prior to CPR in old QEMU. Otherwise, new QEMU will fail when it calls VHOST_SET_OWNER during vhost_dev_init. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- include/hw/virtio/vhost.h | 1 + hw/virtio/vhost.c | 32

[RFC V2 8/8] tap: postload fix for cpr

2025-07-17 Thread Steve Sistare
the queue is already detached. Define tap_disable_postload to avoid IFF_DETACH_QUEUE. Signed-off-by: Steve Sistare --- include/net/tap.h | 1 + hw/net/virtio-net.c | 20 net/tap-win32.c | 5 + net/tap.c | 17 + 4 files changed, 43

[RFC V2 1/8] migration: stop vm earlier for cpr

2025-07-17 Thread Steve Sistare
Stop the vm earlier for cpr, before cpr_save_state which causes new QEMU to proceed and initialize devices. We must guarantee devices are stopped in old QEMU, and all source notifiers called, before they are initialized in new QEMU. Signed-off-by: Steve Sistare --- migration/migration.c | 26

[RFC V2 5/8] Revert "vhost-backend: remove vhost_kernel_reset_device()"

2025-07-17 Thread Steve Sistare
This reverts commit e6383293eb01928692047e617665a742cca87e23. The reset function is needed for CPR. Signed-off-by: Steve Sistare --- hw/virtio/vhost-backend.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 833804d..9b75141

[RFC V2 2/8] migration: cpr setup notifier

2025-07-17 Thread Steve Sistare
Call MIG_EVENT_PRECOPY_SETUP earlier, before CPR starts. An early notifier is needed for resetting vhost devices, as explained in the next patch. Signed-off-by: Steve Sistare --- migration/migration.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/migration

[RFC V2 7/8] tap: cpr support

2025-07-17 Thread Steve Sistare
search for a saved value. Example: -netdev tap,id=hostnet2,fds=-1:-1,vhostfds=-1:-1,cpr=on Signed-off-by: Steve Sistare --- qapi/net.json | 5 +++- include/migration/cpr.h | 2 +- hw/vfio/device.c| 2 +- migration/cpr.c | 11 net

[PATCH V2 1/1] hw/intc/arm_gicv3_kvm: preserve pending interrupts during cpr

2025-07-16 Thread Steve Sistare
instance is created. Signed-off-by: Steve Sistare --- hw/intc/arm_gicv3_kvm.c| 18 +- include/hw/intc/arm_gicv3_common.h | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 3be3bf6c28..3d12c846ce

[PATCH V2 0/2] preserve pending interrupts during cpr

2025-07-16 Thread Steve Sistare
Close a race condition that causes cpr-transfer to lose VFIO interrupts. See commit messages for details. Steve Sistare (2): vfio/pci: augment set_handler vfio/pci: preserve pending interrupts hw/vfio/cpr.c | 93 +- hw/vfio/pci.c

[PATCH V2 2/2] vfio/pci: preserve pending interrupts

2025-07-16 Thread Steve Sistare
etion of kvm_irqchip_remove_irqfd_notifier_gsi, it will be recovered by the subsequent call to cpu_synchronize_all_states, which pulls KVM interrupt state to userland prior to saving it in vmstate. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 91 ++ hw/vfio/pci.c

[PATCH V2 1/2] vfio/pci: augment set_handler

2025-07-16 Thread Steve Sistare
Extend vfio_pci_msi_set_handler() so it can set or clear the handler. Add a similar accessor for INTx. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/cpr.c | 2 +- hw/vfio/pci.c | 13 +++-- hw/vfio/pci.h | 3 ++- 3 files changed, 14

[PATCH] tap: fix net_init_tap() return code

2025-07-14 Thread Steve Sistare
rns false, ret=0 is returned, and net_client_init1 will use a broken interface. Fix it to be future proof. Signed-off-by: Steve Sistare --- net/tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tap.c b/net/tap.c index ae1c7e3..35552c4 100644 --- a/net/tap.c +++ b/

[PATCH 59/59] vfio: fix sub-page bar after cpr

2025-07-14 Thread Steve Sistare
() However, after CPR, the guest does not reconfigure the device and the code path above is not taken. To fix, in vfio_cpr_pci_post_load, call vfio_sub_page_bar_update_mapping for each sub-page BAR with a valid address. Fixes: 7e9f21411302 ("vfio/container: restore DMA vaddr") Signed-off

[PATCH V1] vfio: fix sub-page bar after cpr

2025-07-14 Thread Steve Sistare
() However, after CPR, the guest does not reconfigure the device and the code path above is not taken. To fix, in vfio_cpr_pci_post_load, call vfio_sub_page_bar_update_mapping for each sub-page BAR with a valid address. Fixes: 7e9f21411302 ("vfio/container: restore DMA vaddr") Signed-off

[PATCH V1 1/2] hw/intc/arm_gicv3_kvm: subroutine for save pending

2025-07-14 Thread Steve Sistare
Extract a subroutine for KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES. No functional change. Signed-off-by: Steve Sistare --- hw/intc/arm_gicv3_kvm.c | 24 +++- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index

[PATCH V1 2/2] hw/intc/arm_gicv3_kvm: preserve pending interrupts during cpr

2025-07-14 Thread Steve Sistare
is created. Signed-off-by: Steve Sistare --- hw/intc/arm_gicv3_kvm.c| 16 +++- include/hw/intc/arm_gicv3_common.h | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 43cba6e3f1..15245af2fd 100644

[PATCH V1 1/2] vfio/pci: augment set_handler

2025-07-14 Thread Steve Sistare
Extend vfio_pci_msi_set_handler() so it can set or clear the handler. Add a similar accessor for INTx. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 2 +- hw/vfio/pci.c | 13 +++-- hw/vfio/pci.h | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff

[PATCH V1 0/2] preserve pending interrupts during cpr

2025-07-14 Thread Steve Sistare
Close a race condition that causes cpr-transfer to lose VFIO interrupts. See commit messages for details. Steve Sistare (2): vfio/pci: augment set_handler vfio/pci: preserve pending interrupts hw/vfio/cpr.c | 92 +- hw/vfio/pci.c

[PATCH V1 0/2] preserve pending interrupts during cpr on arm

2025-07-14 Thread Steve Sistare
Close a race condition that causes cpr-transfer to lose VFIO interrupts on ARM. See commit messages for details. Steve Sistare (2): hw/intc/arm_gicv3_kvm: subroutine for save pending hw/intc/arm_gicv3_kvm: preserve pending interrupts during cpr hw/intc/arm_gicv3_kvm.c| 40

[PATCH V1 2/2] vfio/pci: preserve pending interrupts

2025-07-14 Thread Steve Sistare
fier_gsi, it will be recovered by the subsequent call to cpu_synchronize_all_states, which pulls KVM interrupt state to userland prior to saving it in vmstate. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 90 ++ hw/vfio/pci.c |

[PATCH V5 2/3] python: use qom-list-get

2025-07-11 Thread Steve Sistare
Use qom-list-get to speed up the qom-tree command. Signed-off-by: Steve Sistare Acked-by: Markus Armbruster --- python/qemu/utils/qom.py| 43 +++-- python/qemu/utils/qom_common.py | 53 + 2 files changed, 78 insertions

[PATCH V5 0/3] fast qom tree get

2025-07-11 Thread Steve Sistare
v * cosmetic changes in the docs and code. Changes in V2: * removed "qom: qom_resolve_path", which was pulled separately * dropped the error member * fixed missing _list_tree in qom.py * updated 10.0 to 10.1 Steve Sistare (3): qom: qom-list-get python: use qom-list-get test

[PATCH V5 1/3] qom: qom-list-get

2025-07-11 Thread Steve Sistare
start up time. Define the qom-list-get command, which fetches all the properties and values for a list of paths. This can be much faster than qom-list plus qom-get. When getting an entire QOM tree, I measured a 10x speedup in elapsed time. Signed-off-by: Steve Sistare Tested-by: Philippe Mathieu-

[PATCH V5 3/3] tests/qtest/qom-test: unit test for qom-list-get

2025-07-11 Thread Steve Sistare
Add a unit test for qom-list-get. Signed-off-by: Steve Sistare Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster --- tests/qtest/qom-test.c | 116 - 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qom

[PATCH V4 2/3] python: use qom-list-get

2025-07-10 Thread Steve Sistare
Use qom-list-get to speed up the qom-tree command. Signed-off-by: Steve Sistare --- python/qemu/utils/qom.py| 43 +++-- python/qemu/utils/qom_common.py | 53 + 2 files changed, 78 insertions(+), 18 deletions(-) diff

[PATCH V4 3/3] tests/qtest/qom-test: unit test for qom-list-getv

2025-07-10 Thread Steve Sistare
Add a unit test for qom-list-getv. Signed-off-by: Steve Sistare Reviewed-by: Philippe Mathieu-Daudé --- tests/qtest/qom-test.c | 116 - 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c

[PATCH V4 0/3] fast qom tree get

2025-07-10 Thread Steve Sistare
: qom_resolve_path", which was pulled separately * dropped the error member * fixed missing _list_tree in qom.py * updated 10.0 to 10.1 Steve Sistare (3): qom: qom-list-get python: use qom-list-get tests/qtest/qom-test: unit test for qom-list-getv python/qemu/utils/qom.py| 43

[PATCH V4 1/3] qom: qom-list-get

2025-07-10 Thread Steve Sistare
-up time. Signed-off-by: Steve Sistare Reviewed-by: Philippe Mathieu-Daudé --- qapi/qom.json | 50 ++ qom/qom-qmp-cmds.c | 53 + 2 files changed, 103 insertions(+) diff --git a/qapi/qom.json b

[PATCH V3 0/3] fast qom tree get

2025-07-08 Thread Steve Sistare
tree script to use qom-list-getv * cosmetic changes in the docs and code. Changes in V2: * removed "qom: qom_resolve_path", which was pulled separately * dropped the error member * fixed missing _list_tree in qom.py * updated 10.0 to 10.1 Steve Sistare (3): qom: qom-list-

[PATCH V3 3/3] tests/qtest/qom-test: unit test for qom-list-getv

2025-07-08 Thread Steve Sistare
Add a unit test for qom-list-getv. Signed-off-by: Steve Sistare --- tests/qtest/qom-test.c | 64 ++ 1 file changed, 64 insertions(+) diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c index 27d70bc..4defff1 100644 --- a/tests/qtest/qom

[PATCH V3 1/3] qom: qom-list-getv

2025-07-08 Thread Steve Sistare
Define the qom-list-getv command, which fetches all the properties and values for a list of paths. This is faster than qom-tree-get when fetching a subset of the QOM tree. See qom.json for details. Signed-off-by: Steve Sistare --- qapi/qom.json | 50

[PATCH V3 2/3] python: use qom-list-getv

2025-07-08 Thread Steve Sistare
Use qom-list-getv to speed up the qom-tree command. Signed-off-by: Steve Sistare --- python/qemu/utils/qom.py| 43 +++-- python/qemu/utils/qom_common.py | 53 + 2 files changed, 78 insertions(+), 18 deletions(-) diff

[PATCH V6 10/21] vfio/iommufd: add vfio_device_free_name

2025-07-02 Thread Steve Sistare
Define vfio_device_free_name to free the name created by vfio_device_get_name. A subsequent patch will do more there. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater Reviewed-by: Zhenzhong Duan --- include/hw/vfio/vfio-device.h | 1 + hw/vfio/ap.c

[PATCH V6 17/21] vfio/iommufd: reconstruct hwpt

2025-07-02 Thread Steve Sistare
Skip allocation of, and attachment to, hwpt_id. Recover it from CPR state. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 30 ++ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c

[PATCH V6 12/21] vfio/iommufd: register container for cpr

2025-07-02 Thread Steve Sistare
subsequent patches. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 12 +++ include/system/iommufd.h | 1 + backends/iommufd.c | 10 ++ hw/vfio/cpr-iommufd.c | 86 ++ hw/vfio/iommufd.c | 6 ++-- hw/vfio

[PATCH V6 16/21] vfio/iommufd: reconstruct device

2025-07-02 Thread Steve Sistare
a matching container, if any, before creating a new one. This reconstruction is not complete. hwpt_id is handled in a subsequent patch. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- hw/vfio/iommufd.c | 30 -- 1 file changed, 28 insertions(+), 2

[PATCH V6 01/21] vfio-pci: preserve MSI

2025-07-02 Thread Steve Sistare
tance. Signed-off-by: Steve Sistare --- hw/vfio/pci.h | 2 + include/hw/vfio/vfio-cpr.h | 8 hw/vfio/cpr.c | 97 ++ hw/vfio/pci.c | 52 - 4 files changed, 157 insertions(+), 2 dele

[PATCH V6 00/21] Live update: vfio and iommufd

2025-07-02 Thread Steve Sistare
anges in V6: * dropped already-pulled patches * converted remaining g_free in "add vfio_device_free_name" * fixed iommufd_backend_disconnect in "preserve descriptors" * tweaked vfio_cpr_load_device in "preserve descriptors" * added trace_vfio_cpr_find_device i

[PATCH V6 21/21] vfio: doc changes for cpr

2025-07-02 Thread Steve Sistare
Update documentation to say that cpr-transfer supports vfio and iommufd. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater Reviewed-by: Fabiano Rosas --- docs/devel/migration/CPR.rst | 5 ++--- qapi/migration.json | 6 -- 2 files changed, 6 insertions(+), 5 deletions

[PATCH V6 02/21] vfio-pci: preserve INTx

2025-07-02 Thread Steve Sistare
initialization, but still perform kvm initialization. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 27 ++- hw/vfio/pci.c | 55 +-- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/hw/vfio/cpr.c b/hw

[PATCH V6 08/21] vfio/iommufd: use IOMMU_IOAS_MAP_FILE

2025-07-02 Thread Steve Sistare
Use IOMMU_IOAS_MAP_FILE when the mapped region is backed by a file. Such a mapping can be preserved without modification during CPR, because it depends on the file's address space, which does not change, rather than on the process's address space, which does change. Signed-off-by: Ste

[PATCH V6 04/21] migration: cpr_get_fd_param helper

2025-07-02 Thread Steve Sistare
changes when sent to new QEMU via SCM_RIGHTS. Hence the user cannot send getfd to new QEMU, but when the user sends a hotplug command that references the fd, cpr_get_fd_param finds its value in CPR state. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- include/migration/cpr.h | 2

[PATCH V6 09/21] vfio/iommufd: invariant device name

2025-07-02 Thread Steve Sistare
QEMU must know the fd number to construct a name to find the fd number. To fix, create an invariant name based on the id command-line parameter, if id is defined. The user will need to provide such an id to use CPR. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater Reviewed-by: Zhenzhong

[PATCH V6 06/21] backends/iommufd: change process ioctl

2025-07-02 Thread Steve Sistare
Define the change process ioctl Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater Reviewed-by: Zhenzhong Duan --- include/system/iommufd.h | 3 +++ backends/iommufd.c | 24 backends/trace-events| 1 + 3 files changed, 28 insertions(+) diff --git

[PATCH V6 14/21] vfio/iommufd: cpr state

2025-07-02 Thread Steve Sistare
-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- include/hw/vfio/vfio-cpr.h | 3 ++ hw/vfio/cpr-iommufd.c | 98 +- hw/vfio/iommufd.c | 2 + hw/vfio/trace-events | 3 ++ 4 files changed, 105 insertions(+), 1 deletion(-) diff

[PATCH V6 13/21] migration: vfio cpr state hook

2025-07-02 Thread Steve Sistare
device object will be defined by the vfio subsystem in a subsequent patch. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 1 + include/migration/cpr.h| 12 hw/vfio/cpr-iommufd.c | 2 ++ hw/vfio/iommufd-stubs.c| 18 ++ migration/cpr.c

[PATCH V6 11/21] vfio/iommufd: device name blocker

2025-07-02 Thread Steve Sistare
If an invariant device name cannot be created, block CPR. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- include/hw/vfio/vfio-cpr.h | 1 + hw/vfio/device.c | 11 +++ 2 files changed, 12 insertions(+) diff --git a/include/hw/vfio/vfio-cpr.h b/include/hw/vfio

[PATCH V6 03/21] migration: close kvm after cpr

2025-07-02 Thread Steve Sistare
Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- include/hw/vfio/vfio-cpr.h| 2 ++ include/hw/vfio/vfio-device.h | 2 ++ include/system/kvm.h | 1 + accel/kvm/kvm-all.c | 32 hw/vfio/cpr-legacy.c | 2 ++ hw/vfio/cpr.c

[PATCH V6 20/21] vfio/container: delete old cpr register

2025-07-02 Thread Steve Sistare
vfio_cpr_[un]register_container is no longer used since they were subsumed by container type-specific registration. Delete them. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-cpr.h | 4 hw/vfio/cpr.c | 13

[PATCH V6 07/21] physmem: qemu_ram_get_fd_offset

2025-07-02 Thread Steve Sistare
Define qemu_ram_get_fd_offset, so CPR can map a memory region using IOMMU_IOAS_MAP_FILE in a subsequent patch. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: Zhenzhong Duan --- include/exec/cpu-common.h | 1 + system/physmem.c | 5 + 2 files changed, 6 insertions

[PATCH V6 19/21] iommufd: preserve DMA mappings

2025-07-02 Thread Steve Sistare
. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- backends/iommufd.c | 8 1 file changed, 8 insertions(+) diff --git a/backends/iommufd.c b/backends/iommufd.c index e091792..2a33c7a 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -245,6 +245,10 @@ int

[PATCH V6 05/21] backends/iommufd: iommufd_backend_map_file_dma

2025-07-02 Thread Steve Sistare
Define iommufd_backend_map_file_dma to implement IOMMU_IOAS_MAP_FILE. This will be called as a substitute for iommufd_backend_map_dma, so the error conditions for BARs are copied as-is from that function. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- include/system/iommufd.h

[PATCH V6 18/21] vfio/iommufd: change process

2025-07-02 Thread Steve Sistare
Finish CPR by change the owning process of the iommufd device in post load. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- hw/vfio/cpr-iommufd.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c index

[PATCH V6 15/21] vfio/iommufd: preserve descriptors

2025-07-02 Thread Steve Sistare
Save the iommu and vfio device fd in CPR state when it is created. After CPR, the fd number is found in CPR state and reused. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- backends/iommufd.c| 35 +-- hw/vfio/cpr-iommufd.c | 10 ++ hw

[PATCH V5.1] pci: skip reset during cpr

2025-06-10 Thread Steve Sistare
Do not reset a vfio-pci device during CPR. Signed-off-by: Steve Sistare --- hw/pci/pci.c | 5 + hw/vfio/pci.c| 7 +++ include/hw/pci/pci.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 9b4bf48..c70b5ce 100644 --- a/hw/pci/pci.c

[PATCH V5 17/38] vfio/pci: export MSI functions

2025-06-10 Thread Steve Sistare
Export various MSI functions, renamed with a vfio_pci prefix, for use by CPR in subsequent patches. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.h | 8 hw/vfio/pci.c | 29 + 2 files changed, 25

[PATCH V5 03/38] vfio/container: register container for cpr

2025-06-10 Thread Steve Sistare
in subsequent patches. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-container.h | 2 ++ include/hw/vfio/vfio-cpr.h | 15 + hw/vfio/container.c | 7 ++--- hw/vfio/cpr-legacy.c | 68

[PATCH V5 21/38] migration: cpr_get_fd_param helper

2025-06-10 Thread Steve Sistare
changes when sent to new QEMU via SCM_RIGHTS. Hence the user cannot send getfd to new QEMU, but when the user sends a hotplug command that references the fd, cpr_get_fd_param finds its value in CPR state. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- include/migration/cpr.h | 2

[PATCH V5 32/38] vfio/iommufd: preserve descriptors

2025-06-10 Thread Steve Sistare
Save the iommu and vfio device fd in CPR state when it is created. After CPR, the fd number is found in CPR state and reused. Signed-off-by: Steve Sistare --- backends/iommufd.c| 25 - hw/vfio/cpr-iommufd.c | 10 ++ hw/vfio/device.c | 9 + 3

[PATCH V5 18/38] vfio-pci: preserve MSI

2025-06-10 Thread Steve Sistare
tance. Signed-off-by: Steve Sistare --- hw/vfio/pci.h | 2 + include/hw/vfio/vfio-cpr.h | 8 hw/vfio/cpr.c | 97 ++ hw/vfio/pci.c | 54 -- 4 files changed, 158 insertions(+), 3 dele

[PATCH V5 28/38] vfio/iommufd: device name blocker

2025-06-10 Thread Steve Sistare
If an invariant device name cannot be created, block CPR. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 1 + hw/vfio/device.c | 11 +++ 2 files changed, 12 insertions(+) diff --git a/include/hw/vfio/vfio-cpr.h b/include/hw/vfio/vfio-cpr.h index 25e74ee

[PATCH V5 26/38] vfio/iommufd: invariant device name

2025-06-10 Thread Steve Sistare
QEMU must know the fd number to construct a name to find the fd number. To fix, create an invariant name based on the id command-line parameter, if id is defined. The user will need to provide such an id to use CPR. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/device.c

[PATCH V5 25/38] vfio/iommufd: use IOMMU_IOAS_MAP_FILE

2025-06-10 Thread Steve Sistare
Use IOMMU_IOAS_MAP_FILE when the mapped region is backed by a file. Such a mapping can be preserved without modification during CPR, because it depends on the file's address space, which does not change, rather than on the process's address space, which does change. Signed-off-by: Ste

[PATCH V5 09/38] pci: export msix_is_pending

2025-06-10 Thread Steve Sistare
Export msix_is_pending for use by cpr. No functional change. Signed-off-by: Steve Sistare Acked-by: Michael S. Tsirkin --- include/hw/pci/msix.h | 1 + hw/pci/msix.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h

[PATCH V5 14/38] vfio/pci: pass vector to virq functions

2025-06-10 Thread Steve Sistare
Pass the vector number to vfio_connect_kvm_msi_virq and vfio_remove_kvm_msi_virq, so it can be passed to their subroutines in a subsequent patch. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 13 +++-- 1 file changed, 7 insertions

[PATCH V5 29/38] vfio/iommufd: register container for cpr

2025-06-10 Thread Steve Sistare
subsequent patches. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 12 +++ include/system/iommufd.h | 1 + backends/iommufd.c | 10 ++ hw/vfio/cpr-iommufd.c | 84 ++ hw/vfio/iommufd.c | 6 ++-- hw/vfio

[PATCH V5 13/38] vfio/pci: vfio_notifier_init

2025-06-10 Thread Steve Sistare
Move event_notifier_init calls to a helper vfio_notifier_init. This version is trivial, but it will be expanded to support CPR in subsequent patches. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 40

[PATCH V5 36/38] iommufd: preserve DMA mappings

2025-06-10 Thread Steve Sistare
. Signed-off-by: Steve Sistare --- backends/iommufd.c | 8 1 file changed, 8 insertions(+) diff --git a/backends/iommufd.c b/backends/iommufd.c index e02f06e..6a5566c 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -245,6 +245,10 @@ int iommufd_backend_map_file_dma

[PATCH V5 06/38] vfio/container: restore DMA vaddr

2025-06-10 Thread Steve Sistare
section, and the calls will match the mappings remembered by the kernel. The listener calls a special dma_map handler that passes the new VA of each section to the kernel using VFIO_DMA_MAP_FLAG_VADDR. Restore the normal handler at the end. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le

[PATCH V5 10/38] pci: skip reset during cpr

2025-06-10 Thread Steve Sistare
Do not reset a vfio-pci device during CPR. Signed-off-by: Steve Sistare --- include/hw/pci/pci_device.h | 3 +++ hw/pci/pci.c| 5 + hw/vfio/pci.c | 7 +++ 3 files changed, 15 insertions(+) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci

[PATCH V5 19/38] vfio-pci: preserve INTx

2025-06-10 Thread Steve Sistare
initialization, but still perform kvm initialization. Signed-off-by: Steve Sistare --- hw/vfio/cpr.c | 27 ++- hw/vfio/pci.c | 32 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index e467373

[PATCH V5 12/38] vfio/pci: vfio_pci_vector_init

2025-06-10 Thread Steve Sistare
Extract a subroutine vfio_pci_vector_init. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 24 +--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 67edf80..03630bb

[PATCH V5 08/38] vfio/container: recover from unmap-all-vaddr failure

2025-06-10 Thread Steve Sistare
a new "remap" flag that tells it to restore a mapping without re-allocating new userland data structures. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-container-base.h | 3 ++ include/hw/vfio/vfio-cpr.h| 10 hw/vfio/cp

[PATCH V5 33/38] vfio/iommufd: reconstruct device

2025-06-10 Thread Steve Sistare
a matching container, if any, before creating a new one. This reconstruction is not complete. hwpt_id is handled in a subsequent patch. Signed-off-by: Steve Sistare --- hw/vfio/iommufd.c | 30 -- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/hw/vfio

[PATCH V5 16/38] vfio/pci: vfio_notifier_cleanup

2025-06-10 Thread Steve Sistare
Move event_notifier_cleanup calls to a helper vfio_notifier_cleanup. This version is trivial, and does not yet use the vdev and nr parameters. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 28 +--- 1 file changed

[PATCH V5 23/38] backends/iommufd: change process ioctl

2025-06-10 Thread Steve Sistare
Define the change process ioctl Signed-off-by: Steve Sistare --- include/system/iommufd.h | 3 +++ backends/iommufd.c | 24 backends/trace-events| 1 + 3 files changed, 28 insertions(+) diff --git a/include/system/iommufd.h b/include/system/iommufd.h index

[PATCH V5 35/38] vfio/iommufd: change process

2025-06-10 Thread Steve Sistare
Finish CPR by change the owning process of the iommufd device in post load. Signed-off-by: Steve Sistare --- hw/vfio/cpr-iommufd.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c index 152a661..a9e3f68 100644

[PATCH V5 04/38] vfio/container: preserve descriptors

2025-06-10 Thread Steve Sistare
, such as vfio ioctl's, are skipped. The result is that vfio_realize constructs qemu data structures that reflect the current state of the device. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater Reviewed-by: Zhenzhong Duan --- include/hw/vfio/vfio-cpr.h | 6 + hw

[PATCH V5 20/38] migration: close kvm after cpr

2025-06-10 Thread Steve Sistare
Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-device.h | 2 ++ include/migration/cpr.h | 2 ++ include/system/kvm.h | 1 + accel/kvm/kvm-all.c | 32 accel/stubs/kvm-stub.c| 5 + hw/vfio/helpers.c | 10

[PATCH V5 37/38] vfio/container: delete old cpr register

2025-06-10 Thread Steve Sistare
vfio_cpr_[un]register_container is no longer used since they were subsumed by container type-specific registration. Delete them. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- include/hw/vfio/vfio-cpr.h | 4 hw/vfio/cpr.c | 13 - 2 files changed

[PATCH V5 38/38] vfio: doc changes for cpr

2025-06-10 Thread Steve Sistare
Update documentation to say that cpr-transfer supports vfio and iommufd. Signed-off-by: Steve Sistare --- docs/devel/migration/CPR.rst | 5 ++--- qapi/migration.json | 6 -- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/devel/migration/CPR.rst b/docs/devel

[PATCH V5 01/38] migration: cpr helpers

2025-06-10 Thread Steve Sistare
Add the cpr_incoming_needed, cpr_open_fd, and cpr_resave_fd helpers, for use when adding cpr support for vfio and iommufd. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- include/migration/cpr.h | 5 + migration/cpr.c | 36 2

[PATCH V5 34/38] vfio/iommufd: reconstruct hwpt

2025-06-10 Thread Steve Sistare
Skip allocation of, and attachment to, hwpt_id. Recover it from CPR state. Signed-off-by: Steve Sistare --- hw/vfio/iommufd.c | 30 ++ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index a650517..48c590b 100644

[PATCH V5 15/38] vfio/pci: vfio_notifier_init cpr parameters

2025-06-10 Thread Steve Sistare
Pass vdev and nr to vfio_notifier_init, for use by CPR in a subsequent patch. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 31 +++ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/hw/vfio/pci.c

[PATCH V5 27/38] vfio/iommufd: add vfio_device_free_name

2025-06-10 Thread Steve Sistare
Define vfio_device_free_name to free the name created by vfio_device_get_name. A subsequent patch will do more there. No functional change. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-device.h | 1 + hw/vfio/ap.c | 2 +- hw/vfio/ccw.c | 2 +- hw/vfio

[PATCH V5 00/38] Live update: vfio and iommufd

2025-06-10 Thread Steve Sistare
y attach to multiple containers per iommufd using ioas_id * simplified "reconstruct hwpt" by matching against hwpt_id. * added patch "add vfio_device_free_name" Changes in V5: * dropped: vfio/pci: vfio_pci_put_device on failure * added: "vfio: doc changes for

[PATCH V5 30/38] migration: vfio cpr state hook

2025-06-10 Thread Steve Sistare
device object will be defined by the vfio subsystem in a subsequent patch. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 1 + include/migration/cpr.h| 12 hw/vfio/cpr-iommufd.c | 2 ++ hw/vfio/iommufd-stubs.c| 18 ++ migration/cpr.c

[PATCH V5 07/38] vfio/container: mdev cpr blocker

2025-06-10 Thread Steve Sistare
During CPR, after VFIO_DMA_UNMAP_FLAG_VADDR, the vaddr is temporarily invalid, so mediated devices cannot be supported. Add a blocker for them. This restriction will not apply to iommufd containers when CPR is added for them in a future patch. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le

[PATCH V5 05/38] vfio/container: discard old DMA vaddr

2025-06-10 Thread Steve Sistare
In the container pre_save handler, discard the virtual addresses in DMA mappings with VFIO_DMA_UNMAP_FLAG_VADDR, because guest RAM will be remapped at a different VA after in new QEMU. DMA to already-mapped pages continues. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw

[PATCH V5 31/38] vfio/iommufd: cpr state

2025-06-10 Thread Steve Sistare
-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 3 ++ hw/vfio/cpr-iommufd.c | 96 +- hw/vfio/iommufd.c | 2 + 3 files changed, 100 insertions(+), 1 deletion(-) diff --git a/include/hw/vfio/vfio-cpr.h b/include/hw/vfio/vfio-cpr.h

[PATCH V5 02/38] migration: lower handler priority

2025-06-10 Thread Steve Sistare
handlers for the devices that they contain. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- include/migration/vmstate.h | 6 +- migration/savevm.c | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/migration/vmstate.h

[PATCH V5 22/38] backends/iommufd: iommufd_backend_map_file_dma

2025-06-10 Thread Steve Sistare
Define iommufd_backend_map_file_dma to implement IOMMU_IOAS_MAP_FILE. This will be called as a substitute for iommufd_backend_map_dma, so the error conditions for BARs are copied as-is from that function. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan --- include/system/iommufd.h

[PATCH V5 24/38] physmem: qemu_ram_get_fd_offset

2025-06-10 Thread Steve Sistare
Define qemu_ram_get_fd_offset, so CPR can map a memory region using IOMMU_IOAS_MAP_FILE in a subsequent patch. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: Zhenzhong Duan --- include/exec/cpu-common.h | 1 + system/physmem.c | 5 + 2 files changed, 6 insertions

[PATCH V5 11/38] vfio-pci: skip reset during cpr

2025-06-10 Thread Steve Sistare
Do not reset a vfio-pci device during CPR, and do not complain if the kernel's PCI config space changes for non-emulated bits between the vmstate save and load, which can happen due to ongoing interrupt activity. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- include/hw

[PATCH V4 17/43] vfio-pci: skip reset during cpr

2025-05-29 Thread Steve Sistare
Do not reset a vfio-pci device during CPR, and do not complain if the kernel's PCI config space changes for non-emulated bits between the vmstate save and load, which can happen due to ongoing interrupt activity. Signed-off-by: Steve Sistare --- include/hw/vfio/vfio-cpr.h | 2 ++ hw/vfio/

[PATCH V4 27/43] migration: cpr_get_fd_param helper

2025-05-29 Thread Steve Sistare
changes when sent to new QEMU via SCM_RIGHTS. Hence the user cannot send getfd to new QEMU, but when the user sends a hotplug command that references the fd, cpr_get_fd_param finds its value in CPR state. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- include/migration/cpr.h | 2

[PATCH V4 19/43] vfio/pci: vfio_notifier_init

2025-05-29 Thread Steve Sistare
Move event_notifier_init calls to a helper vfio_notifier_init. This version is trivial, but it will be expanded to support CPR in subsequent patches. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le Goater --- hw/vfio/pci.c | 40

[PATCH V4 13/43] vfio/container: mdev cpr blocker

2025-05-29 Thread Steve Sistare
During CPR, after VFIO_DMA_UNMAP_FLAG_VADDR, the vaddr is temporarily invalid, so mediated devices cannot be supported. Add a blocker for them. This restriction will not apply to iommufd containers when CPR is added for them in a future patch. Signed-off-by: Steve Sistare Reviewed-by: Cédric Le

  1   2   3   4   5   6   7   8   9   10   >