From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vadim Rozenfeld Subject: Re: [RFC PATCH 5/7] [hyper-v] hyper-v helper functions Date: Mon, 10 Oct 2011 08:45:40 +0200 Message-ID: <1318229141.2706.0.camel@vadimr.dell> References: <1318186375-27672-1-git-send-email-vrozenfe@redhat.com> <1318186375-27672-6-git-send-email-vrozenfe@redhat.com> <20111009190100.GA2550@bow.tlv.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Avi Kivity To: Alon Levy Return-path: Received: from mx1.redhat.com ([209.132.183.28]:38047 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750915Ab1JJGpp (ORCPT ); Mon, 10 Oct 2011 02:45:45 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9A6jjxw005335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Oct 2011 02:45:45 -0400 In-Reply-To: <20111009190100.GA2550@bow.tlv.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, 2011-10-09 at 21:01 +0200, Alon Levy wrote: > 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? Sure, thanks. > > > +} > > + > > +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 > -- > 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