qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,
	qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH v2 3/4] block/null-{co, aio}: Implement get_block_status()
Date: Thu, 24 Mar 2016 23:33:59 +0100	[thread overview]
Message-ID: <1458858840-3859-4-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1458858840-3859-1-git-send-email-mreitz@redhat.com>

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/null.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/block/null.c b/block/null.c
index a7df386..f4b3bba 100644
--- a/block/null.c
+++ b/block/null.c
@@ -204,6 +204,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",
@@ -217,6 +235,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 = {
@@ -232,6 +252,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)
-- 
2.7.4

  parent reply	other threads:[~2016-03-24 22:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24 22:33 [Qemu-devel] [PATCH v2 0/4] qemu-img: Fix preallocation with -S 0 for convert Max Reitz
2016-03-24 22:33 ` [Qemu-devel] [PATCH v2 1/4] " Max Reitz
2016-03-25  6:36   ` Fam Zheng
2016-03-24 22:33 ` [Qemu-devel] [PATCH v2 2/4] block/null-{co, aio}: Allow reading zeroes Max Reitz
2016-03-24 22:55   ` Eric Blake
2016-03-25  2:01   ` Fam Zheng
2016-03-24 22:33 ` Max Reitz [this message]
2016-03-25  2:02   ` [Qemu-devel] [PATCH v2 3/4] block/null-{co, aio}: Implement get_block_status() Fam Zheng
2016-03-24 22:34 ` [Qemu-devel] [PATCH v2 4/4] iotests: Test qemu-img convert -S 0 behavior Max Reitz
2016-03-25  6:43   ` Fam Zheng
2016-03-29 16:16 ` [Qemu-devel] [PATCH v2 0/4] qemu-img: Fix preallocation with -S 0 for convert Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458858840-3859-4-git-send-email-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).