qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>, qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, kraxel@redhat.com, quintela@redhat.com
Subject: [Qemu-devel] [PATCHv3 02/12] kvm: add API to set ioeventfd
Date: Tue, 2 Mar 2010 20:43:27 +0200	[thread overview]
Message-ID: <b3ba9c1822fc581767f759b56f7e107a43b5bd68.1267555267.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1267555267.git.mst@redhat.com>

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>
---
 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 1a02076..f54af71 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1138,3 +1138,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 a74dfcb..45d087b 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)
@@ -135,4 +141,14 @@ static inline void cpu_synchronize_state(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

  parent reply	other threads:[~2010-03-02 18:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 18:43 [Qemu-devel] [PATCHv3 00/12] vhost-net: upstream integration Michael S. Tsirkin
2010-03-02 18:43 ` [Qemu-devel] [PATCHv3 01/12] tap: add interface to get device fd Michael S. Tsirkin
2010-03-02 18:43 ` Michael S. Tsirkin [this message]
2010-03-02 18:43 ` [Qemu-devel] [PATCHv3 03/12] notifier: event notifier implementation Michael S. Tsirkin
2010-03-02 18:43 ` [Qemu-devel] [PATCHv3 04/12] virtio: add notifier support Michael S. Tsirkin
2010-03-02 18:43 ` [Qemu-devel] [PATCHv3 05/12] virtio: add APIs for queue fields Michael S. Tsirkin
2010-03-02 18:43 ` [Qemu-devel] [PATCHv3 06/12] virtio: add set_status callback Michael S. Tsirkin
2010-03-02 18:43 ` [Qemu-devel] [PATCHv3 07/12] virtio: move typedef to qemu-common Michael S. Tsirkin
2010-03-02 18:43 ` [Qemu-devel] [PATCHv3 08/12] virtio-pci: fill in notifier support Michael S. Tsirkin
2010-03-02 18:44 ` [Qemu-devel] [PATCHv3 09/12] vhost: vhost net support Michael S. Tsirkin
2010-03-02 18:44 ` [Qemu-devel] [PATCHv3 10/12] tap: add vhost/vhostfd options Michael S. Tsirkin
2010-03-02 18:44 ` [Qemu-devel] [PATCHv3 11/12] tap: add API to retrieve vhost net header Michael S. Tsirkin
2010-03-02 18:44 ` [Qemu-devel] [PATCHv3 12/12] virtio-net: vhost net support Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b3ba9c1822fc581767f759b56f7e107a43b5bd68.1267555267.git.mst@redhat.com \
    --to=mst@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).