diff mbox

[RFC,ppc-next,5/6] kvm: export result of irqchip config check

Message ID 1360823521-32306-6-git-send-email-scottwood@freescale.com
State New
Headers show

Commit Message

Scott Wood Feb. 14, 2013, 6:32 a.m. UTC
This allows platform code to register in-kernel irqchips that
don't use the legacy KVM_CAP_IRQCHIP/KVM_CREATE_IRQCHIP interface.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 include/sysemu/kvm.h |   10 ++++++++++
 kvm-all.c            |   11 +++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

Comments

Alexander Graf March 21, 2013, 8:34 a.m. UTC | #1
On 14.02.2013, at 07:32, Scott Wood wrote:

> This allows platform code to register in-kernel irqchips that
> don't use the legacy KVM_CAP_IRQCHIP/KVM_CREATE_IRQCHIP interface.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
> include/sysemu/kvm.h |   10 ++++++++++
> kvm-all.c            |   11 +++++++++--
> 2 files changed, 19 insertions(+), 2 deletions(-)
> 
> 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;
> 
> #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)
> 
> +/**
> + * 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
> 
> 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;
> 
> static const KVMCapabilityInfo kvm_required_capabilites[] = {
>     KVM_CAP_INFO(USER_MEMORY),
> @@ -1205,8 +1206,14 @@ static int kvm_irqchip_create(KVMState *s)
> 
>     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 = true;
> +
> +    /* Platform code may have a different way of enabling an IRQ chip */
> +    if (!kvm_check_extension(s, KVM_CAP_IRQCHIP)) {

Does x86 have the required checks then to make sure it has the CAP?


Alex

>         return 0;
>     }
> 
> -- 
> 1.7.9.5
> 
>
Jan Kiszka March 21, 2013, 8:45 a.m. UTC | #2
On 2013-03-21 09:34, Alexander Graf wrote:
> 
> On 14.02.2013, at 07:32, Scott Wood wrote:
> 
>> This allows platform code to register in-kernel irqchips that
>> don't use the legacy KVM_CAP_IRQCHIP/KVM_CREATE_IRQCHIP interface.
>>
>> Signed-off-by: Scott Wood <scottwood@freescale.com>
>> ---
>> include/sysemu/kvm.h |   10 ++++++++++
>> kvm-all.c            |   11 +++++++++--
>> 2 files changed, 19 insertions(+), 2 deletions(-)
>>
>> 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;
>>
>> #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)
>>
>> +/**
>> + * 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
>>
>> 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;
>>
>> static const KVMCapabilityInfo kvm_required_capabilites[] = {
>>     KVM_CAP_INFO(USER_MEMORY),
>> @@ -1205,8 +1206,14 @@ static int kvm_irqchip_create(KVMState *s)
>>
>>     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 = true;
>> +
>> +    /* Platform code may have a different way of enabling an IRQ chip */
>> +    if (!kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
> 
> Does x86 have the required checks then to make sure it has the CAP?

To my understanding, x86 won't evaluate this new flag but continue to
bail out from this service early.

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.

Jan
Alexander Graf March 21, 2013, 8:50 a.m. UTC | #3
On 21.03.2013, at 09:45, Jan Kiszka wrote:

> On 2013-03-21 09:34, Alexander Graf wrote:
>> 
>> On 14.02.2013, at 07:32, Scott Wood wrote:
>> 
>>> This allows platform code to register in-kernel irqchips that
>>> don't use the legacy KVM_CAP_IRQCHIP/KVM_CREATE_IRQCHIP interface.
>>> 
>>> Signed-off-by: Scott Wood <scottwood@freescale.com>
>>> ---
>>> include/sysemu/kvm.h |   10 ++++++++++
>>> kvm-all.c            |   11 +++++++++--
>>> 2 files changed, 19 insertions(+), 2 deletions(-)
>>> 
>>> 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;
>>> 
>>> #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)
>>> 
>>> +/**
>>> + * 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
>>> 
>>> 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;
>>> 
>>> static const KVMCapabilityInfo kvm_required_capabilites[] = {
>>>    KVM_CAP_INFO(USER_MEMORY),
>>> @@ -1205,8 +1206,14 @@ static int kvm_irqchip_create(KVMState *s)
>>> 
>>>    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 = true;
>>> +
>>> +    /* Platform code may have a different way of enabling an IRQ chip */
>>> +    if (!kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
>> 
>> Does x86 have the required checks then to make sure it has the CAP?
> 
> To my understanding, x86 won't evaluate this new flag but continue to
> bail out from this service early.
> 
> 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;
    
    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
diff mbox

Patch

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;
 
 #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)
 
+/**
+ * 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
 
 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;
 
 static const KVMCapabilityInfo kvm_required_capabilites[] = {
     KVM_CAP_INFO(USER_MEMORY),
@@ -1205,8 +1206,14 @@  static int kvm_irqchip_create(KVMState *s)
 
     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 = true;
+
+    /* Platform code may have a different way of enabling an IRQ chip */
+    if (!kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
         return 0;
     }