From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkEH1-0006Bq-9Q for qemu-devel@nongnu.org; Fri, 31 Oct 2014 11:38:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xjt4C-0000HI-FQ for qemu-devel@nongnu.org; Thu, 30 Oct 2014 12:59:27 -0400 Received: from mail-lb0-x22e.google.com ([2a00:1450:4010:c04::22e]:48685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xjt4C-0000Gu-4S for qemu-devel@nongnu.org; Thu, 30 Oct 2014 12:59:20 -0400 Received: by mail-lb0-f174.google.com with SMTP id z11so2700922lbi.19 for ; Thu, 30 Oct 2014 09:59:17 -0700 (PDT) Message-ID: <1414688302.2327.2.camel@localhost.localdomain> From: Marcel Apfelbaum Date: Thu, 30 Oct 2014 18:58:22 +0200 In-Reply-To: <8761f4sfe5.fsf@blackfin.pond.sub.org> References: <1414481739-19939-1-git-send-email-armbru@redhat.com> <1414481739-19939-2-git-send-email-armbru@redhat.com> <544F54BB.2080508@huawei.com> <8761f4sfe5.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 01/10] pci: Convert core to realize Reply-To: marcel.a@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gonglei , Markus Armbruster Cc: "qemu-devel@nongnu.org" , "pbonzini@redhat.com" , "kraxel@redhat.com" , "afaerber@suse.de" , "mst@redhat.com" On Tue, 2014-10-28 at 10:38 +0100, Markus Armbruster wrote: > Gonglei writes: > > > On 2014/10/28 15:35, Markus Armbruster wrote: > > > >> Implement DeviceClass methods realize() and unrealize() instead of > >> init() and exit(). The core's initialization errors now get > >> propagated properly, and QMP sends them instead of an unspecific > >> "Device initialization failed" error. Unrealize can't fail, so no > >> change there. > >> > >> PCIDeviceClass is unchanged: it still provides init() and exit(). > >> Therefore, device models' errors are still not propagated. > >> > >> Signed-off-by: Markus Armbruster > >> --- > >> hw/pci/pci.c | 91 +++++++++++++++++++++++++++++++----------------------------- > >> 1 file changed, 47 insertions(+), 44 deletions(-) > >> > >> diff --git a/hw/pci/pci.c b/hw/pci/pci.c > >> index cd7a403..aef95c3 100644 > >> --- a/hw/pci/pci.c > >> +++ b/hw/pci/pci.c > [...] > >> void pci_register_bar(PCIDevice *pci_dev, int region_num, > >> @@ -1742,10 +1747,11 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn) > >> return bus->devices[devfn]; > >> } > >> > >> -static int pci_qdev_init(DeviceState *qdev) > >> +static void pci_qdev_realize(DeviceState *qdev, Error **errp) > >> { > >> PCIDevice *pci_dev = (PCIDevice *)qdev; > >> PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); > >> + Error *local_err = NULL; > >> PCIBus *bus; > >> int rc; > >> bool is_default_rom; > >> @@ -1758,15 +1764,16 @@ static int pci_qdev_init(DeviceState *qdev) > >> bus = PCI_BUS(qdev_get_parent_bus(qdev)); > >> pci_dev = do_pci_register_device(pci_dev, bus, > >> object_get_typename(OBJECT(qdev)), > >> - pci_dev->devfn); > >> + pci_dev->devfn, errp); > >> if (pci_dev == NULL) > > > >> - return -1; > >> + return; > >> > > > > Maybe we can use '{}' for if statement follow Qemu's coding style. I suggest adding a trivial patch on top of Markus's series Thanks, Marcel > > scripts/checkpatch.pl is happy with the patch as is. > > I prefer to add braces only when I touch the conditional. > > Naturally, I also add them when a maintainer asks me to :) > > >> if (pc->init) { > >> rc = pc->init(pci_dev); > >> if (rc != 0) { > >> do_pci_unregister_device(pci_dev); > >> - return rc; > >> + error_setg(errp, "Device initialization failed"); > >> + return; > >> } > >> } > >> > [...] > > Thanks! >