diff options
| author | Steve Sistare <steven.sistare@oracle.com> | 2025-06-10 08:39:24 -0700 |
|---|---|---|
| committer | Cédric Le Goater <clg@redhat.com> | 2025-06-11 14:01:58 +0200 |
| commit | 031fbb7110a183053b431fb667867a5244910e75 (patch) | |
| tree | e748d232ae65333fb787abb5567fd2657be3fd7c /hw/vfio/cpr.c | |
| parent | 24c156dcd94299f64994170ce84efac9ae001f41 (diff) | |
| download | focaccia-qemu-031fbb7110a183053b431fb667867a5244910e75.tar.gz focaccia-qemu-031fbb7110a183053b431fb667867a5244910e75.zip | |
vfio-pci: skip reset during cpr
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 <steven.sistare@oracle.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/qemu-devel/1749569991-25171-12-git-send-email-steven.sistare@oracle.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/vfio/cpr.c')
| -rw-r--r-- | hw/vfio/cpr.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index 0e59612228..fdbb58e203 100644 --- a/hw/vfio/cpr.c +++ b/hw/vfio/cpr.c @@ -8,6 +8,8 @@ #include "qemu/osdep.h" #include "hw/vfio/vfio-device.h" #include "hw/vfio/vfio-cpr.h" +#include "hw/vfio/pci.h" +#include "migration/cpr.h" #include "qapi/error.h" #include "system/runstate.h" @@ -37,3 +39,32 @@ void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer) { migration_remove_notifier(&bcontainer->cpr_reboot_notifier); } + +/* + * The kernel may change non-emulated config bits. Exclude them from the + * changed-bits check in get_pci_config_device. + */ +static int vfio_cpr_pci_pre_load(void *opaque) +{ + VFIOPCIDevice *vdev = opaque; + PCIDevice *pdev = &vdev->pdev; + int size = MIN(pci_config_size(pdev), vdev->config_size); + int i; + + for (i = 0; i < size; i++) { + pdev->cmask[i] &= vdev->emulated_config_bits[i]; + } + + return 0; +} + +const VMStateDescription vfio_cpr_pci_vmstate = { + .name = "vfio-cpr-pci", + .version_id = 0, + .minimum_version_id = 0, + .pre_load = vfio_cpr_pci_pre_load, + .needed = cpr_incoming_needed, + .fields = (VMStateField[]) { + VMSTATE_END_OF_LIST() + } +}; |