kvm tools: Add is_pio flag to ioeventfd__add_event

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@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
Asias He
2012-04-08 06:47:17 +08:00
committed by Will Deacon
parent 4d1fa72f0e
commit 9ff913391e
3 changed files with 14 additions and 10 deletions
+2 -1
View File
@@ -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
+11 -8
View File
@@ -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);
+1 -1
View File
@@ -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;