summaryrefslogtreecommitdiff
path: root/kvm-all.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2010-03-17 13:07:54 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2010-04-01 13:56:43 -0500
commitca82180603446831187203383de4b5ede4e2c346 (patch)
tree38b5d43ad938dc0a7a7fcd7e14b8023ffa57bfe6 /kvm-all.c
parent95d528a2fe9f1eaec11dc3256dc9dec49b557990 (diff)
kvm: add API to set ioeventfd
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 <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'kvm-all.c')
-rw-r--r--kvm-all.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/kvm-all.c b/kvm-all.c
index 40b5a51f5..6324635d3 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1151,3 +1151,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