thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
218e99
From 91a73a0f154a7d8f2c4949ea882f684d55c916e4 Mon Sep 17 00:00:00 2001
218e99
From: Paolo Bonzini <pbonzini@redhat.com>
218e99
Date: Fri, 18 Oct 2013 08:14:47 +0200
218e99
Subject: [PATCH 22/81] block: look for zero blocks in bs->file
218e99
218e99
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
218e99
Message-id: <1382084091-16636-23-git-send-email-pbonzini@redhat.com>
218e99
Patchwork-id: 55005
218e99
O-Subject: [RHEL 7.0 qemu-kvm PATCH 22/26] block: look for zero blocks in bs->file
218e99
Bugzilla: 989646
218e99
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
218e99
Reviewed-by: Eric Blake <eblake@redhat.com>
218e99
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
(cherry picked from commit 5daa74a6ebce7543aaad178c4061dc087bb4c705)
218e99
---
218e99
 block.c | 16 +++++++++++++++-
218e99
 1 file changed, 15 insertions(+), 1 deletion(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block.c |   16 +++++++++++++++-
218e99
 1 files changed, 15 insertions(+), 1 deletions(-)
218e99
218e99
diff --git a/block.c b/block.c
218e99
index 2a4a9dd..f993b2e 100644
218e99
--- a/block.c
218e99
+++ b/block.c
218e99
@@ -3041,7 +3041,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
218e99
 {
218e99
     int64_t length;
218e99
     int64_t n;
218e99
-    int64_t ret;
218e99
+    int64_t ret, ret2;
218e99
 
218e99
     length = bdrv_getlength(bs);
218e99
     if (length < 0) {
218e99
@@ -3083,6 +3083,20 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
218e99
             }
218e99
         }
218e99
     }
218e99
+
218e99
+    if (bs->file &&
218e99
+        (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&
218e99
+        (ret & BDRV_BLOCK_OFFSET_VALID)) {
218e99
+        ret2 = bdrv_co_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS,
218e99
+                                        *pnum, pnum);
218e99
+        if (ret2 >= 0) {
218e99
+            /* Ignore errors.  This is just providing extra information, it
218e99
+             * is useful but not necessary.
218e99
+             */
218e99
+            ret |= (ret2 & BDRV_BLOCK_ZERO);
218e99
+        }
218e99
+    }
218e99
+
218e99
     return ret;
218e99
 }
218e99
 
218e99
-- 
218e99
1.7.1
218e99