summary refs log tree commit diff stats
path: root/hw/vfio-user/pci.c
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2025-06-25 20:30:04 +0100
committerCédric Le Goater <clg@redhat.com>2025-06-26 08:55:38 +0200
commit019232358124e4f4b929e40fa23253de60eec73e (patch)
tree7720556efe3ed89d322f6239fbb1bb3954d3efac /hw/vfio-user/pci.c
parent52ce9c35f8e364e5823fc13f23929eb597bb69ac (diff)
downloadfocaccia-qemu-019232358124e4f4b929e40fa23253de60eec73e.tar.gz
focaccia-qemu-019232358124e4f4b929e40fa23253de60eec73e.zip
vfio-user: implement VFIO_USER_DEVICE_RESET
Hook this call up to the legacy reset handler for vfio-user-pci.

Originally-by: John Johnson <john.g.johnson@oracle.com>
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-13-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/vfio-user/pci.c')
-rw-r--r--hw/vfio-user/pci.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c
index c0f00f15b1..49d12763ab 100644
--- a/hw/vfio-user/pci.c
+++ b/hw/vfio-user/pci.c
@@ -263,6 +263,20 @@ static void vfio_user_instance_finalize(Object *obj)
     }
 }
 
+static void vfio_user_pci_reset(DeviceState *dev)
+{
+    VFIOPCIDevice *vdev = VFIO_PCI_BASE(dev);
+    VFIODevice *vbasedev = &vdev->vbasedev;
+
+    vfio_pci_pre_reset(vdev);
+
+    if (vbasedev->reset_works) {
+        vfio_user_device_reset(vbasedev->proxy);
+    }
+
+    vfio_pci_post_reset(vdev);
+}
+
 static const Property vfio_user_pci_dev_properties[] = {
     DEFINE_PROP_UINT32("x-pci-vendor-id", VFIOPCIDevice,
                        vendor_id, PCI_ANY_ID),
@@ -310,6 +324,7 @@ static void vfio_user_pci_dev_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *pdc = PCI_DEVICE_CLASS(klass);
 
+    device_class_set_legacy_reset(dc, vfio_user_pci_reset);
     device_class_set_props(dc, vfio_user_pci_dev_properties);
 
     object_class_property_add(klass, "socket", "SocketAddress", NULL,