[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCHv6 02/11] kvm: add API to set ioeventfd
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PATCHv6 02/11] kvm: add API to set ioeventfd |
Date: |
Wed, 17 Mar 2010 13:07:54 +0200 |
User-agent: |
Mutt/1.5.19 (2009-01-05) |
Comment on kvm usage: rather than require users to do if (kvm_enabled())
and/or ifdefs, this patch adds an API that, internally, is defined to
stub function on non-kvm build, and checks kvm_enabled for non-kvm
run.
While rest of qemu code still uses if (kvm_enabled()), I think this
approach is cleaner, and we should convert rest of code to it
long term.
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
kvm-all.c | 22 ++++++++++++++++++++++
kvm.h | 16 ++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index 534ead0..f427f73 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1153,3 +1153,25 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t
*sigset)
return r;
}
+
+#ifdef KVM_IOEVENTFD
+int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool
assign)
+{
+ struct kvm_ioeventfd kick = {
+ .datamatch = val,
+ .addr = addr,
+ .len = 2,
+ .flags = KVM_IOEVENTFD_FLAG_DATAMATCH | KVM_IOEVENTFD_FLAG_PIO,
+ .fd = fd,
+ };
+ int r;
+ if (!kvm_enabled())
+ return -ENOSYS;
+ if (!assign)
+ kick.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN;
+ r = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &kick);
+ if (r < 0)
+ return r;
+ return 0;
+}
+#endif
diff --git a/kvm.h b/kvm.h
index fd8d0c1..2dfcb15 100644
--- a/kvm.h
+++ b/kvm.h
@@ -14,10 +14,16 @@
#ifndef QEMU_KVM_H
#define QEMU_KVM_H
+#include <stdbool.h>
+#include <errno.h>
#include "config.h"
#include "qemu-queue.h"
#ifdef CONFIG_KVM
+#include <linux/kvm.h>
+#endif
+
+#ifdef CONFIG_KVM
extern int kvm_allowed;
#define kvm_enabled() (kvm_allowed)
@@ -161,4 +167,14 @@ static inline void cpu_synchronize_post_init(CPUState *env)
}
}
+#if defined(KVM_IOEVENTFD) && defined(CONFIG_KVM)
+int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool
assign);
+#else
+static inline
+int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign)
+{
+ return -ENOSYS;
+}
+#endif
+
#endif
--
1.7.0.18.g0d53a5
- [Qemu-devel] [PATCHv6 00/11] vhost-net: upstream integration, Michael S. Tsirkin, 2010/03/17
- [Qemu-devel] [PATCHv6 01/11] tap: add interface to get device fd, Michael S. Tsirkin, 2010/03/17
- [Qemu-devel] [PATCHv6 02/11] kvm: add API to set ioeventfd,
Michael S. Tsirkin <=
- [Qemu-devel] [PATCHv6 09/11] tap: add vhost/vhostfd options, Michael S. Tsirkin, 2010/03/17
- [Qemu-devel] [PATCHv6 11/11] virtio-net: vhost net support, Michael S. Tsirkin, 2010/03/17
- [Qemu-devel] [PATCHv6 10/11] tap: add API to retrieve vhost net header, Michael S. Tsirkin, 2010/03/17
- [Qemu-devel] [PATCHv6 04/11] virtio: notifier support + APIs for queue fields, Michael S. Tsirkin, 2010/03/17
- [Qemu-devel] [PATCHv6 03/11] notifier: event notifier implementation, Michael S. Tsirkin, 2010/03/17
- [Qemu-devel] [PATCHv6 05/11] virtio: add set_status callback, Michael S. Tsirkin, 2010/03/17
- [Qemu-devel] [PATCHv6 07/11] virtio-pci: fill in notifier support, Michael S. Tsirkin, 2010/03/17
- [Qemu-devel] [PATCHv6 08/11] vhost: vhost net support, Michael S. Tsirkin, 2010/03/17