summaryrefslogtreecommitdiff
path: root/hw/pcnet.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-08-14 10:36:05 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-08-27 20:43:28 -0500
commit81a322d4a1b68d47908a6630bf22897a289722aa (patch)
treecdca9840d0620d9e0b46d7b81c58abe04a372b78 /hw/pcnet.c
parent24e6f3551f3c8ea7cc7524a3e64e84beca59618f (diff)
qdev: add return value to init() callbacks.
Sorry folks, but it has to be. One more of these invasive qdev patches. We have a serious design bug in the qdev interface: device init callbacks can't signal failure because the init() callback has no return value. This patch fixes it. We have already one case in-tree where this is needed: Try -device virtio-blk-pci (without drive= specified) and watch qemu segfault. This patch fixes it. With usb+scsi being converted to qdev we'll get more devices where the init callback can fail for various reasons. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/pcnet.c')
-rw-r--r--hw/pcnet.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 827f6bd81f..107b5b64c3 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -1948,7 +1948,7 @@ static void pcnet_common_cleanup(PCNetState *d)
qemu_free_timer(d->poll_timer);
}
-static void pcnet_common_init(DeviceState *dev, PCNetState *s,
+static int pcnet_common_init(DeviceState *dev, PCNetState *s,
NetCleanup *cleanup)
{
s->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, s);
@@ -1959,6 +1959,7 @@ static void pcnet_common_init(DeviceState *dev, PCNetState *s,
cleanup, s);
pcnet_h_reset(s);
register_savevm("pcnet", -1, 2, pcnet_save, pcnet_load, s);
+ return 0;
}
/* PCI interface */
@@ -2015,7 +2016,7 @@ static int pci_pcnet_uninit(PCIDevice *dev)
return 0;
}
-static void pci_pcnet_init(PCIDevice *pci_dev)
+static int pci_pcnet_init(PCIDevice *pci_dev)
{
PCIPCNetState *d = (PCIPCNetState *)pci_dev;
PCNetState *s = &d->state;
@@ -2061,7 +2062,7 @@ static void pci_pcnet_init(PCIDevice *pci_dev)
s->phys_mem_write = pci_physical_memory_write;
s->pci_dev = pci_dev;
- pcnet_common_init(&pci_dev->qdev, s, pci_pcnet_cleanup);
+ return pcnet_common_init(&pci_dev->qdev, s, pci_pcnet_cleanup);
}
/* SPARC32 interface */
@@ -2120,7 +2121,7 @@ static void lance_cleanup(VLANClientState *vc)
pcnet_common_cleanup(d);
}
-static void lance_init(SysBusDevice *dev)
+static int lance_init(SysBusDevice *dev)
{
SysBusPCNetState *d = FROM_SYSBUS(SysBusPCNetState, dev);
PCNetState *s = &d->state;
@@ -2137,7 +2138,7 @@ static void lance_init(SysBusDevice *dev)
s->phys_mem_read = ledma_memory_read;
s->phys_mem_write = ledma_memory_write;
- pcnet_common_init(&dev->qdev, s, lance_cleanup);
+ return pcnet_common_init(&dev->qdev, s, lance_cleanup);
}
static SysBusDeviceInfo lance_info = {