summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-12 19:57:16 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-12 19:57:16 +0000
commiteda578e559879b1a6a85f924adf2942070ae7ec3 (patch)
treee2ed165dddbda7b7a1a543185ed4b86daa5a501f /block.c
parent04eeb8b6d68ed314746856c813ce6fa8bc1a95df (diff)
downloadqemu-eda578e559879b1a6a85f924adf2942070ae7ec3.tar.gz
qemu-eda578e559879b1a6a85f924adf2942070ae7ec3.tar.bz2
qemu-eda578e559879b1a6a85f924adf2942070ae7ec3.zip
Drop internal bdrv_pread()/bdrv_pwrite() APIs (Avi Kivity)
Now that scsi generic no longer uses bdrv_pread() and bdrv_pwrite(), we can drop the corresponding internal APIs, which overlap bdrv_read()/bdrv_write() and, being byte oriented, are unnatural for a block device. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6824 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block.c')
-rw-r--r--block.c79
1 files changed, 6 insertions, 73 deletions
diff --git a/block.c b/block.c
index e2a75b0f88..135fbe6a30 100644
--- a/block.c
+++ b/block.c
@@ -142,7 +142,7 @@ static void bdrv_register(BlockDriver *bdrv)
bdrv->bdrv_aio_write = bdrv_aio_write_em;
bdrv->bdrv_aio_cancel = bdrv_aio_cancel_em;
bdrv->aiocb_size = sizeof(BlockDriverAIOCBSync);
- } else if (!bdrv->bdrv_read && !bdrv->bdrv_pread) {
+ } else if (!bdrv->bdrv_read) {
/* add synchronous IO emulation layer */
bdrv->bdrv_read = bdrv_read_em;
bdrv->bdrv_write = bdrv_write_em;
@@ -568,22 +568,7 @@ int bdrv_read(BlockDriverState *bs, int64_t sector_num,
if (bdrv_check_request(bs, sector_num, nb_sectors))
return -EIO;
- if (drv->bdrv_pread) {
- int ret, len;
- len = nb_sectors * 512;
- ret = drv->bdrv_pread(bs, sector_num * 512, buf, len);
- if (ret < 0)
- return ret;
- else if (ret != len)
- return -EINVAL;
- else {
- bs->rd_bytes += (unsigned) len;
- bs->rd_ops ++;
- return 0;
- }
- } else {
- return drv->bdrv_read(bs, sector_num, buf, nb_sectors);
- }
+ return drv->bdrv_read(bs, sector_num, buf, nb_sectors);
}
/* Return < 0 if error. Important errors are:
@@ -603,27 +588,11 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num,
if (bdrv_check_request(bs, sector_num, nb_sectors))
return -EIO;
- if (drv->bdrv_pwrite) {
- int ret, len, count = 0;
- len = nb_sectors * 512;
- do {
- ret = drv->bdrv_pwrite(bs, sector_num * 512, buf, len - count);
- if (ret < 0) {
- printf("bdrv_write ret=%d\n", ret);
- return ret;
- }
- count += ret;
- buf += ret;
- } while (count != len);
- bs->wr_bytes += (unsigned) len;
- bs->wr_ops ++;
- return 0;
- }
return drv->bdrv_write(bs, sector_num, buf, nb_sectors);
}
-static int bdrv_pread_em(BlockDriverState *bs, int64_t offset,
- uint8_t *buf, int count1)
+int bdrv_pread(BlockDriverState *bs, int64_t offset,
+ void *buf, int count1)
{
uint8_t tmp_buf[SECTOR_SIZE];
int len, nb_sectors, count;
@@ -666,8 +635,8 @@ static int bdrv_pread_em(BlockDriverState *bs, int64_t offset,
return count1;
}
-static int bdrv_pwrite_em(BlockDriverState *bs, int64_t offset,
- const uint8_t *buf, int count1)
+int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
+ const void *buf, int count1)
{
uint8_t tmp_buf[SECTOR_SIZE];
int len, nb_sectors, count;
@@ -715,42 +684,6 @@ static int bdrv_pwrite_em(BlockDriverState *bs, int64_t offset,
}
/**
- * Read with byte offsets (needed only for file protocols)
- */
-int bdrv_pread(BlockDriverState *bs, int64_t offset,
- void *buf1, int count1)
-{
- BlockDriver *drv = bs->drv;
-
- if (!drv)
- return -ENOMEDIUM;
- if (bdrv_check_byte_request(bs, offset, count1))
- return -EIO;
-
- if (!drv->bdrv_pread)
- return bdrv_pread_em(bs, offset, buf1, count1);
- return drv->bdrv_pread(bs, offset, buf1, count1);
-}
-
-/**
- * Write with byte offsets (needed only for file protocols)
- */
-int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
- const void *buf1, int count1)
-{
- BlockDriver *drv = bs->drv;
-
- if (!drv)
- return -ENOMEDIUM;
- if (bdrv_check_byte_request(bs, offset, count1))
- return -EIO;
-
- if (!drv->bdrv_pwrite)
- return bdrv_pwrite_em(bs, offset, buf1, count1);
- return drv->bdrv_pwrite(bs, offset, buf1, count1);
-}
-
-/**
* Truncate file to 'offset' bytes (needed only for file protocols)
*/
int bdrv_truncate(BlockDriverState *bs, int64_t offset)