提交 558ecef2 编写于 作者: M Markus Armbruster 提交者: Michael S. Tsirkin

pci: Convert pci_nic_init() to Error to avoid qdev_init()

qdev_init() is deprecated, and will be removed when its callers have
been weaned off it.
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Acked-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
上级 75cc7f01
...@@ -1613,9 +1613,11 @@ static const char * const pci_nic_names[] = { ...@@ -1613,9 +1613,11 @@ static const char * const pci_nic_names[] = {
/* Initialize a PCI NIC. */ /* Initialize a PCI NIC. */
static PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus, static PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus,
const char *default_model, const char *default_model,
const char *default_devaddr) const char *default_devaddr,
Error **errp)
{ {
const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr; const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr;
Error *err = NULL;
PCIBus *bus; PCIBus *bus;
int devfn; int devfn;
PCIDevice *pci_dev; PCIDevice *pci_dev;
...@@ -1636,8 +1638,13 @@ static PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus, ...@@ -1636,8 +1638,13 @@ static PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus,
pci_dev = pci_create(bus, devfn, pci_nic_names[i]); pci_dev = pci_create(bus, devfn, pci_nic_names[i]);
dev = &pci_dev->qdev; dev = &pci_dev->qdev;
qdev_set_nic_properties(dev, nd); 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 NULL;
}
return pci_dev; return pci_dev;
} }
...@@ -1645,14 +1652,17 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus, ...@@ -1645,14 +1652,17 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
const char *default_model, const char *default_model,
const char *default_devaddr) const char *default_devaddr)
{ {
Error *err = NULL;
PCIDevice *res; PCIDevice *res;
if (qemu_show_nic_models(nd->model, pci_nic_models)) if (qemu_show_nic_models(nd->model, pci_nic_models))
exit(0); exit(0);
res = pci_nic_init(nd, rootbus, default_model, default_devaddr); res = pci_nic_init(nd, rootbus, default_model, default_devaddr, &err);
if (!res) if (!res) {
error_report_err(err);
exit(1); exit(1);
}
return res; return res;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册