summaryrefslogtreecommitdiff
path: root/block/raw.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-12-16 19:36:31 +0100
committerKevin Wolf <kwolf@redhat.com>2010-12-17 16:11:03 +0100
commitd54f28d2875d7743267fe094b987042c8d6f8da5 (patch)
tree3869081b39a96da24bff96e06099794960dd9ccf /block/raw.c
parent3f0854e8b659c2b7087f04d4f0e4bf3d123b8048 (diff)
downloadqemu-d54f28d2875d7743267fe094b987042c8d6f8da5.tar.gz
qemu-d54f28d2875d7743267fe094b987042c8d6f8da5.tar.bz2
qemu-d54f28d2875d7743267fe094b987042c8d6f8da5.zip
block: add discard support
Add a new bdrv_discard method to free blocks in a mapping image, and a new drive property to set the granularity for these discard. If no discard granularity support is set discard support is disabled. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/raw.c')
-rw-r--r--block/raw.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/block/raw.c b/block/raw.c
index 1980debc00..b0f72d6a62 100644
--- a/block/raw.c
+++ b/block/raw.c
@@ -65,6 +65,11 @@ static int raw_probe(const uint8_t *buf, int buf_size, const char *filename)
return 1; /* everything can be opened as raw image */
}
+static int raw_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
+{
+ return bdrv_discard(bs->file, sector_num, nb_sectors);
+}
+
static int raw_is_inserted(BlockDriverState *bs)
{
return bdrv_is_inserted(bs->file);
@@ -130,6 +135,7 @@ static BlockDriver bdrv_raw = {
.bdrv_aio_readv = raw_aio_readv,
.bdrv_aio_writev = raw_aio_writev,
.bdrv_aio_flush = raw_aio_flush,
+ .bdrv_discard = raw_discard,
.bdrv_is_inserted = raw_is_inserted,
.bdrv_eject = raw_eject,