From: Asias He <asias.hejun@xxxxxxxxx> Add is_pio flag to set KVM_IOEVENTFD_FLAG_PIO. This is useful for attaching an ioeventfd to MMIO address as well as PIO address. virtio-mmio needs an ioeventfd to MMIO address. Signed-off-by: Asias He <asias.hejun@xxxxxxxxx> --- tools/kvm/include/kvm/ioeventfd.h | 3 ++- tools/kvm/ioeventfd.c | 19 +++++++++++-------- tools/kvm/virtio/pci.c | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tools/kvm/include/kvm/ioeventfd.h b/tools/kvm/include/kvm/ioeventfd.h index ec70aa5..70cce9a 100644 --- a/tools/kvm/include/kvm/ioeventfd.h +++ b/tools/kvm/include/kvm/ioeventfd.h @@ -4,6 +4,7 @@ #include <linux/types.h> #include <linux/list.h> #include <sys/eventfd.h> +#include "kvm/util.h" struct kvm; @@ -21,7 +22,7 @@ struct ioevent { int ioeventfd__init(struct kvm *kvm); int ioeventfd__exit(struct kvm *kvm); -int ioeventfd__add_event(struct ioevent *ioevent); +int ioeventfd__add_event(struct ioevent *ioevent, bool is_pio); int ioeventfd__del_event(u64 addr, u64 datamatch); #endif diff --git a/tools/kvm/ioeventfd.c b/tools/kvm/ioeventfd.c index 9b328cd..97deb06 100644 --- a/tools/kvm/ioeventfd.c +++ b/tools/kvm/ioeventfd.c @@ -117,7 +117,7 @@ int ioeventfd__exit(struct kvm *kvm) return 0; } -int ioeventfd__add_event(struct ioevent *ioevent) +int ioeventfd__add_event(struct ioevent *ioevent, bool is_pio) { struct kvm_ioeventfd kvm_ioevent; struct epoll_event epoll_event; @@ -135,13 +135,16 @@ int ioeventfd__add_event(struct ioevent *ioevent) event = new_ioevent->fd; kvm_ioevent = (struct kvm_ioeventfd) { - .addr = ioevent->io_addr, - .len = ioevent->io_len, - .datamatch = ioevent->datamatch, - .fd = event, - .flags = KVM_IOEVENTFD_FLAG_PIO | KVM_IOEVENTFD_FLAG_DATAMATCH, + .addr = ioevent->io_addr, + .len = ioevent->io_len, + .datamatch = ioevent->datamatch, + .fd = event, + .flags = KVM_IOEVENTFD_FLAG_DATAMATCH, }; + if (is_pio) + kvm_ioevent.flags |= KVM_IOEVENTFD_FLAG_PIO; + r = ioctl(ioevent->fn_kvm->vm_fd, KVM_IOEVENTFD, &kvm_ioevent); if (r) { r = -errno; @@ -149,8 +152,8 @@ int ioeventfd__add_event(struct ioevent *ioevent) } epoll_event = (struct epoll_event) { - .events = EPOLLIN, - .data.ptr = new_ioevent, + .events = EPOLLIN, + .data.ptr = new_ioevent, }; r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, event, &epoll_event); diff --git a/tools/kvm/virtio/pci.c b/tools/kvm/virtio/pci.c index 5a3cad8..529e30d 100644 --- a/tools/kvm/virtio/pci.c +++ b/tools/kvm/virtio/pci.c @@ -52,7 +52,7 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_trans *vtra .fd = eventfd(0, 0), }; - r = ioeventfd__add_event(&ioevent); + r = ioeventfd__add_event(&ioevent, true); if (r) return r; -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html