summaryrefslogtreecommitdiff
path: root/block-raw-posix.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-13 03:12:03 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-13 03:12:03 +0000
commit18be4fc257bf2f6932b85ec901eab43fa22af1be (patch)
tree93f68beb4ac7fc625c08cd06a690bf170c0fba0e /block-raw-posix.c
parenta44691b069fda7db98007e269f061dd2a02168f2 (diff)
downloadqemu-18be4fc257bf2f6932b85ec901eab43fa22af1be.tar.gz
qemu-18be4fc257bf2f6932b85ec901eab43fa22af1be.tar.bz2
qemu-18be4fc257bf2f6932b85ec901eab43fa22af1be.zip
Fix regression introduced by r6824
The changes introduced by r6824 broke a subtle, and admittedly obscure, aspect of the block API. While bdrv_{pread,pwrite} return the number of bytes read or written upon success, bdrv_{read,write} returns a zero upon success. When using bdrv_pread for bdrv_read, special care must be taken to handle this case. This fixes certain guest images (notably linux-0.2 provided on the qemu website). Reported-by: malc <av1474@comtv.ru> Reported-by: Herve Poussineau <hpoussin@reactos.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6828 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block-raw-posix.c')
-rw-r--r--block-raw-posix.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/block-raw-posix.c b/block-raw-posix.c
index 696128b80b..1a1a1781bc 100644
--- a/block-raw-posix.c
+++ b/block-raw-posix.c
@@ -361,7 +361,12 @@ static int raw_pread(BlockDriverState *bs, int64_t offset,
static int raw_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
- return raw_pread(bs, sector_num * 512, buf, (uint64_t)nb_sectors * 512);
+ int ret;
+
+ ret = raw_pread(bs, sector_num * 512, buf, nb_sectors * 512);
+ if (ret == (nb_sectors * 512))
+ ret = 0;
+ return ret;
}
/*
@@ -445,7 +450,11 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset,
static int raw_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
- return raw_pwrite(bs, sector_num * 512, buf, (uint64_t)nb_sectors * 512);
+ int ret;
+ ret = raw_pwrite(bs, sector_num * 512, buf, nb_sectors * 512);
+ if (ret == (nb_sectors * 512))
+ ret = 0;
+ return ret;
}
#ifdef CONFIG_AIO