Patchwork KVM: Fix compilation on non-x86

login
register
mail settings
Submitter Alexander Graf
Date Jan. 25, 2012, 5:33 p.m.
Message ID <1327512783-29868-1-git-send-email-agraf@suse.de>
Download mbox | patch
Permalink /patch/137807/
State New
Headers show

Comments

Alexander Graf - Jan. 25, 2012, 5:33 p.m.
Commit 84b058d broke compilation for KVM on non-x86 targets, which
don't have KVM_CAP_IRQ_ROUTING defined.

Fix by not using the unavailable constant when it's not around.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 kvm-all.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
Jan Kiszka - Jan. 25, 2012, 5:40 p.m.
On 2012-01-25 18:33, Alexander Graf wrote:
> Commit 84b058d broke compilation for KVM on non-x86 targets, which
> don't have KVM_CAP_IRQ_ROUTING defined.
> 
> Fix by not using the unavailable constant when it's not around.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  kvm-all.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/kvm-all.c b/kvm-all.c
> index e411d3c..831f39a 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -1305,7 +1305,11 @@ int kvm_has_many_ioeventfds(void)
>  
>  int kvm_has_gsi_routing(void)
>  {
> +#ifdef KVM_CAP_IRQ_ROUTING
>      return kvm_check_extension(kvm_state, KVM_CAP_IRQ_ROUTING);
> +#else
> +    return false;
> +#endif
>  }
>  
>  int kvm_allows_irq0_override(void)

Yep, thanks.

Jan
Alexander Graf - Jan. 25, 2012, 5:45 p.m.
On 01/25/2012 06:40 PM, Jan Kiszka wrote:
> On 2012-01-25 18:33, Alexander Graf wrote:
>> Commit 84b058d broke compilation for KVM on non-x86 targets, which
>> don't have KVM_CAP_IRQ_ROUTING defined.
>>
>> Fix by not using the unavailable constant when it's not around.
>>
>> Signed-off-by: Alexander Graf<agraf@suse.de>
>> ---
>>   kvm-all.c |    4 ++++
>>   1 files changed, 4 insertions(+), 0 deletions(-)
>>
>> diff --git a/kvm-all.c b/kvm-all.c
>> index e411d3c..831f39a 100644
>> --- a/kvm-all.c
>> +++ b/kvm-all.c
>> @@ -1305,7 +1305,11 @@ int kvm_has_many_ioeventfds(void)
>>
>>   int kvm_has_gsi_routing(void)
>>   {
>> +#ifdef KVM_CAP_IRQ_ROUTING
>>       return kvm_check_extension(kvm_state, KVM_CAP_IRQ_ROUTING);
>> +#else
>> +    return false;
>> +#endif
>>   }
>>
>>   int kvm_allows_irq0_override(void)
> Yep, thanks.

Btw, I really dislike the concept of conditional CAP defines. If a CAP 
isn't available, we get false returned from the kernel anyway. And if a 
CAP is architecture specific, we should rather be #ifdefing on 
TARGET_XXX rather than the CAP.


Alex
Jan Kiszka - Jan. 25, 2012, 5:59 p.m.
On 2012-01-25 18:45, Alexander Graf wrote:
> On 01/25/2012 06:40 PM, Jan Kiszka wrote:
>> On 2012-01-25 18:33, Alexander Graf wrote:
>>> Commit 84b058d broke compilation for KVM on non-x86 targets, which
>>> don't have KVM_CAP_IRQ_ROUTING defined.
>>>
>>> Fix by not using the unavailable constant when it's not around.
>>>
>>> Signed-off-by: Alexander Graf<agraf@suse.de>
>>> ---
>>>   kvm-all.c |    4 ++++
>>>   1 files changed, 4 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/kvm-all.c b/kvm-all.c
>>> index e411d3c..831f39a 100644
>>> --- a/kvm-all.c
>>> +++ b/kvm-all.c
>>> @@ -1305,7 +1305,11 @@ int kvm_has_many_ioeventfds(void)
>>>
>>>   int kvm_has_gsi_routing(void)
>>>   {
>>> +#ifdef KVM_CAP_IRQ_ROUTING
>>>       return kvm_check_extension(kvm_state, KVM_CAP_IRQ_ROUTING);
>>> +#else
>>> +    return false;
>>> +#endif
>>>   }
>>>
>>>   int kvm_allows_irq0_override(void)
>> Yep, thanks.
> 
> Btw, I really dislike the concept of conditional CAP defines. If a CAP
> isn't available, we get false returned from the kernel anyway. And if a
> CAP is architecture specific, we should rather be #ifdefing on
> TARGET_XXX rather than the CAP.

Yes, I hate it generally as well. There are cases (IIRC) where it is
really useless. The use case here is that it allows to disable certain
conceptually generic parts in kvm-all during build time. If it's worth
it, that's a different question.

Jan
Marcelo Tosatti - Feb. 6, 2012, 6:33 p.m.
On Wed, Jan 25, 2012 at 06:33:03PM +0100, Alexander Graf wrote:
> Commit 84b058d broke compilation for KVM on non-x86 targets, which
> don't have KVM_CAP_IRQ_ROUTING defined.
> 
> Fix by not using the unavailable constant when it's not around.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>

Applied, thanks.

Patch

diff --git a/kvm-all.c b/kvm-all.c
index e411d3c..831f39a 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1305,7 +1305,11 @@  int kvm_has_many_ioeventfds(void)
 
 int kvm_has_gsi_routing(void)
 {
+#ifdef KVM_CAP_IRQ_ROUTING
     return kvm_check_extension(kvm_state, KVM_CAP_IRQ_ROUTING);
+#else
+    return false;
+#endif
 }
 
 int kvm_allows_irq0_override(void)