[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/17] raw-posix: Fix test for host CD-ROM
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 06/17] raw-posix: Fix test for host CD-ROM |
Date: |
Tue, 6 Jul 2010 17:33:15 +0200 |
From: Markus Armbruster <address@hidden>
raw_pread_aligned() retries up to two times if the block device backs
a virtual CD-ROM (a drive with media=cdrom and if=ide, scsi, xen or
none). This makes no sense. Whether retrying reads can correct read
errors can only depend on what we're reading, not on how the result
gets used. We need to check what whether we're reading from a
physical CD-ROM or floppy here.
I doubt retrying is useful even then. Left for another day.
Impact:
* Virtual CD-ROM backed by host_cdrom behaves the same.
* Virtual CD-ROM backed by file or host_device no longer retries.
* A drive backed by host_cdrom now retries even if it's not a virtual
CD-ROM.
* Any drive backed by host_floppy now retries.
While there, clean up gratuitous use of goto.
Signed-off-by: Markus Armbruster <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/raw-posix.c | 17 ++++++-----------
1 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 3f0701b..291699f 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -242,15 +242,14 @@ static int raw_pread_aligned(BlockDriverState *bs,
int64_t offset,
ret = pread(s->fd, buf, count, offset);
if (ret == count)
- goto label__raw_read__success;
+ return ret;
/* Allow reads beyond the end (needed for pwrite) */
if ((ret == 0) && bs->growable) {
int64_t size = raw_getlength(bs);
if (offset >= size) {
memset(buf, 0, count);
- ret = count;
- goto label__raw_read__success;
+ return count;
}
}
@@ -260,13 +259,13 @@ static int raw_pread_aligned(BlockDriverState *bs,
int64_t offset,
bs->total_sectors, ret, errno, strerror(errno));
/* Try harder for CDrom. */
- if (bs->type == BDRV_TYPE_CDROM) {
+ if (s->type != FTYPE_FILE) {
ret = pread(s->fd, buf, count, offset);
if (ret == count)
- goto label__raw_read__success;
+ return ret;
ret = pread(s->fd, buf, count, offset);
if (ret == count)
- goto label__raw_read__success;
+ return ret;
DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] retry read failed %d : %d = %s\n",
@@ -274,8 +273,6 @@ static int raw_pread_aligned(BlockDriverState *bs, int64_t
offset,
bs->total_sectors, ret, errno, strerror(errno));
}
-label__raw_read__success:
-
return (ret < 0) ? -errno : ret;
}
@@ -298,15 +295,13 @@ static int raw_pwrite_aligned(BlockDriverState *bs,
int64_t offset,
ret = pwrite(s->fd, buf, count, offset);
if (ret == count)
- goto label__raw_write__success;
+ return ret;
DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
"] write failed %d : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, ret, errno, strerror(errno));
-label__raw_write__success:
-
return (ret < 0) ? -errno : ret;
}
--
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 <=
- [Qemu-devel] [PATCH 07/17] fdc: Reject unimplemented error actions, Kevin Wolf, 2010/07/06
- [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