Received: from eggs.gnu.org ([208.118.235.92]:56090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIbCl-0005X4-GN for qemu-devel@nongnu.org; Thu, 21 Mar 2013 04:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIbCg-000855-CT for qemu-devel@nongnu.org; Thu, 21 Mar 2013 04:50:35 -0400 Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=iso-8859-1 From: Alexander Graf In-Reply-To: <514AC8A3.9020705@siemens.com> Date: Thu, 21 Mar 2013 09:50:27 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <4F5EB7F4-BB11-4E73-93CF-C101FDCA5927@suse.de> References: <1360823521-32306-1-git-send-email-scottwood@freescale.com> <1360823521-32306-6-git-send-email-scottwood@freescale.com> <9EBF5CA0-AEA6-444E-8893-44F97A848C35@suse.de> <514AC8A3.9020705@siemens.com> Subject: Re: [Qemu-devel] [RFC ppc-next PATCH 5/6] kvm: export result of irqchip config check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Scott Wood , "qemu-ppc@nongnu.org list:PowerPC" , qemu-devel qemu-devel On 21.03.2013, at 09:45, Jan Kiszka wrote: > On 2013-03-21 09:34, Alexander Graf wrote: >>=20 >> On 14.02.2013, at 07:32, Scott Wood wrote: >>=20 >>> This allows platform code to register in-kernel irqchips that >>> don't use the legacy KVM_CAP_IRQCHIP/KVM_CREATE_IRQCHIP interface. >>>=20 >>> Signed-off-by: Scott Wood >>> --- >>> include/sysemu/kvm.h | 10 ++++++++++ >>> kvm-all.c | 11 +++++++++-- >>> 2 files changed, 19 insertions(+), 2 deletions(-) >>>=20 >>> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h >>> index f2d97b5..b9a8701 100644 >>> --- a/include/sysemu/kvm.h >>> +++ b/include/sysemu/kvm.h >>> @@ -45,6 +45,7 @@ extern bool kvm_async_interrupts_allowed; >>> extern bool kvm_irqfds_allowed; >>> extern bool kvm_msi_via_irqfd_allowed; >>> extern bool kvm_gsi_routing_allowed; >>> +extern bool kvm_irqchip_wanted; >>>=20 >>> #if defined CONFIG_KVM || !defined NEED_CPU_H >>> #define kvm_enabled() (kvm_allowed) >>> @@ -97,6 +98,14 @@ extern bool kvm_gsi_routing_allowed; >>> */ >>> #define kvm_gsi_routing_enabled() (kvm_gsi_routing_allowed) >>>=20 >>> +/** >>> + * kvm_irqchip_wanted >>> + * >>> + * Returns: true if the user requested that an in-kernel IRQ chip = be >>> + * used, regardless of whether support has been detected. >>> + */ >>> +#define kvm_irqchip_wanted() (kvm_irqchip_wanted) >>> + >>> #else >>> #define kvm_enabled() (0) >>> #define kvm_irqchip_in_kernel() (false) >>> @@ -104,6 +113,7 @@ extern bool kvm_gsi_routing_allowed; >>> #define kvm_irqfds_enabled() (false) >>> #define kvm_msi_via_irqfd_enabled() (false) >>> #define kvm_gsi_routing_allowed() (false) >>> +#define kvm_irqchip_wanted() (false) >>> #endif >>>=20 >>> struct kvm_run; >>> diff --git a/kvm-all.c b/kvm-all.c >>> index 04ec2d5..13a628d 100644 >>> --- a/kvm-all.c >>> +++ b/kvm-all.c >>> @@ -109,6 +109,7 @@ bool kvm_async_interrupts_allowed; >>> bool kvm_irqfds_allowed; >>> bool kvm_msi_via_irqfd_allowed; >>> bool kvm_gsi_routing_allowed; >>> +bool kvm_irqchip_wanted; >>>=20 >>> static const KVMCapabilityInfo kvm_required_capabilites[] =3D { >>> KVM_CAP_INFO(USER_MEMORY), >>> @@ -1205,8 +1206,14 @@ static int kvm_irqchip_create(KVMState *s) >>>=20 >>> if (QTAILQ_EMPTY(&list->head) || >>> !qemu_opt_get_bool(QTAILQ_FIRST(&list->head), >>> - "kernel_irqchip", true) || >>> - !kvm_check_extension(s, KVM_CAP_IRQCHIP)) { >>> + "kernel_irqchip", true)) { >>> + return 0; >>> + } >>> + >>> + kvm_irqchip_wanted =3D true; >>> + >>> + /* Platform code may have a different way of enabling an IRQ = chip */ >>> + if (!kvm_check_extension(s, KVM_CAP_IRQCHIP)) { >>=20 >> Does x86 have the required checks then to make sure it has the CAP? >=20 > To my understanding, x86 won't evaluate this new flag but continue to > bail out from this service early. >=20 > However, invoking something that is called "create" to just end up = with > a set flag "wanted" and then do the creation elsewhere is not a very > beautiful design. Yeah. This should probably be kvm_irqchip_wanted(KVMState *s) { if (!kvm_arch_irqchip_available(s)) return false; =20 return qemu_opt_get_bool("kernel_irqchip", true); } with kvm_arch_irqchip_available checking for KVM_CAP_IRQCHIP on x86 and = the respective device creation capability on ppc. Alex