On 5/12/25 17:32, Steve Sistare wrote:
Extract a subroutine vfio_vector_init.  No functional change.

Signed-off-by: Steve Sistare <steven.sist...@oracle.com>
---
  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 4aa83b1..b46c42e 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -511,6 +511,22 @@ static void vfio_update_kvm_msi_virq(VFIOMSIVector 
*vector, MSIMessage msg,
      kvm_irqchip_commit_routes(kvm_state);
  }
+static void vfio_vector_init(VFIOPCIDevice *vdev, int nr)
+{
+    VFIOMSIVector *vector = &vdev->msi_vectors[nr];
+    PCIDevice *pdev = &vdev->pdev;
+
+    vector->vdev = vdev;
+    vector->virq = -1;
+    if (event_notifier_init(&vector->interrupt, 0)) {
+        error_report("vfio: Error: event_notifier_init failed");
+    }
+    vector->use = true;
+    if (vdev->interrupt == VFIO_INT_MSIX) {

You seem to have plans to use vfio_vector_init elsewhere (patch 22).

Looks ok for now.

Thanks,

C.


+        msix_vector_use(pdev, nr);
+    }
+}
+
  static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
                                     MSIMessage *msg, IOHandler *handler)
  {
@@ -524,13 +540,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, 
unsigned int nr,
      vector = &vdev->msi_vectors[nr];
if (!vector->use) {
-        vector->vdev = vdev;
-        vector->virq = -1;
-        if (event_notifier_init(&vector->interrupt, 0)) {
-            error_report("vfio: Error: event_notifier_init failed");
-        }
-        vector->use = true;
-        msix_vector_use(pdev, nr);
+        vfio_vector_init(vdev, nr);
      }
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),


Reply via email to