[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH qom-next] fdc: Improve error propagation for QOM rea
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH qom-next] fdc: Improve error propagation for QOM realize |
Date: |
Sun, 21 Jul 2013 11:31:57 +0200 |
Rename fdctrl_init_common() to fdctrl_realize_common() and let
fdctrl_connect_drives() propagate an Error through it.
Signed-off-by: Andreas Färber <address@hidden>
---
hw/block/fdc.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 9a983fb..d32f6ba 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -1997,7 +1997,7 @@ static const BlockDevOps fdctrl_block_ops = {
};
/* Init functions */
-static int fdctrl_connect_drives(FDCtrl *fdctrl)
+static void fdctrl_connect_drives(FDCtrl *fdctrl, Error **errp)
{
unsigned int i;
FDrive *drive;
@@ -2008,12 +2008,12 @@ static int fdctrl_connect_drives(FDCtrl *fdctrl)
if (drive->bs) {
if (bdrv_get_on_error(drive->bs, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {
- error_report("fdc doesn't support drive option werror");
- return -1;
+ error_setg(errp, "fdc doesn't support drive option werror");
+ return;
}
if (bdrv_get_on_error(drive->bs, 1) != BLOCKDEV_ON_ERROR_REPORT) {
- error_report("fdc doesn't support drive option rerror");
- return -1;
+ error_setg(errp, "fdc doesn't support drive option rerror");
+ return;
}
}
@@ -2023,7 +2023,6 @@ static int fdctrl_connect_drives(FDCtrl *fdctrl)
bdrv_set_dev_ops(drive->bs, &fdctrl_block_ops, drive);
}
}
- return 0;
}
ISADevice *fdctrl_init_isa(ISABus *bus, DriveInfo **fds)
@@ -2089,7 +2088,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,
*fdc_tc = qdev_get_gpio_in(dev, 0);
}
-static int fdctrl_init_common(FDCtrl *fdctrl)
+static void fdctrl_realize_common(FDCtrl *fdctrl, Error **errp)
{
int i, j;
static int command_tables_inited = 0;
@@ -2110,15 +2109,16 @@ static int fdctrl_init_common(FDCtrl *fdctrl)
fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
fdctrl->fifo_size = 512;
fdctrl->result_timer = qemu_new_timer_ns(vm_clock,
- fdctrl_result_timer, fdctrl);
+ fdctrl_result_timer, fdctrl);
fdctrl->version = 0x90; /* Intel 82078 controller */
fdctrl->config = FD_CONFIG_EIS | FD_CONFIG_EFIFO; /* Implicit seek,
polling & FIFO enabled */
fdctrl->num_floppies = MAX_FD;
- if (fdctrl->dma_chann != -1)
+ if (fdctrl->dma_chann != -1) {
DMA_register_channel(fdctrl->dma_chann, &fdctrl_transfer_handler,
fdctrl);
- return fdctrl_connect_drives(fdctrl);
+ }
+ fdctrl_connect_drives(fdctrl, errp);
}
static const MemoryRegionPortio fdc_portio_list[] = {
@@ -2132,7 +2132,7 @@ static void isabus_fdc_realize(DeviceState *dev, Error
**errp)
ISADevice *isadev = ISA_DEVICE(dev);
FDCtrlISABus *isa = ISA_FDC(dev);
FDCtrl *fdctrl = &isa->state;
- int ret;
+ Error *err = NULL;
isa_register_portio_list(isadev, isa->iobase, fdc_portio_list, fdctrl,
"fdc");
@@ -2141,9 +2141,9 @@ static void isabus_fdc_realize(DeviceState *dev, Error
**errp)
fdctrl->dma_chann = isa->dma;
qdev_set_legacy_instance_id(dev, isa->iobase, 2);
- ret = fdctrl_init_common(fdctrl);
- if (ret < 0) {
- error_setg(errp, "Floppy init failed.");
+ fdctrl_realize_common(fdctrl, &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
return;
}
@@ -2165,6 +2165,7 @@ static void sysbus_fdc_realize(DeviceState *dev, Error
**errp)
FDCtrlSysBus *sys = SYSBUS_FDC(dev);
FDCtrl *fdctrl = &sys->state;
SysBusDevice *b = SYS_BUS_DEVICE(dev);
+ Error *err = NULL;
sysbus_init_mmio(b, &fdctrl->iomem);
sysbus_init_irq(b, &fdctrl->irq);
@@ -2172,8 +2173,9 @@ static void sysbus_fdc_realize(DeviceState *dev, Error
**errp)
fdctrl->dma_chann = -1;
qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */
- if (fdctrl_init_common(fdctrl) < 0) {
- error_setg(errp, "Floppy init failed.");
+ fdctrl_realize_common(fdctrl, &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
return;
}
}
@@ -2192,6 +2194,7 @@ static void sun4m_fdc_realize(DeviceState *dev, Error
**errp)
FDCtrlSysBus *sys = SYSBUS_FDC(dev);
FDCtrl *fdctrl = &sys->state;
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+ Error *err = NULL;
sysbus_init_mmio(sbd, &fdctrl->iomem);
sysbus_init_irq(sbd, &fdctrl->irq);
@@ -2199,8 +2202,9 @@ static void sun4m_fdc_realize(DeviceState *dev, Error
**errp)
fdctrl->sun4m = 1;
qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */
- if (fdctrl_init_common(fdctrl) < 0) {
- error_setg(errp, "Floppy init failed.");
+ fdctrl_realize_common(fdctrl, &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
return;
}
}
--
1.8.1.4
- [Qemu-devel] [PATCH v2 04/26] i440fx-pcihost: use realize for i440fx-pcihost, (continued)
- [Qemu-devel] [PATCH v2 04/26] i440fx-pcihost: use realize for i440fx-pcihost, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 06/26] q35: use type-safe cast instead of directly access of parent dev, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 08/26] fdc: QOM'ify some more, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 07/26] q35: use realize for q35 host, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 11/26] pflash_cfi01: use realize for pflash_cfi01, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 09/26] fdc: use realize for fdc., Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 12/26] pflash-cfi02: QOM'ify some more, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 14/26] ahci: QOM'ify some more, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 10/26] pflash-cfi01: QOM'ify some more, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 13/26] pflash_cfi02: use realize for pflash_cfi02, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 15/26] ahci: use realize for ahci, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 16/26] fwcfg: QOM'ify some more, Hu Tao, 2013/07/01
- [Qemu-devel] [PATCH v2 18/26] scsi esp: QOM'ify some more, Hu Tao, 2013/07/01