vfio queue
The following changes since commit a74434580e1051bff12ab5eee5586058295c497f:
Merge tag 'pull-loongarch-20250808' of https://github.com/gaosong715/qemu into staging (2025-08-08 09:49:06 -0400)
are available in the Git repository at:
https://github.com/legoater/qemu/ tags/pull-vfio-20250810
for you to fetch changes up to d9f4b45713e4e000a42ed1f33cb06b806173b559:
vfio: Document 'use-legacy-x86-rom' property (2025-08-09 00:06:48 +0200)
----------------------------------------------------------------
vfio queue:
* Add documentation for the use-legacy-x86-rom property
* Preserve pending VFIO interrupts during CPR
----------------------------------------------------------------
Cédric Le Goater (1):
vfio: Document 'use-legacy-x86-rom' property
Steve Sistare (2):
vfio/pci: augment set_handler
vfio/pci: preserve pending interrupts
hw/vfio/pci.h | 4 +- include/hw/vfio/vfio-cpr.h | 6 +++ hw/vfio/cpr.c | 93 +++++++++++++++++++++++++++++++++++++++++++++- hw/vfio/pci.c | 18 ++++++++- 4 files changed, 117 insertions(+), 4 deletions(-)
[PULL 1/3] vfio/pci: augment set_handler
From: Steve Sistare <[email protected]>
Extend vfio_pci_msi_set_handler() so it can set or clear the handler. Add a similar accessor for INTx. No functional change.
--- hw/vfio/pci.h | 3 ++- hw/vfio/cpr.c | 2 +- hw/vfio/pci.c | 13 +++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-)
hw/vfio/pci.h +2 -1
@@ -209,8 +209,9 @@ void vfio_pci_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector,void vfio_pci_prepare_kvm_msi_virq_batch (VFIOPCIDevice *vdev);void vfio_pci_commit_kvm_msi_virq_batch (VFIOPCIDevice *vdev);bool vfio_pci_intx_enable (VFIOPCIDevice *vdev,Error **errp); +void vfio_pci_intx_set_handler (VFIOPCIDevice *vdev,bool enable);void vfio_pci_msix_set_notifiers (VFIOPCIDevice *vdev); -void vfio_pci_msi_set_handler (VFIOPCIDevice *vdev,int nr); +void vfio_pci_msi_set_handler (VFIOPCIDevice *vdev,int nr,bool enable);uint32_t vfio_pci_read_config (PCIDevice *pdev,uint32_t addr,int len); void vfio_pci_write_config(PCIDevice *pdev,
hw/vfio/cpr.c +1 -1
@@ -70,7 +70,7 @@ static void vfio_cpr_claim_vectors(VFIOPCIDevice *vdev, int nr_vectors, fd =vfio_cpr_load_vector_fd (vdev,"interrupt" , i);if (fd >=0 ) {vfio_pci_vector_init (vdev, i); -vfio_pci_msi_set_handler (vdev, i); +vfio_pci_msi_set_handler (vdev, i, true); }if (vfio_cpr_load_vector_fd (vdev,"kvm_interrupt" , i) >=0 ) {
hw/vfio/pci.c +11 -2
@@ -413,6 +413,14 @@ bool vfio_pci_intx_enable(VFIOPCIDevice *vdev, Error **errp)return vfio_intx_enable (vdev, errp); } +void vfio_pci_intx_set_handler (VFIOPCIDevice *vdev,bool enable) +{ +int fd =event_notifier_get_fd (&vdev->intx.interrupt); +IOHandler *handler = (enable ? vfio_intx_interrupt :NULL ); + +qemu_set_fd_handler (fd, handler,NULL , vdev); +} +/* * MSI/X */
@@ -451,12 +459,13 @@ static void vfio_msi_interrupt(void *opaque)notify (&vdev->pdev, nr); } -void vfio_pci_msi_set_handler (VFIOPCIDevice *vdev,int nr) +void vfio_pci_msi_set_handler (VFIOPCIDevice *vdev,int nr,bool enable) {VFIOMSIVector *vector = &vdev->msi_vectors[nr];int fd =event_notifier_get_fd (&vector->interrupt); +IOHandler *handler = (enable ? vfio_msi_interrupt :NULL ); -qemu_set_fd_handler (fd, vfio_msi_interrupt,NULL , vector); +qemu_set_fd_handler (fd, handler,NULL , vector); }/*
Signature · 1 line
2.50.1
[PULL 3/3] vfio: Document 'use-legacy-x86-rom' property
In reply to Cédric Le GoaterCommit 350785d41d8b ("ramfb: Add property to control if load the romfile") introduced the use-legacy-x86-rom property for the vfio-pci-nohotplug device. Add documentation for the property.
--- hw/vfio/pci.c | 3 +++ 1 file changed, 3 insertions(+)
hw/vfio/pci.c +3 -0
@@ -3901,6 +3901,9 @@ static void vfio_pci_nohotplug_dev_class_init(ObjectClass *klass,"x-ramfb-migrate" ,"Override default migration support for ramfb support " "(DEBUG)"); +object_class_property_set_description (klass,/* 10.1 */ +"use-legacy-x86-rom" , +"Controls loading of a legacy VGA BIOS ROM" ); }static const TypeInfo vfio_pci_nohotplug_dev_info = {
Signature · 1 line
2.50.1
[PULL 2/3] vfio/pci: preserve pending interrupts
In reply to Cédric Le GoaterFrom: Steve Sistare <[email protected]>
cpr-transfer may lose a VFIO interrupt because the KVM instance is destroyed and recreated. If an interrupt arrives in the middle, it is dropped. To fix, stop pending new interrupts during cpr save, and pick up the pieces. In more detail:
Stop the VCPUs. Call kvm_irqchip_remove_irqfd_notifier_gsi --> KVM_IRQFD to deassign the irqfd gsi that routes interrupts directly to the VCPU and KVM. After this call, interrupts fall back to the kernel vfio_msihandler, which writes to QEMU's kvm_interrupt eventfd. CPR already preserves that eventfd. When the route is re-established in new QEMU, the kernel tests the eventfd and injects an interrupt to KVM if necessary.
Deassign INTx in a similar manner. For both MSI and INTx, remove the eventfd handler so old QEMU does not consume an event.
If an interrupt was already pended to KVM prior to the completion 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.
--- hw/vfio/pci.h | 1 + include/hw/vfio/vfio-cpr.h | 6 +++ hw/vfio/cpr.c | 91 ++++++++++++++++++++++++++++++++++++++ hw/vfio/pci.c | 2 + 4 files changed, 100 insertions(+)
hw/vfio/pci.h +1 -0
@@ -188,6 +188,7 @@ struct VFIOPCIDevice {bool skip_vsc_check;VFIODisplay *dpy;Notifier irqchip_change_notifier; +VFIOPCICPR cpr; };/* Use uin32_t for vendor & device so PCI_ANY_ID expands and cannot match hw */
include/hw/vfio/vfio-cpr.h +6 -0
@@ -38,6 +38,10 @@ typedef struct VFIODeviceCPR {uint32_t ioas_id; } VFIODeviceCPR; +typedef struct VFIOPCICPR { +NotifierWithReturn transfer_notifier; +}VFIOPCICPR ; +bool vfio_legacy_cpr_register_container (struct VFIOContainer *container,Error **errp);void vfio_legacy_cpr_unregister_container (struct VFIOContainer *container);
@@ -77,5 +81,7 @@ extern const VMStateDescription vfio_cpr_pci_vmstate;extern const VMStateDescription vmstate_cpr_vfio_devices;void vfio_cpr_add_kvm_notifier (void ); +void vfio_cpr_pci_register_device (struct VFIOPCIDevice *vdev); +void vfio_cpr_pci_unregister_device (struct VFIOPCIDevice *vdev);#endif /* HW_VFIO_VFIO_CPR_H */
hw/vfio/cpr.c +91 -0
94 lines not on this page · raw message
hw/vfio/pci.c +2 -0
@@ -3001,6 +3001,7 @@ void vfio_pci_put_device(VFIOPCIDevice *vdev) {vfio_display_finalize (vdev);vfio_bars_finalize (vdev); +vfio_cpr_pci_unregister_device (vdev);g_free (vdev->emulated_config_bits);g_free (vdev->rom);/*
@@ -3480,6 +3481,7 @@ static void vfio_pci_realize(PCIDevice *pdev, Error **errp)vfio_pci_register_err_notifier (vdev);vfio_pci_register_req_notifier (vdev);vfio_setup_resetfn_quirk (vdev); +vfio_cpr_pci_register_device (vdev);return ;
Signature · 1 line
2.50.1
Stefan Hajnoczi
AppliedApplied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/10.1 for any user-visible changes.
Quoted 5 lines · Cédric Le Goater
vfio queue:
* Add documentation for the use-legacy-x86-rom property
* Preserve pending VFIO interrupts during CPR
Quoted 7 lines
----------------------------------------------------------------
Cédric Le Goater (1):
vfio: Document 'use-legacy-x86-rom' propertySteve Sistare (2):
vfio/pci: augmentset_handler
vfio/pci: preserve pending interrupts
It looks like 'preserve pending interrupts' is a good candidate for qemu-stable series (10.0.x), but the patch is rather large. Should I pick it up?
(FTR, it doesn't apply to 10.0 due to other changes in this area, and looking at these other changes, maybe we should pick up some more fixes?)
Thanks,
/mjt
Quoted 11 lines · Michael Tokarev
Quoted 9 lines · Cédric Le Goater
vfio queue:
* Add documentation for the use-legacy-x86-rom property
* Preserve pending VFIO interrupts during CPR----------------------------------------------------------------
Cédric Le Goater (1):
vfio: Document 'use-legacy-x86-rom' property
Quoted 7 lines
Quoted 3 lines
Steve Sistare (2):
vfio/pci: augmentset_handler
vfio/pci: preserve pending interruptsIt looks like 'preserve pending interrupts' is a good candidate for qemu-stable series (10.0.x), but the patch is rather large. Should I pick it up?
Nope. It's CPR related which has been merged in 10.1.
It lacks a Fixes tag. Sorry about that.
Thanks,
C.
Quoted 8 lines
(FTR, it doesn't apply to 10.0 due to other changes in this area, and looking at these other changes, maybe we should pick up some more fixes?)
Thanks,
/mjt