From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Steve Sistare" <steven.sistare@oracle.com>,
"Cédric Le Goater" <clg@redhat.com>
Subject: [PULL 1/3] vfio/pci: augment set_handler
Date: Sun, 10 Aug 2025 18:01:16 +0200 [thread overview]
Message-ID: <20250810160118.450430-2-clg@redhat.com> (raw)
In-Reply-To: <20250810160118.450430-1-clg@redhat.com>
From: Steve Sistare <steven.sistare@oracle.com>
Extend vfio_pci_msi_set_handler() so it can set or clear the handler.
Add a similar accessor for INTx. No functional change.
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/1752689169-233452-2-git-send-email-steven.sistare@oracle.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/pci.h | 3 ++-
hw/vfio/cpr.c | 2 +-
hw/vfio/pci.c | 13 +++++++++++--
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 81465a8214a4008716806ae85c7f320f6b198bb2..2b564baf88640a4fe2e78b5ec4c4eb3ba3141357 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -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,
diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c
index 384b56c4c74d8224df0ceecb2b8ea4e1a1f40562..ade7ff745dc26e13712dbdafda38e1875a016505 100644
--- a/hw/vfio/cpr.c
+++ b/hw/vfio/cpr.c
@@ -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) {
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 4fa692c1a32bcfa4e4939e5fcb64f2bf19905b3b..4cd6894ca81731258ad10a5f9f894289e671a3db 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -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);
}
/*
--
2.50.1
next prev parent reply other threads:[~2025-08-10 16:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-10 16:01 [PULL 0/3] vfio queue Cédric Le Goater
2025-08-10 16:01 ` Cédric Le Goater [this message]
2025-08-10 16:01 ` [PULL 2/3] vfio/pci: preserve pending interrupts Cédric Le Goater
2025-08-10 16:01 ` [PULL 3/3] vfio: Document 'use-legacy-x86-rom' property Cédric Le Goater
2025-08-11 20:43 ` [PULL 0/3] vfio queue Stefan Hajnoczi
2025-08-12 5:55 ` Michael Tokarev
2025-08-12 6:35 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250810160118.450430-2-clg@redhat.com \
--to=clg@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=steven.sistare@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.