diff options
author | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-10-01 01:13:37 +0000 |
---|---|---|
committer | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-10-01 01:13:37 +0000 |
commit | e162cfb07b7bee2d4527b860f13de39429733dfa (patch) | |
tree | 1e98228fdb7de2f87dc3ffb0b44f793996dc261b /hw/ide.c | |
parent | 6dc2d0daee4ca38c81b3d755ef3efd31fcd2fda2 (diff) |
Actually check read/write errors in IDE (Ian Jackson).
This patch makes the ide emulation actually take notice of
error returns from bdrv_write and bdrv_aio_{read,write}.
(Cherry picked from qemu-xen e0e7a0afe0e324a1f7d64c240f567b15dbe454cf,
first posted to qemu-devel Wed, 20 Feb 2008 15:26:41 +0000)
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5368 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/ide.c')
-rw-r--r-- | hw/ide.c | 34 |
1 files changed, 32 insertions, 2 deletions
@@ -817,6 +817,11 @@ static void ide_set_sector(IDEState *s, int64_t sector_num) } } +static void ide_rw_error(IDEState *s) { + ide_abort_command(s); + ide_set_irq(s); +} + static void ide_sector_read(IDEState *s) { int64_t sector_num; @@ -836,6 +841,10 @@ static void ide_sector_read(IDEState *s) if (n > s->req_nb_sectors) n = s->req_nb_sectors; ret = bdrv_read(s->bs, sector_num, s->io_buffer, n); + if (ret != 0) { + ide_rw_error(s); + return; + } ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_read); ide_set_irq(s); ide_set_sector(s, sector_num + n); @@ -843,6 +852,14 @@ static void ide_sector_read(IDEState *s) } } +static void ide_dma_error(IDEState *s) +{ + ide_transfer_stop(s); + s->error = ABRT_ERR; + s->status = READY_STAT | ERR_STAT; + ide_set_irq(s); +} + /* return 0 if buffer completed */ static int dma_buf_rw(BMDMAState *bm, int is_write) { @@ -891,7 +908,6 @@ static int dma_buf_rw(BMDMAState *bm, int is_write) return 1; } -/* XXX: handle errors */ static void ide_read_dma_cb(void *opaque, int ret) { BMDMAState *bm = opaque; @@ -899,6 +915,11 @@ static void ide_read_dma_cb(void *opaque, int ret) int n; int64_t sector_num; + if (ret < 0) { + ide_dma_error(s); + return; + } + n = s->io_buffer_size >> 9; sector_num = ide_get_sector(s); if (n > 0) { @@ -963,6 +984,11 @@ static void ide_sector_write(IDEState *s) if (n > s->req_nb_sectors) n = s->req_nb_sectors; ret = bdrv_write(s->bs, sector_num, s->io_buffer, n); + if (ret != 0) { + ide_rw_error(s); + return; + } + s->nsector -= n; if (s->nsector == 0) { /* no more sectors to write */ @@ -992,7 +1018,6 @@ static void ide_sector_write(IDEState *s) } } -/* XXX: handle errors */ static void ide_write_dma_cb(void *opaque, int ret) { BMDMAState *bm = opaque; @@ -1000,6 +1025,11 @@ static void ide_write_dma_cb(void *opaque, int ret) int n; int64_t sector_num; + if (ret < 0) { + ide_dma_error(s); + return; + } + n = s->io_buffer_size >> 9; sector_num = ide_get_sector(s); if (n > 0) { |