Blob Blame Raw
From 815d053228bffeb0c2774f283c249ddf7f5fb03e Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Fri, 18 Oct 2013 08:14:46 +0200
Subject: [PATCH 21/81] block: add default get_block_status implementation for protocols

RH-Author: Paolo Bonzini <pbonzini@redhat.com>
Message-id: <1382084091-16636-22-git-send-email-pbonzini@redhat.com>
Patchwork-id: 55004
O-Subject: [RHEL 7.0 qemu-kvm PATCH 21/26] block: add default get_block_status implementation for protocols
Bugzilla: 989646
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>

Protocols return raw data, so you can assume the offsets to pass
through unchanged.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 918e92d71b38306a6bf4fedfd1109367f1425587)
---
 block.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 block.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/block.c b/block.c
index 36a2f24..2a4a9dd 100644
--- a/block.c
+++ b/block.c
@@ -3060,7 +3060,11 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
 
     if (!bs->drv->bdrv_co_get_block_status) {
         *pnum = nb_sectors;
-        return BDRV_BLOCK_DATA;
+        ret = BDRV_BLOCK_DATA;
+        if (bs->drv->protocol_name) {
+            ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);
+        }
+        return ret;
     }
 
     ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum);
-- 
1.7.1