Skip to contentSkip to conversation

device-assignment: Don't deassign when the assignment fails

PATCH Applied Alex Williamson 2 participants 2 messages Jun 10, 2010 – Jun 11, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 device-assignment: Don't deassign when the assignment fails

The last thing assign_device() does is call into KVM_ASSIGN_PCI_DEVICE. If that fails, the device is not assigned, so we shouldn't then try to deassign it. If you try to assign the same device multiple times, you can get into a nasty fail-succeed-fail-succeed loop. And we certainly shouldn't take the assigned_out branch before we've even attempted to assign the device.

---

 hw/device-assignment.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/device-assignment.c +2 -2
index 2b963b5..7e53a95 100644
@@ -1407,12 +1407,12 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
     if (pci_enable_capability_support(pci_dev, 0, NULL,
                     assigned_device_pci_cap_write_config,
                     assigned_device_pci_cap_init) < 0)
-        goto assigned_out;
+        goto out;
 
     /* assign device to guest */
     r = assign_device(dev);
     if (r < 0)
-        goto assigned_out;
+        goto out;
 
     /* assign irq for the device */
     r = assign_irq(dev);
#1 lore raw
Quoted 8 lines · Alex Williamson

The last thing assign_device() does is call into KVM_ASSIGN_PCI_DEVICE. If that fails, the device is not assigned, so we shouldn't then try to deassign it. If you try to assign the same device multiple times, you can get into a nasty fail-succeed-fail-succeed loop. And we certainly shouldn't take the assigned_out branch before we've even attempted to assign the device.

Applied, thanks.