diff mbox

[ANNOUNCE,Call-For-Testing] Release 0.12.0-rc1 of QEMU

Message ID 4B1E4F91.9010206@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann Dec. 8, 2009, 1:07 p.m. UTC
On 12/08/09 13:52, Gerd Hoffmann wrote:
>> The latter. The guest does not see it, but it at least does not abort.
>> It is the 'does not abort' behaviour I'm interested in - quite OK with
>> this returning an error to the monitor client when acpi is disabled.
>
> Does the attached patch fix it for you?

One more fix for the "hw_error() when slots full" case.

cheers,
   Gerd
From 1c1de5c577a3241df4fb52cfdf15e97af9283caa Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Tue, 8 Dec 2009 14:05:11 +0100
Subject: [PATCH] pci: don't hw_error() when no slot is available.


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/pci.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

Comments

Daniel P. Berrangé Dec. 9, 2009, 10:21 a.m. UTC | #1
On Tue, Dec 08, 2009 at 02:07:29PM +0100, Gerd Hoffmann wrote:
> On 12/08/09 13:52, Gerd Hoffmann wrote:
> >>The latter. The guest does not see it, but it at least does not abort.
> >>It is the 'does not abort' behaviour I'm interested in - quite OK with
> >>this returning an error to the monitor client when acpi is disabled.
> >
> >Does the attached patch fix it for you?
> 
> One more fix for the "hw_error() when slots full" case.

Yes, the combination of those two patches fix both problems


(qemu) pci_add pci_addr=auto storage file=/home/berrange/mcdboot.img,if=virtio
PCI bus doesn't support hotplug
failed to add file=/home/berrange/mcdboot.img,if=virtio


(qemu) pci_add pci_addr=auto storage file=/home/berrange/mcdboot.img,if=virtio
PCI: no devfn available for virtio-blk-pci, all in use
failed to add file=/home/berrange/mcdboot.img,if=virtio

Regards,
Daniel
diff mbox

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 4f662b7..404eead 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -580,11 +580,13 @@  static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
             if (!bus->devices[devfn])
                 goto found;
         }
-        hw_error("PCI: no devfn available for %s, all in use\n", name);
+        qemu_error("PCI: no devfn available for %s, all in use\n", name);
+        return NULL;
     found: ;
     } else if (bus->devices[devfn]) {
-        hw_error("PCI: devfn %d not available for %s, in use by %s\n", devfn,
+        qemu_error("PCI: devfn %d not available for %s, in use by %s\n", devfn,
                  name, bus->devices[devfn]->name);
+        return NULL;
     }
     pci_dev->bus = bus;
     pci_dev->devfn = devfn;
@@ -625,6 +627,9 @@  PCIDevice *pci_register_device(PCIBus *bus, const char *name,
     pci_dev = do_pci_register_device(pci_dev, bus, name, devfn,
                                      config_read, config_write,
                                      PCI_HEADER_TYPE_NORMAL);
+    if (pci_dev == NULL) {
+        hw_error("PCI: can't register device\n");
+    }
     return pci_dev;
 }
 static target_phys_addr_t pci_to_cpu_addr(target_phys_addr_t addr)
@@ -1376,6 +1381,8 @@  static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
     pci_dev = do_pci_register_device(pci_dev, bus, base->name, devfn,
                                      info->config_read, info->config_write,
                                      info->header_type);
+    if (pci_dev == NULL)
+        return -1;
     rc = info->init(pci_dev);
     if (rc != 0)
         return rc;