qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 15/17] raw: add get_info


From: Paolo Bonzini
Subject: [Qemu-devel] [RFC PATCH 15/17] raw: add get_info
Date: Thu, 8 Mar 2012 18:15:15 +0100

Now that everything is in place we can declare discard support
for the file protocol (and the raw format).

Signed-off-by: Paolo Bonzini <address@hidden>
---
 block/raw-posix.c |    9 +++++++++
 block/raw.c       |    6 ++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index f23d92b..56aabc7 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -635,6 +635,14 @@ static coroutine_fn int raw_co_discard(BlockDriverState 
*bs,
 #endif
 }
 
+static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+{
+    bdi->cluster_size = BDRV_SECTOR_SIZE;
+    bdi->discard_zeroes_data = true;
+    bdi->discard_granularity = 1;
+    return 0;
+}
+
 static QEMUOptionParameter raw_create_options[] = {
     {
         .name = BLOCK_OPT_SIZE,
@@ -660,6 +668,7 @@ static BlockDriver bdrv_file = {
 
     .bdrv_truncate = raw_truncate,
     .bdrv_getlength = raw_getlength,
+    .bdrv_get_info = raw_get_info,
     .bdrv_get_allocated_file_size
                         = raw_get_allocated_file_size,
 
diff --git a/block/raw.c b/block/raw.c
index 1cdac0c..3618c2d 100644
--- a/block/raw.c
+++ b/block/raw.c
@@ -35,6 +35,11 @@ static int64_t raw_getlength(BlockDriverState *bs)
     return bdrv_getlength(bs->file);
 }
 
+static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+{
+    return bdrv_get_info(bs->file, bdi);
+}
+
 static int raw_truncate(BlockDriverState *bs, int64_t offset)
 {
     return bdrv_truncate(bs->file, offset);
@@ -118,6 +123,7 @@ static BlockDriver bdrv_raw = {
 
     .bdrv_probe         = raw_probe,
     .bdrv_getlength     = raw_getlength,
+    .bdrv_get_info      = raw_get_info,
     .bdrv_truncate      = raw_truncate,
 
     .bdrv_is_inserted   = raw_is_inserted,
-- 
1.7.7.6





reply via email to

[Prev in Thread] Current Thread [Next in Thread]