]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Add optional callbacks for VQs
authorSasha Levin <levinsasha928@gmail.com>
Wed, 16 Nov 2011 12:24:35 +0000 (14:24 +0200)
committerPekka Enberg <penberg@kernel.org>
Wed, 16 Nov 2011 19:20:22 +0000 (21:20 +0200)
This patch adds optional callbacks which get called when the VQ gets assigned
an eventfd for notifications, and when it gets assigned with a GSI.

This allows the device to pass the eventfds to 3rd parties which can use
them to notify and get notifications regarding the VQ.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/include/kvm/virtio-trans.h
tools/kvm/virtio/pci.c

index d9f4b95a0b22af3dc03b9840776689d69303949f..e7c186ee6082aa595add3281243e63bd9f982503 100644 (file)
@@ -20,6 +20,8 @@ struct virtio_ops {
        int (*notify_vq)(struct kvm *kvm, void *dev, u32 vq);
        int (*get_pfn_vq)(struct kvm *kvm, void *dev, u32 vq);
        int (*get_size_vq)(struct kvm *kvm, void *dev, u32 vq);
+       void (*notify_vq_gsi)(struct kvm *kvm, void *dev, u32 vq, u32 gsi);
+       void (*notify_vq_eventfd)(struct kvm *kvm, void *dev, u32 vq, u32 efd);
 };
 
 struct virtio_trans_ops {
index 1660f060446d668093ef272a126f1fdb8cb4f4a0..0737ae7176733547d9bda068fd9ba094cec86596 100644 (file)
@@ -51,6 +51,9 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_trans *vtra
 
        ioeventfd__add_event(&ioevent);
 
+       if (vtrans->virtio_ops->notify_vq_eventfd)
+               vtrans->virtio_ops->notify_vq_eventfd(kvm, vpci->dev, vq, ioevent.fd);
+
        return 0;
 }
 
@@ -152,6 +155,9 @@ static bool virtio_pci__specific_io_out(struct kvm *kvm, struct virtio_trans *vt
 
                        gsi = irq__add_msix_route(kvm, &vpci->msix_table[vec].msg);
                        vpci->gsis[vpci->queue_selector] = gsi;
+                       if (vtrans->virtio_ops->notify_vq_gsi)
+                               vtrans->virtio_ops->notify_vq_gsi(kvm, vpci->dev,
+                                                       vpci->queue_selector, gsi);
                        break;
                }
                };