aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>2018-04-04 18:53:54 +0100
committerWill Deacon <will.deacon@arm.com>2018-04-06 11:28:12 +0100
commit0e1882a49f81cb15d328ef83a78849c0ea26eecc (patch)
treeb19a99df685ed55075649b2f9563b0d9bb29ccd2
parented83730f9750e40ad0351cab8b22e09b2820da03 (diff)
downloadkvmtool-0e1882a49f81cb15d328ef83a78849c0ea26eecc.tar.gz
virtio/pci: Register a single eventfd for vhost
Vhost supports a single eventfd as the kick mechanism. Registering a second one will override the first. To ensure vhost works with our virtio-pci, only register the kick eventfd that is used by the guest. Fixes: a508ea95f954 ("virtio/pci: Use port I/O for configuration registers by default") Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--virtio/pci.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/virtio/pci.c b/virtio/pci.c
index 9a199013..5a5fc6e1 100644
--- a/virtio/pci.c
+++ b/virtio/pci.c
@@ -25,8 +25,8 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde
{
struct ioevent ioevent;
struct virtio_pci *vpci = vdev->virtio;
- int i, r, flags = 0;
- int fds[2];
+ int r, flags = 0;
+ int fd;
vpci->ioeventfds[vq] = (struct virtio_pci_ioevent_param) {
.vdev = vdev,
@@ -50,7 +50,7 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde
/* ioport */
ioevent.io_addr = vpci->port_addr + VIRTIO_PCI_QUEUE_NOTIFY;
ioevent.io_len = sizeof(u16);
- ioevent.fd = fds[0] = eventfd(0, 0);
+ ioevent.fd = fd = eventfd(0, 0);
r = ioeventfd__add_event(&ioevent, flags | IOEVENTFD_FLAG_PIO);
if (r)
return r;
@@ -58,15 +58,13 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde
/* mmio */
ioevent.io_addr = vpci->mmio_addr + VIRTIO_PCI_QUEUE_NOTIFY;
ioevent.io_len = sizeof(u16);
- ioevent.fd = fds[1] = eventfd(0, 0);
+ ioevent.fd = eventfd(0, 0);
r = ioeventfd__add_event(&ioevent, flags);
if (r)
goto free_ioport_evt;
if (vdev->ops->notify_vq_eventfd)
- for (i = 0; i < 2; ++i)
- vdev->ops->notify_vq_eventfd(kvm, vpci->dev, vq,
- fds[i]);
+ vdev->ops->notify_vq_eventfd(kvm, vpci->dev, vq, fd);
return 0;
free_ioport_evt: