aboutsummaryrefslogtreecommitdiff
path: root/block/null.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2016-03-24 23:33:59 +0100
committerKevin Wolf <kwolf@redhat.com>2016-03-30 12:16:04 +0200
commita90639270df14ee8bd2aec38243c24348c9053fa (patch)
treebbf156dbbdb39f9696529f4c35f2c06e31266369 /block/null.c
parentcd219eb1e55a5bf9eab4193cafaf6ab188fc2752 (diff)
block/null-{co,aio}: Implement get_block_status()
Signed-off-by: Max Reitz <mreitz@redhat.com> Acked-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/null.c')
-rw-r--r--block/null.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/block/null.c b/block/null.c
index 7646bb0e23..396500babd 100644
--- a/block/null.c
+++ b/block/null.c
@@ -205,6 +205,24 @@ static int null_reopen_prepare(BDRVReopenState *reopen_state,
return 0;
}
+static int64_t coroutine_fn null_co_get_block_status(BlockDriverState *bs,
+ int64_t sector_num,
+ int nb_sectors, int *pnum,
+ BlockDriverState **file)
+{
+ BDRVNullState *s = bs->opaque;
+ off_t start = sector_num * BDRV_SECTOR_SIZE;
+
+ *pnum = nb_sectors;
+ *file = bs;
+
+ if (s->read_zeroes) {
+ return BDRV_BLOCK_OFFSET_VALID | start | BDRV_BLOCK_ZERO;
+ } else {
+ return BDRV_BLOCK_OFFSET_VALID | start;
+ }
+}
+
static BlockDriver bdrv_null_co = {
.format_name = "null-co",
.protocol_name = "null-co",
@@ -218,6 +236,8 @@ static BlockDriver bdrv_null_co = {
.bdrv_co_writev = null_co_writev,
.bdrv_co_flush_to_disk = null_co_flush,
.bdrv_reopen_prepare = null_reopen_prepare,
+
+ .bdrv_co_get_block_status = null_co_get_block_status,
};
static BlockDriver bdrv_null_aio = {
@@ -233,6 +253,8 @@ static BlockDriver bdrv_null_aio = {
.bdrv_aio_writev = null_aio_writev,
.bdrv_aio_flush = null_aio_flush,
.bdrv_reopen_prepare = null_reopen_prepare,
+
+ .bdrv_co_get_block_status = null_co_get_block_status,
};
static void bdrv_null_init(void)