@@ -23,6 +23,7 @@
#include "msix.h"
#include "net.h"
#include "loader.h"
+#include "kvm.h"
/* from Linux's linux/virtio_pci.h */
@@ -388,6 +389,29 @@ static unsigned virtio_pci_get_features(void *opaque)
return proxy->host_features;
}
+static void virtio_pci_irqfd_read(void *opaque)
+{
+ VirtQueue *vq = opaque;
+ virtio_irq(vq->vdev, vq);
+}
+
+static int virtio_pci_irqfd(void * opaque, int n, int fd, bool assign)
+{
+ VirtIOPCIProxy *proxy = opaque;
+ VirtQueue *vq = &proxy->vdev->vq[n];
+
+ qemu_set_fd_handler(fd, assign ? virtio_pci_irqfd_read : NULL, NULL, vq);
+ return 0;
+}
+
+static int virtio_pci_queuefd(void * opaque, int n, int fd, bool assign)
+{
+ VirtIOPCIProxy *proxy = opaque;
+ return kvm_set_ioeventfd(proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY,
+ n, fd, assign);
+}
+
+
static const VirtIOBindings virtio_pci_bindings = {
.notify = virtio_pci_notify,
.save_config = virtio_pci_save_config,
@@ -395,6 +419,8 @@ static const VirtIOBindings virtio_pci_bindings = {
.save_queue = virtio_pci_save_queue,
.load_queue = virtio_pci_load_queue,
.get_features = virtio_pci_get_features,
+ .set_irqfd = virtio_pci_irqfd,
+ .set_queuefd = virtio_pci_queuefd,
};
static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
Support irqfd/queuefd. The last one only with kvm, that's okay because vhost relies on kvm anyway. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- hw/virtio-pci.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-)