aboutsummaryrefslogtreecommitdiff
path: root/block/raw.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-05-09 16:49:58 +0200
committerKevin Wolf <kwolf@redhat.com>2012-06-15 14:03:42 +0200
commit5500316ded9db5b10072334cde1e27fb37682240 (patch)
treec02ce4c1a29b4a05d8860b6fec6f99d5b9eb26a2 /block/raw.c
parent87267753a36798e25262ee48264bea2ab70921aa (diff)
downloadqemu-5500316ded9db5b10072334cde1e27fb37682240.zip
qemu-5500316ded9db5b10072334cde1e27fb37682240.tar.gz
qemu-5500316ded9db5b10072334cde1e27fb37682240.tar.bz2
block: implement is_allocated for raw
Either FIEMAP, or SEEK_DATA+SEEK_HOLE can be used to implement the is_allocated callback for raw files. On Linux ext4, btrfs and XFS all support it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/raw.c')
-rw-r--r--block/raw.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/block/raw.c b/block/raw.c
index 7086e31..09d9b48 100644
--- a/block/raw.c
+++ b/block/raw.c
@@ -25,6 +25,13 @@ static void raw_close(BlockDriverState *bs)
{
}
+static int coroutine_fn raw_co_is_allocated(BlockDriverState *bs,
+ int64_t sector_num,
+ int nb_sectors, int *pnum)
+{
+ return bdrv_co_is_allocated(bs->file, sector_num, nb_sectors, pnum);
+}
+
static int64_t raw_getlength(BlockDriverState *bs)
{
return bdrv_getlength(bs->file);
@@ -108,6 +115,7 @@ static BlockDriver bdrv_raw = {
.bdrv_co_readv = raw_co_readv,
.bdrv_co_writev = raw_co_writev,
+ .bdrv_co_is_allocated = raw_co_is_allocated,
.bdrv_co_discard = raw_co_discard,
.bdrv_probe = raw_probe,