diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-08-14 10:36:05 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-08-27 20:43:28 -0500 |
commit | 81a322d4a1b68d47908a6630bf22897a289722aa (patch) | |
tree | cdca9840d0620d9e0b46d7b81c58abe04a372b78 /hw/unin_pci.c | |
parent | 24e6f3551f3c8ea7cc7524a3e64e84beca59618f (diff) | |
download | qemu-81a322d4a1b68d47908a6630bf22897a289722aa.zip qemu-81a322d4a1b68d47908a6630bf22897a289722aa.tar.gz qemu-81a322d4a1b68d47908a6630bf22897a289722aa.tar.bz2 |
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/unin_pci.c')
-rw-r--r-- | hw/unin_pci.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/hw/unin_pci.c b/hw/unin_pci.c index 908e046..9b5b8c8 100644 --- a/hw/unin_pci.c +++ b/hw/unin_pci.c @@ -167,7 +167,7 @@ static void pci_unin_reset(void *opaque) { } -static void pci_unin_main_init_device(SysBusDevice *dev) +static int pci_unin_main_init_device(SysBusDevice *dev) { UNINState *s; int pci_mem_config, pci_mem_data; @@ -187,9 +187,10 @@ static void pci_unin_main_init_device(SysBusDevice *dev) register_savevm("uninorth", 0, 1, pci_unin_save, pci_unin_load, &s->host_state); qemu_register_reset(pci_unin_reset, &s->host_state); pci_unin_reset(&s->host_state); + return 0; } -static void pci_dec_21154_init_device(SysBusDevice *dev) +static int pci_dec_21154_init_device(SysBusDevice *dev) { UNINState *s; int pci_mem_config, pci_mem_data; @@ -204,9 +205,10 @@ static void pci_dec_21154_init_device(SysBusDevice *dev) pci_unin_main_write, &s->host_state); sysbus_init_mmio(dev, 0x1000, pci_mem_config); sysbus_init_mmio(dev, 0x1000, pci_mem_data); + return 0; } -static void pci_unin_agp_init_device(SysBusDevice *dev) +static int pci_unin_agp_init_device(SysBusDevice *dev) { UNINState *s; int pci_mem_config, pci_mem_data; @@ -220,9 +222,10 @@ static void pci_unin_agp_init_device(SysBusDevice *dev) pci_unin_main_write, &s->host_state); sysbus_init_mmio(dev, 0x1000, pci_mem_config); sysbus_init_mmio(dev, 0x1000, pci_mem_data); + return 0; } -static void pci_unin_internal_init_device(SysBusDevice *dev) +static int pci_unin_internal_init_device(SysBusDevice *dev) { UNINState *s; int pci_mem_config, pci_mem_data; @@ -236,6 +239,7 @@ static void pci_unin_internal_init_device(SysBusDevice *dev) pci_unin_write, s); sysbus_init_mmio(dev, 0x1000, pci_mem_config); sysbus_init_mmio(dev, 0x1000, pci_mem_data); + return 0; } PCIBus *pci_pmac_init(qemu_irq *pic) @@ -277,7 +281,7 @@ PCIBus *pci_pmac_init(qemu_irq *pic) return d->host_state.bus; } -static void unin_main_pci_host_init(PCIDevice *d) +static int unin_main_pci_host_init(PCIDevice *d) { pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_PCI); @@ -287,9 +291,10 @@ static void unin_main_pci_host_init(PCIDevice *d) d->config[0x0D] = 0x10; // latency_timer d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type d->config[0x34] = 0x00; // capabilities_pointer + return 0; } -static void dec_21154_pci_host_init(PCIDevice *d) +static int dec_21154_pci_host_init(PCIDevice *d) { /* pci-to-pci bridge */ pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_DEC); @@ -315,9 +320,10 @@ static void dec_21154_pci_host_init(PCIDevice *d) d->config[0x26] = 0xF1; // prefectchable_memory_limit d->config[0x27] = 0x7F; // d->config[0x34] = 0xdc // capabilities_pointer + return 0; } -static void unin_agp_pci_host_init(PCIDevice *d) +static int unin_agp_pci_host_init(PCIDevice *d) { pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_AGP); @@ -327,9 +333,10 @@ static void unin_agp_pci_host_init(PCIDevice *d) d->config[0x0D] = 0x10; // latency_timer d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type // d->config[0x34] = 0x80; // capabilities_pointer + return 0; } -static void unin_internal_pci_host_init(PCIDevice *d) +static int unin_internal_pci_host_init(PCIDevice *d) { pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_I_PCI); @@ -339,6 +346,7 @@ static void unin_internal_pci_host_init(PCIDevice *d) d->config[0x0D] = 0x10; // latency_timer d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type d->config[0x34] = 0x00; // capabilities_pointer + return 0; } static PCIDeviceInfo unin_main_pci_host_info = { |