kvm tools: ioeventfd: replace bool parameters to __add_event with flags
PATCH 1/1 kvm tools: ioeventfd: replace bool parameters to __add_event with flags
A recent fix to virtio MMIO (72a7541ce305 ["kvm tools: virtio-mmio:init_ioeventfd should use MMIO for ioeventfd__add_event()"]) highlighted the confusing parameters expected by ioeventfd__add_event.
As per Pekka's suggestion, replace the bool parameters to this function with a single `flags' argument instead.
Cc Ying-Shiuan Pan <[email protected]>
Signed-off-by Will Deacon <[email protected]>
--- tools/kvm/include/kvm/ioeventfd.h | 5 ++++- tools/kvm/ioeventfd.c | 6 +++--- tools/kvm/virtio/mmio.c | 4 ++-- tools/kvm/virtio/pci.c | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-)
tools/kvm/include/kvm/ioeventfd.h +4 -1
@@ -20,9 +20,12 @@ struct ioevent { struct list_head list; }; +#define IOEVENTFD_FLAG_PIO (1 << 0) +#define IOEVENTFD_FLAG_USER_POLL (1 << 1) +int ioeventfd__init (struct kvm *kvm);int ioeventfd__exit (struct kvm *kvm); -int ioeventfd__add_event (struct ioevent *ioevent,bool is_pio,bool poll_in_userspace); +int ioeventfd__add_event (struct ioevent *ioevent,int flags);int ioeventfd__del_event (u64 addr,u64 datamatch);#endif
tools/kvm/ioeventfd.c +3 -3
@@ -120,7 +120,7 @@ int ioeventfd__exit(struct kvm *kvm) }base_exit (ioeventfd__exit); -int ioeventfd__add_event (struct ioevent *ioevent,bool is_pio,bool poll_in_userspace) +int ioeventfd__add_event (struct ioevent *ioevent,int flags) {struct kvm_ioeventfd kvm_ioevent;struct epoll_event epoll_event;
@@ -145,7 +145,7 @@ int ioeventfd__add_event(struct ioevent *ioevent, bool is_pio, bool poll_in_user .flags = KVM_IOEVENTFD_FLAG_DATAMATCH, }; -if (is_pio) +if (flags &IOEVENTFD_FLAG_PIO ) kvm_ioevent.flags |=KVM_IOEVENTFD_FLAG_PIO ; r =ioctl (ioevent->fn_kvm->vm_fd,KVM_IOEVENTFD , &kvm_ioevent);
@@ -154,7 +154,7 @@ int ioeventfd__add_event(struct ioevent *ioevent, bool is_pio, bool poll_in_user goto cleanup; } -if (!poll_in_userspace) +if (!(flags &IOEVENTFD_FLAG_USER_POLL ))return 0 ; epoll_event = (struct epoll_event ) {
tools/kvm/virtio/mmio.c +2 -2
@@ -55,10 +55,10 @@ static int virtio_mmio_init_ioeventfd(struct kvm *kvm,* Vhost will poll the eventfd in host kernel side, * no need to poll in userspace. */ - err =ioeventfd__add_event (&ioevent, false, false); + err =ioeventfd__add_event (&ioevent,0 ); else/* Need to poll in userspace. */ - err =ioeventfd__add_event (&ioevent, false, true); + err =ioeventfd__add_event (&ioevent,IOEVENTFD_FLAG_USER_POLL );if (err)return err;
tools/kvm/virtio/pci.c +3 -2
@@ -46,10 +46,11 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde* Vhost will poll the eventfd in host kernel side, * no need to poll in userspace. */ - r =ioeventfd__add_event (&ioevent, true, false); + r =ioeventfd__add_event (&ioevent,IOEVENTFD_FLAG_PIO ); else/* Need to poll in userspace. */ - r =ioeventfd__add_event (&ioevent, true, true); + r =ioeventfd__add_event (&ioevent,IOEVENTFD_FLAG_PIO | +IOEVENTFD_FLAG_USER_POLL );if (r)return r;
Signature · 1 line
1.8.2.2
Pekka Enberg
AppliedQuoted 9 lines · Will Deacon
A recent fix to virtio MMIO (
72a7541ce305["kvm tools: virtio-mmio:init_ioeventfdshould use MMIO forioeventfd__add_event()"]) highlighted the confusing parameters expected byioeventfd__add_event.As per Pekka's suggestion, replace the bool parameters to this function with a single `flags' argument instead.
Cc Ying-Shiuan Pan <[email protected]>Signed-off-by Will Deacon <[email protected]>
Applied, thanks a lot!