Received: from eggs.gnu.org ([2001:4830:134:3::10]:33666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRM5j-0000Vl-6W for qemu-devel@nongnu.org; Fri, 27 Feb 2015 09:40:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YRM5e-0006uV-5l for qemu-devel@nongnu.org; Fri, 27 Feb 2015 09:40:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50691) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRM5d-0006uQ-Qb for qemu-devel@nongnu.org; Fri, 27 Feb 2015 09:40:30 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1REeRG2029928 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 27 Feb 2015 09:40:28 -0500 From: Markus Armbruster Date: Fri, 27 Feb 2015 15:40:25 +0100 Message-Id: <1425048025-7501-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH] pci: Convert pci_nic_init() to Error to avoid qdev_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mst@redhat.com qdev_init() is deprecated, and will be removed when its callers have been weaned off it. Signed-off-by: Markus Armbruster --- Depends on my "[PATCH 00/10] pci: Partial conversion to realize", which is in Michael's latest pull request, and on my "[PATCH v2 2/2] pci: Give a few helpers internal linkage". hw/pci/pci.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index cc5d946..6941a82 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1613,9 +1613,11 @@ static const char * const pci_nic_names[] = { /* Initialize a PCI NIC. */ static PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus, const char *default_model, - const char *default_devaddr) + const char *default_devaddr, + Error **errp) { const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr; + Error *err = NULL; PCIBus *bus; int devfn; PCIDevice *pci_dev; @@ -1636,8 +1638,13 @@ static PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus, pci_dev = pci_create(bus, devfn, pci_nic_names[i]); dev = &pci_dev->qdev; qdev_set_nic_properties(dev, nd); - if (qdev_init(dev) < 0) + + object_property_set_bool(OBJECT(dev), true, "realized", &err); + if (err) { + error_propagate(errp, err); + object_unparent(OBJECT(dev)); return NULL; + } return pci_dev; } @@ -1645,14 +1652,17 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus, const char *default_model, const char *default_devaddr) { + Error *err = NULL; PCIDevice *res; if (qemu_show_nic_models(nd->model, pci_nic_models)) exit(0); - res = pci_nic_init(nd, rootbus, default_model, default_devaddr); - if (!res) + res = pci_nic_init(nd, rootbus, default_model, default_devaddr, &err); + if (!res) { + error_report_err(err); exit(1); + } return res; } -- 1.9.3