From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIANA-0001Nj-EG for qemu-devel@nongnu.org; Sun, 10 Jan 2016 02:25:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIAN7-0001Dc-6h for qemu-devel@nongnu.org; Sun, 10 Jan 2016 02:25:08 -0500 Received: from [59.151.112.132] (port=37355 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIAN6-00014a-FH for qemu-devel@nongnu.org; Sun, 10 Jan 2016 02:25:05 -0500 References: <1450788622-9132-1-git-send-email-caoj.fnst@cn.fujitsu.com> <56795A03.4060409@redhat.com> From: Cao jin Message-ID: <569207FE.9040205@cn.fujitsu.com> Date: Sun, 10 Jan 2016 15:27:58 +0800 MIME-Version: 1.0 In-Reply-To: <56795A03.4060409@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3] PXB: convert to realize() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , pbonzini@redhat.com Hi, The patch has been reviewed by: Marcel Apfelbaum , but still not seeing it in upstream, is it missed? On 12/22/2015 10:11 PM, Marcel Apfelbaum wrote: > On 12/22/2015 02:50 PM, Cao jin wrote: >> Signed-off-by: Cao jin >> --- >> v3 changelog: >> 1. As per Paolo`s review, also Marcel`s test suggestion, just unparent >> bus >> object while unref the ds & bds object >> >> hw/pci-bridge/pci_expander_bridge.c | 33 >> +++++++++++++++++++-------------- >> 1 file changed, 19 insertions(+), 14 deletions(-) >> >> diff --git a/hw/pci-bridge/pci_expander_bridge.c >> b/hw/pci-bridge/pci_expander_bridge.c >> index 57f8a37..7db6a78 100644 >> --- a/hw/pci-bridge/pci_expander_bridge.c >> +++ b/hw/pci-bridge/pci_expander_bridge.c >> @@ -145,25 +145,23 @@ static const TypeInfo pxb_host_info = { >> * Returns 0 on successs, -1 if i440fx host was not >> * found or the bus number is already in use. >> */ >> -static int pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus) >> +static void pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus, Error >> **errp) >> { >> PCIBus *bus = dev->bus; >> int pxb_bus_num = pci_bus_num(pxb_bus); >> >> if (bus->parent_dev) { >> - error_report("PXB devices can be attached only to root bus."); >> - return -1; >> + error_setg(errp, "PXB devices can be attached only to root >> bus."); >> + return; >> } >> >> QLIST_FOREACH(bus, &bus->child, sibling) { >> if (pci_bus_num(bus) == pxb_bus_num) { >> - error_report("Bus %d is already in use.", pxb_bus_num); >> - return -1; >> + error_setg(errp, "Bus %d is already in use.", pxb_bus_num); >> + return; >> } >> } >> QLIST_INSERT_HEAD(&dev->bus->child, pxb_bus, sibling); >> - >> - return 0; >> } >> >> static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin) >> @@ -193,7 +191,7 @@ static gint pxb_compare(gconstpointer a, >> gconstpointer b) >> 0; >> } >> >> -static int pxb_dev_initfn(PCIDevice *dev) >> +static void pxb_dev_realize(PCIDevice *dev, Error **errp) >> { >> PXBDev *pxb = PXB_DEV(dev); >> DeviceState *ds, *bds; >> @@ -202,8 +200,8 @@ static int pxb_dev_initfn(PCIDevice *dev) >> >> if (pxb->numa_node != NUMA_NODE_UNASSIGNED && >> pxb->numa_node >= nb_numa_nodes) { >> - error_report("Illegal numa node %d.", pxb->numa_node); >> - return -EINVAL; >> + error_setg(errp, "Illegal numa node %d.", pxb->numa_node); >> + return; >> } >> >> if (dev->qdev.id && *dev->qdev.id) { >> @@ -225,8 +223,9 @@ static int pxb_dev_initfn(PCIDevice *dev) >> >> PCI_HOST_BRIDGE(ds)->bus = bus; >> >> - if (pxb_register_bus(dev, bus)) { >> - return -EINVAL; >> + pxb_register_bus(dev, bus, errp); >> + if (*errp) { >> + goto err_register_bus; >> } >> >> qdev_init_nofail(ds); >> @@ -237,7 +236,13 @@ static int pxb_dev_initfn(PCIDevice *dev) >> pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST); >> >> pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, >> pxb_compare); >> - return 0; >> + >> + return; >> + >> +err_register_bus: >> + object_unref(OBJECT(bds)); >> + object_unparent(OBJECT(bus)); >> + object_unref(OBJECT(ds)); >> } >> >> static void pxb_dev_exitfn(PCIDevice *pci_dev) >> @@ -259,7 +264,7 @@ static void pxb_dev_class_init(ObjectClass *klass, >> void *data) >> DeviceClass *dc = DEVICE_CLASS(klass); >> PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); >> >> - k->init = pxb_dev_initfn; >> + k->realize = pxb_dev_realize; >> k->exit = pxb_dev_exitfn; >> k->vendor_id = PCI_VENDOR_ID_REDHAT; >> k->device_id = PCI_DEVICE_ID_REDHAT_PXB; >> > > > Reviewed-by: Marcel Apfelbaum > > > Thanks, > Marcel > > > > . > -- Yours Sincerely, Cao jin