diff mbox

qemu-kvm: fix no gsi routing warning

Message ID 20090921145136.GA29405@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael S. Tsirkin Sept. 21, 2009, 2:51 p.m. UTC
When running on host kernel which does not let the guest manupulate the
gsi routing, and user requested MSI-X to be enabled, we get the
following warnings:
kvm_msix_add: kvm_get_irq_route_gsi failed: No space left on device
kvm_msix_update: kvm_update_routing_entry failed: Invalid argument

What really happens is that we report a failure to allocate
a vector to the guest, it will retry and finally disable MSI.

Make this clearer by checking for gsi capability and warning about
the error in a readable form.

Reported-by: Juan Quintela <quintela@redhat.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/msix.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

Comments

Avi Kivity Sept. 21, 2009, 2:56 p.m. UTC | #1
On 09/21/2009 05:51 PM, Michael S. Tsirkin wrote:
> When running on host kernel which does not let the guest manupulate the
> gsi routing, and user requested MSI-X to be enabled, we get the
> following warnings:
> kvm_msix_add: kvm_get_irq_route_gsi failed: No space left on device
> kvm_msix_update: kvm_update_routing_entry failed: Invalid argument
>
> What really happens is that we report a failure to allocate
> a vector to the guest, it will retry and finally disable MSI.
>
> Make this clearer by checking for gsi capability and warning about
> the error in a readable form.
>
>    

Can we disable msix (or, abort qemu at startup and request that the user 
disable msix) if the kernel doesn't provide required features?  It's 
better than a runtime error.
Michael S. Tsirkin Sept. 21, 2009, 7:50 p.m. UTC | #2
On Mon, Sep 21, 2009 at 05:56:13PM +0300, Avi Kivity wrote:
> On 09/21/2009 05:51 PM, Michael S. Tsirkin wrote:
>> When running on host kernel which does not let the guest manupulate the
>> gsi routing, and user requested MSI-X to be enabled, we get the
>> following warnings:
>> kvm_msix_add: kvm_get_irq_route_gsi failed: No space left on device
>> kvm_msix_update: kvm_update_routing_entry failed: Invalid argument
>>
>> What really happens is that we report a failure to allocate
>> a vector to the guest, it will retry and finally disable MSI.
>>
>> Make this clearer by checking for gsi capability and warning about
>> the error in a readable form.
>>
>>    
>
> Can we disable msix

What we do effectively disables msix.

> (or, abort qemu at startup and request that the user  
> disable msix) if the kernel doesn't provide required features?
>  It's  
> better than a runtime error.

Note it's a warning, not an error.

We have a similar failure mode when we run out of gsi entries, and that
can not be checked upfront.  I prefer having it fail in the same way, so
that this failure path in guest drivers is excercised and tested.

> -- 
> error compiling committee.c: too many arguments to function
--
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
Avi Kivity Sept. 23, 2009, 9:04 a.m. UTC | #3
On 09/21/2009 10:50 PM, Michael S. Tsirkin wrote:
> On Mon, Sep 21, 2009 at 05:56:13PM +0300, Avi Kivity wrote:
>    
>> On 09/21/2009 05:51 PM, Michael S. Tsirkin wrote:
>>      
>>> When running on host kernel which does not let the guest manupulate the
>>> gsi routing, and user requested MSI-X to be enabled, we get the
>>> following warnings:
>>> kvm_msix_add: kvm_get_irq_route_gsi failed: No space left on device
>>> kvm_msix_update: kvm_update_routing_entry failed: Invalid argument
>>>
>>> What really happens is that we report a failure to allocate
>>> a vector to the guest, it will retry and finally disable MSI.
>>>
>>> Make this clearer by checking for gsi capability and warning about
>>> the error in a readable form.
>>>
>>>
>>>        
>> Can we disable msix
>>      
> What we do effectively disables msix.
>
>    
>> (or, abort qemu at startup and request that the user
>> disable msix) if the kernel doesn't provide required features?
>>   It's
>> better than a runtime error.
>>      
> Note it's a warning, not an error.
>
> We have a similar failure mode when we run out of gsi entries, and that
> can not be checked upfront.  I prefer having it fail in the same way, so
> that this failure path in guest drivers is excercised and tested.
>    

I see, applied the patch, thanks.
diff mbox

Patch

diff --git a/hw/msix.c b/hw/msix.c
index fcd425f..5695582 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -129,6 +129,13 @@  static int kvm_msix_add(PCIDevice *dev, unsigned vector)
     struct kvm_irq_routing_entry *entry = dev->msix_irq_entries + vector;
     int r;
 
+    if (!kvm_has_gsi_routing(kvm_context)) {
+        fprintf(stderr, "Warning: no MSI-X support found. "
+                "At least kernel 2.6.30 is required for MSI-X support.\n"
+               );
+        return -EOPNOTSUPP;
+    }
+
     r = kvm_get_irq_route_gsi(kvm_context);
     if (r < 0) {
         fprintf(stderr, "%s: kvm_get_irq_route_gsi failed: %s\n", __func__, strerror(-r));