From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIhrE-0008CL-W1 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 07:10:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIhr9-00085w-VV for qemu-devel@nongnu.org; Thu, 10 Dec 2009 07:10:56 -0500 Received: from [199.232.76.173] (port=52057 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIhr9-00085j-J7 for qemu-devel@nongnu.org; Thu, 10 Dec 2009 07:10:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41574) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIhr9-00028Z-Bb for qemu-devel@nongnu.org; Thu, 10 Dec 2009 07:10:51 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBACAowJ016487 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 10 Dec 2009 07:10:50 -0500 Date: Thu, 10 Dec 2009 14:08:06 +0200 From: "Michael S. Tsirkin" Message-ID: <20091210120806.GB13657@redhat.com> References: <1260439868-15061-1-git-send-email-kraxel@redhat.com> <1260439868-15061-3-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1260439868-15061-3-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] Re: [FOR 0.12 PATCH 2/4] pci: don't hw_error() when no slot is available. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org On Thu, Dec 10, 2009 at 11:11:06AM +0100, Gerd Hoffmann wrote: > Current PCI code will simply hw_error() and thus abort in case no free > PCI slot is available or the requested PCI slot is already in use by > another device. For the hotplug case this behavior is not acceptable. > This patch makes qemu pass up the error properly, so the calling code > can decide whenever it wants to exit with an error (on startup) or > whenever it wants to continue (hotplug). > > Signed-off-by: Gerd Hoffmann Good stuff. However > --- > hw/pci.c | 11 +++++++++-- > 1 files changed, 9 insertions(+), 2 deletions(-) > > 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"); > + } Can you please use !pci_dev for these checks? > 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; And here too. > rc = info->init(pci_dev); > if (rc != 0) > return rc; > -- > 1.6.5.2 > >