summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2025-06-25 20:30:00 +0100
committerCédric Le Goater <clg@redhat.com>2025-06-26 08:55:38 +0200
commit692e0ec50c2f38a7952f7e7c4c375c77b141f6b2 (patch)
tree5c908ea12b00a06632124f0c92705548e972e134
parent1ed50fcb6a8b99312458b9653de2d1d5acfd7506 (diff)
downloadfocaccia-qemu-692e0ec50c2f38a7952f7e7c4c375c77b141f6b2.tar.gz
focaccia-qemu-692e0ec50c2f38a7952f7e7c4c375c77b141f6b2.zip
vfio-user: set up PCI in vfio_user_pci_realize()
Re-use PCI setup functions from hw/vfio/pci.c to realize the vfio-user
PCI device.

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-9-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
-rw-r--r--hw/vfio-user/pci.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c
index d704e3d390..b49f42b980 100644
--- a/hw/vfio-user/pci.c
+++ b/hw/vfio-user/pci.c
@@ -126,10 +126,39 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp)
         goto error;
     }
 
+    if (!vfio_pci_populate_device(vdev, errp)) {
+        goto error;
+    }
+
+    if (!vfio_pci_config_setup(vdev, errp)) {
+        goto error;
+    }
+
+    /*
+     * vfio_pci_config_setup will have registered the device's BARs
+     * and setup any MSIX BARs, so errors after it succeeds must
+     * use out_teardown
+     */
+
+    if (!vfio_pci_add_capabilities(vdev, errp)) {
+        goto out_teardown;
+    }
+
+    if (!vfio_pci_interrupt_setup(vdev, errp)) {
+        goto out_teardown;
+    }
+
+    vfio_pci_register_err_notifier(vdev);
+    vfio_pci_register_req_notifier(vdev);
+
     return;
 
+out_teardown:
+    vfio_pci_teardown_msi(vdev);
+    vfio_pci_bars_exit(vdev);
 error:
     error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name);
+    vfio_pci_put_device(vdev);
 }
 
 static void vfio_user_instance_init(Object *obj)