[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/17] fdc: Reject unimplemented error actions
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 07/17] fdc: Reject unimplemented error actions |
Date: |
Tue, 6 Jul 2010 17:33:16 +0200 |
From: Markus Armbruster <address@hidden>
drive_init() doesn't permit them for if=floppy, but that's worthless:
we get them via if=none and -global.
This can make device initialization fail. Since all callers of
fdctrl_init_isa() ignore its value, change it to die instead of
returning failure. Without this, some callers would ignore the
failure, and others would crash.
Wart: unlike drive_init(), we don't reject the default action when
it's explicitly specified. That's because we can't distinguish "no
rerror option" from "rerror=report", or "no werror" from
"rerror=enospc". Left for another day.
Signed-off-by: Markus Armbruster <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/fdc.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 6c74878..2d50bd6 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -29,6 +29,7 @@
#include "hw.h"
#include "fdc.h"
+#include "qemu-error.h"
#include "qemu-timer.h"
#include "isa.h"
#include "sysbus.h"
@@ -1844,7 +1845,7 @@ static void fdctrl_result_timer(void *opaque)
}
/* Init functions */
-static void fdctrl_connect_drives(FDCtrl *fdctrl)
+static int fdctrl_connect_drives(FDCtrl *fdctrl)
{
unsigned int i;
FDrive *drive;
@@ -1852,12 +1853,24 @@ static void fdctrl_connect_drives(FDCtrl *fdctrl)
for (i = 0; i < MAX_FD; i++) {
drive = &fdctrl->drives[i];
+ if (drive->bs) {
+ if (bdrv_get_on_error(drive->bs, 0) != BLOCK_ERR_STOP_ENOSPC) {
+ error_report("fdc doesn't support drive option werror");
+ return -1;
+ }
+ if (bdrv_get_on_error(drive->bs, 1) != BLOCK_ERR_REPORT) {
+ error_report("fdc doesn't support drive option rerror");
+ return -1;
+ }
+ }
+
fd_init(drive);
fd_revalidate(drive);
if (drive->bs) {
bdrv_set_removable(drive->bs, 1);
}
}
+ return 0;
}
FDCtrl *fdctrl_init_isa(DriveInfo **fds)
@@ -1871,8 +1884,7 @@ FDCtrl *fdctrl_init_isa(DriveInfo **fds)
if (fds[1]) {
qdev_prop_set_drive_nofail(&dev->qdev, "driveB", fds[1]->bdrv);
}
- if (qdev_init(&dev->qdev) < 0)
- return NULL;
+ qdev_init_nofail(&dev->qdev);
return &(DO_UPCAST(FDCtrlISABus, busdev, dev)->state);
}
@@ -1950,9 +1962,7 @@ static int fdctrl_init_common(FDCtrl *fdctrl)
if (fdctrl->dma_chann != -1)
DMA_register_channel(fdctrl->dma_chann, &fdctrl_transfer_handler,
fdctrl);
- fdctrl_connect_drives(fdctrl);
-
- return 0;
+ return fdctrl_connect_drives(fdctrl);
}
static int isabus_fdc_init1(ISADevice *dev)
--
1.6.6.1
- [Qemu-devel] [PULL 00/17] Block patches, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 01/17] qemu-img check: Distinguish different kinds of errors, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 03/17] Add virtio disk identification support, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 04/17] blockdev: Clean up how readonly persists across virtual media change, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 02/17] qcow2/vdi: Change check to distinguish error cases, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 05/17] block migration: Fix test for read-only drive, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 06/17] raw-posix: Fix test for host CD-ROM, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 07/17] fdc: Reject unimplemented error actions,
Kevin Wolf <=
- [Qemu-devel] [PATCH 09/17] scsi: Reject unimplemented error actions, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 08/17] qdev: Don't hw_error() in qdev_init_nofail(), Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 10/17] error: New qemu_opts_loc_restore(), Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 12/17] ide: Improve error messages, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 11/17] scsi: Error locations for -drive if=scsi device initialization, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 13/17] ide: Replace IDEState members is_cdrom, is_cf by drive_kind, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 14/17] ide: Make ide_init_drive() return success, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 15/17] ide: Reject readonly drives unless CD-ROM, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 16/17] ide: Reject invalid CHS geometry, Kevin Wolf, 2010/07/06
- [Qemu-devel] [PATCH 17/17] block: add sheepdog driver for distributed storage support, Kevin Wolf, 2010/07/06