public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Vadim Rozenfeld <vrozenfe@redhat.com>
To: kvm@vger.kernel.org
Cc: Avi Kivity <avi@redhat.com>, Vadim Rozenfeld <vrozenfe@redhat.com>
Subject: [RFC PATCH 5/7] [hyper-v] hyper-v helper functions
Date: Sun,  9 Oct 2011 20:52:53 +0200	[thread overview]
Message-ID: <1318186375-27672-6-git-send-email-vrozenfe@redhat.com> (raw)
In-Reply-To: <1318186375-27672-1-git-send-email-vrozenfe@redhat.com>

---
 hyperv.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 hyperv.h |    7 +++++++
 2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/hyperv.c b/hyperv.c
index a17f879..57915b9 100644
--- a/hyperv.c
+++ b/hyperv.c
@@ -3,6 +3,10 @@
 #include "qemu-option.h"
 #include "qemu-config.h"
 
+static int hyperv_apic;
+static int hyperv_wd;
+static int hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
+
 void hyperv_init(void)
 {
     QemuOpts *opts = QTAILQ_FIRST(&qemu_hyperv_opts.head);
@@ -10,6 +14,46 @@ void hyperv_init(void)
     if (!opts) {
         return;
     }
+
+    hyperv_spinlock_attempts = qemu_opt_get_number(opts, "spinlock", 
+                                                   HYPERV_SPINLOCK_NEVER_RETRY
+                                                  );
+    hyperv_wd = qemu_opt_get_bool(opts, "wd", 0);
+    hyperv_apic = qemu_opt_get_bool(opts, "vapic", 0);
+
+}
+
+int hyperv_enabled(void)
+{
+    return hyperv_hypercall_available() | hyperv_relaxed_timing();
+}
+
+int hyperv_hypercall_available(void)
+{
+    if (hyperv_apic ||
+        (hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY)) {
+      return 1;
+    }
+    return 0;
+}
+
+int hyperv_relaxed_timing(void)
+{
+    return !hyperv_wd;
+}
+
+int hyperv_apic_recommended(void)
+{
+#ifdef KVM_CAP_IRQCHIP
+    return hyperv_apic;
+#else
+    return 0;
+#endif
+}
+
+int hyperv_spinlock_retries(void)
+{
+    return hyperv_spinlock_attempts;
 }
 
 static void hyperv_initialize(void)
diff --git a/hyperv.h b/hyperv.h
index eaf974a..27d2e6e 100644
--- a/hyperv.h
+++ b/hyperv.h
@@ -6,7 +6,14 @@
 
 #include <asm/hyperv.h>
 
+#define HYPERV_SPINLOCK_NEVER_RETRY             0xFFFFFFFF
+
 void hyperv_init(void);
+int hyperv_enabled(void);
+int hyperv_hypercall_available(void);
+int hyperv_relaxed_timing(void);
+int hyperv_apic_recommended(void);
+int hyperv_spinlock_retries(void);
 
 #endif /* QEMU_HW_HYPERV_H */
 
-- 
1.7.4.4


  parent reply	other threads:[~2011-10-09 18:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-09 18:52 [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Vadim Rozenfeld
2011-10-09 18:52 ` [RFC PATCH 1/7] [hyper-v] Add hyper-v parameters block Vadim Rozenfeld
2011-10-10  6:54   ` Jan Kiszka
2011-10-10  9:40     ` Vadim Rozenfeld
2011-10-10 10:25       ` Jan Kiszka
2011-10-11  7:35   ` Paolo Bonzini
2011-10-11  7:42     ` Paolo Bonzini
2011-10-09 18:52 ` [RFC PATCH 2/7] [hyper-v] add hyper-v placeholders Vadim Rozenfeld
2011-10-11  7:40   ` Paolo Bonzini
2011-10-09 18:52 ` [RFC PATCH 3/7] [hyper-v] make Hyper-V option configurable Vadim Rozenfeld
2011-10-10  6:54   ` Jan Kiszka
2011-10-09 18:52 ` [RFC PATCH 4/7] [hyper-v] hyper-v parameters Vadim Rozenfeld
2011-10-09 18:52 ` Vadim Rozenfeld [this message]
2011-10-09 19:01   ` [RFC PATCH 5/7] [hyper-v] hyper-v helper functions Alon Levy
2011-10-10  6:45     ` Vadim Rozenfeld
2011-10-09 18:52 ` [RFC PATCH 6/7] [hyper-v] parse hyper-v parameters Vadim Rozenfeld
2011-10-09 18:52 ` [RFC PATCH 7/7] [hyper-v] init hyper-v cpuid leafs Vadim Rozenfeld
2011-10-11  7:38   ` Paolo Bonzini
2011-10-11 13:46     ` Vadim Rozenfeld
2011-10-11 15:52       ` Paolo Bonzini
2011-10-11 16:09         ` Vadim Rozenfeld
2011-10-11 16:17           ` Paolo Bonzini
2011-10-10  6:53 ` [RFC PATCH 0/7] Initial support for Microsoft Hyper-V Jan Kiszka
2011-10-10  9:39   ` Vadim Rozenfeld

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=1318186375-27672-6-git-send-email-vrozenfe@redhat.com \
    --to=vrozenfe@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    /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