Skip to contentSkip to conversation

qemu-kvm: fix error handling in msix vector add

PATCH Applied Michael S. Tsirkin 4 participants 6 messages Jul 23, 2009 – Sep 9, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-kvm: fix error handling in msix vector add

When adding a vector fails, the used counter should not be incremented, otherwise on vector change we will try to update the routing entry.

---
 hw/msix.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
hw/msix.c +8 -2
index 5f77dc9..47cbdc7 100644
@@ -502,13 +502,19 @@ void msix_reset(PCIDevice *dev)
 /* Mark vector as used. */
 int msix_vector_use(PCIDevice *dev, unsigned vector)
 {
+    int ret;
     if (vector >= dev->msix_entries_nr)
         return -EINVAL;
-    if (dev->msix_entry_used[vector]++)
+    if (dev->msix_entry_used[vector]) {
         return 0;
+    }
     if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) {
-        return kvm_msix_add(dev, vector);
+        ret = kvm_msix_add(dev, vector);
+        if (ret) {
+            return ret;
+        }
     }
+    ++dev->msix_entry_used[vector];
     return 0;
 }
 
Signature · 1 line
1.6.2.5
#1 lore raw
Quoted 5 lines · Michael S. Tsirkin

When adding a vector fails, the used counter should not be incremented, otherwise on vector change we will try to update the routing entry.

Applied, thanks.

Quoted 36 lines
---
 hw/msix.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
hw/msix.c +8 -2
index 5f77dc9..47cbdc7 100644
@@ -502,13 +502,19 @@ void msix_reset(PCIDevice *dev)
 /* Mark vector as used. */
 int msix_vector_use(PCIDevice *dev, unsigned vector)
 {
+    int ret;
     if (vector >= dev->msix_entries_nr)
         return -EINVAL;
-    if (dev->msix_entry_used[vector]++)
+    if (dev->msix_entry_used[vector]) {
         return 0;
+    }
     if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) {
-        return kvm_msix_add(dev, vector);
+        ret = kvm_msix_add(dev, vector);
+        if (ret) {
+            return ret;
+        }
     }
+    ++dev->msix_entry_used[vector];
     return 0;
 }
 
Signature · 5 lines
1.6.2.5
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 8 lines · Marcelo Tosatti
Quoted 5 lines · Michael S. Tsirkin

When adding a vector fails, the used counter should not be incremented, otherwise on vector change we will try to update the routing entry.

Applied, thanks.

Should I see this in qemu-kvm master?
It does not seem to be there.

Quoted 36 lines
Quoted 36 lines
---
 hw/msix.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
hw/msix.c +8 -2
index 5f77dc9..47cbdc7 100644
@@ -502,13 +502,19 @@ void msix_reset(PCIDevice *dev)
 /* Mark vector as used. */
 int msix_vector_use(PCIDevice *dev, unsigned vector)
 {
+    int ret;
     if (vector >= dev->msix_entries_nr)
         return -EINVAL;
-    if (dev->msix_entry_used[vector]++)
+    if (dev->msix_entry_used[vector]) {
         return 0;
+    }
     if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) {
-        return kvm_msix_add(dev, vector);
+        ret = kvm_msix_add(dev, vector);
+        if (ret) {
+            return ret;
+        }
     }
+    ++dev->msix_entry_used[vector];
     return 0;
 }
 
Signature · 5 lines
1.6.2.5
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Marcelo Tosatti
Quoted 4 lines · Michael S. Tsirkin

When adding a vector fails, the used counter should not be incremented, otherwise on vector change we will try to update the routing entry.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Applied, thanks.

Should I see this in qemu-kvm master?
It does not seem to be there.

Hum, forgot to push. Will handle it. Sorry for the mess.

Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
---
 hw/msix.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
hw/msix.c +8 -2
index 5f77dc9..47cbdc7 100644
@@ -502,13 +502,19 @@ void msix_reset(PCIDevice *dev)
 /* Mark vector as used. */
 int msix_vector_use(PCIDevice *dev, unsigned vector)
 {
+    int ret;
     if (vector >= dev->msix_entries_nr)
         return -EINVAL;
-    if (dev->msix_entry_used[vector]++)
+    if (dev->msix_entry_used[vector]) {
         return 0;
+    }
     if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) {
-        return kvm_msix_add(dev, vector);
+        ret = kvm_msix_add(dev, vector);
+        if (ret) {
+            return ret;
+        }
     }
+    ++dev->msix_entry_used[vector];
     return 0;
 }
 
Signature · 5 lines
1.6.2.5
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 8 lines · Mark McLoughlin
Quoted 6 lines · Marcelo Tosatti
Quoted 4 lines · Michael S. Tsirkin

When adding a vector fails, the used counter should not be incremented, otherwise on vector change we will try to update the routing entry.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Applied, thanks.

We need this on stable-0.11 too. See:

   https://bugzilla.redhat.com/519787

Added there, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function