diff mbox

[1/7] Only call kvm_set_irqfd() if CONFIG_KVM is defined

Message ID 1276599879-22749-2-git-send-email-Jes.Sorensen@redhat.com
State New
Headers show

Commit Message

Jes Sorensen June 15, 2010, 11:04 a.m. UTC
From: Jes Sorensen <Jes.Sorensen@redhat.com>

Only call kvm_set_irqfd() if CONFIG_KVM is defined to avoid breaking
the build for non x86.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 hw/virtio-pci.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Comments

Paolo Bonzini June 15, 2010, 1:31 p.m. UTC | #1
On 06/15/2010 01:04 PM, Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>
> Only call kvm_set_irqfd() if CONFIG_KVM is defined to avoid breaking
> the build for non x86.

You can just add a stub to kvm-stub.c that returns -ENOSYS.

Paolo
Jes Sorensen June 15, 2010, 1:40 p.m. UTC | #2
On 06/15/10 15:31, Paolo Bonzini wrote:
> On 06/15/2010 01:04 PM, Jes.Sorensen@redhat.com wrote:
>> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>>
>> Only call kvm_set_irqfd() if CONFIG_KVM is defined to avoid breaking
>> the build for non x86.
> 
> You can just add a stub to kvm-stub.c that returns -ENOSYS.
> 
> Paolo

It's more than that, the code also uses bits in the msix code that isn't
globally available.

Cheers,
Jes
Paolo Bonzini June 15, 2010, 1:48 p.m. UTC | #3
On 06/15/2010 03:40 PM, Jes Sorensen wrote:
> On 06/15/10 15:31, Paolo Bonzini wrote:
>> On 06/15/2010 01:04 PM, Jes.Sorensen@redhat.com wrote:
>>> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>>>
>>> Only call kvm_set_irqfd() if CONFIG_KVM is defined to avoid breaking
>>> the build for non x86.
>>
>> You can just add a stub to kvm-stub.c that returns -ENOSYS.
>>
>> Paolo
>
> It's more than that, the code also uses bits in the msix code that isn't
> globally available.

I see now.  BTW, my eventnotifier series conflicts with this part of 
qemu-kvm, so it's probably better if I work that series out in qemu-kvm 
first and then upstream.  As I would touch this code anyway, I think 
your patch is fine even if it were be only a stopgap measure.

Maybe the right fix, which I could include in my series, is to change 
kvm_set_irqfd's calling convention to be like this:

     int r = kvm_set_irqfd(&dev->msix_irq_entries[vector],
                           event_notifier_get_fd(notifier),
                           !masked);

and extract the gsi in the function.  Michael, does this make any sense?

Paolo
Michael S. Tsirkin June 15, 2010, 2:58 p.m. UTC | #4
On Tue, Jun 15, 2010 at 03:48:50PM +0200, Paolo Bonzini wrote:
> On 06/15/2010 03:40 PM, Jes Sorensen wrote:
>> On 06/15/10 15:31, Paolo Bonzini wrote:
>>> On 06/15/2010 01:04 PM, Jes.Sorensen@redhat.com wrote:
>>>> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>>>>
>>>> Only call kvm_set_irqfd() if CONFIG_KVM is defined to avoid breaking
>>>> the build for non x86.
>>>
>>> You can just add a stub to kvm-stub.c that returns -ENOSYS.
>>>
>>> Paolo
>>
>> It's more than that, the code also uses bits in the msix code that isn't
>> globally available.
>
> I see now.  BTW, my eventnotifier series conflicts with this part of  
> qemu-kvm, so it's probably better if I work that series out in qemu-kvm  
> first and then upstream.  As I would touch this code anyway, I think  
> your patch is fine even if it were be only a stopgap measure.
>
> Maybe the right fix, which I could include in my series, is to change  
> kvm_set_irqfd's calling convention to be like this:
>
>     int r = kvm_set_irqfd(&dev->msix_irq_entries[vector],
>                           event_notifier_get_fd(notifier),
>                           !masked);
>
> and extract the gsi in the function.  Michael, does this make any sense?
>
> Paolo

I'm fine with this change.
diff mbox

Patch

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index c3c1fcd..926b8e1 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -431,6 +431,7 @@  static void virtio_pci_guest_notifier_read(void *opaque)
 static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector,
                                     void *opaque, int masked)
 {
+#ifdef CONFIG_KVM
     VirtQueue *vq = opaque;
     EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
     int r = kvm_set_irqfd(dev->msix_irq_entries[vector].gsi,
@@ -447,6 +448,9 @@  static int virtio_pci_mask_notifier(PCIDevice *dev, unsigned vector,
                             NULL, NULL, NULL);
     }
     return 0;
+#else
+    return -ENOSYS;
+#endif
 }
 
 static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign)