From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alon Levy Subject: Re: [RFC PATCH 5/7] [hyper-v] hyper-v helper functions Date: Sun, 9 Oct 2011 21:01:00 +0200 Message-ID: <20111009190100.GA2550@bow.tlv.redhat.com> References: <1318186375-27672-1-git-send-email-vrozenfe@redhat.com> <1318186375-27672-6-git-send-email-vrozenfe@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, Avi Kivity To: Vadim Rozenfeld Return-path: Received: from mx1.redhat.com ([209.132.183.28]:20548 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814Ab1JITD3 (ORCPT ); Sun, 9 Oct 2011 15:03:29 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p99J3TQn005912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 9 Oct 2011 15:03:29 -0400 Content-Disposition: inline In-Reply-To: <1318186375-27672-6-git-send-email-vrozenfe@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Oct 09, 2011 at 08:52:53PM +0200, Vadim Rozenfeld wrote: > --- > 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(); Shouldn't this be a logical or? > +} > + > +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 > > +#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 > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html