cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
05bba0
From c7d5655eea99e3a62075c5ca067a6d8f670ddf9d Mon Sep 17 00:00:00 2001
05bba0
From: Max Reitz <mreitz@redhat.com>
05bba0
Date: Sat, 13 Jun 2015 16:22:00 +0200
05bba0
Subject: [PATCH 06/42] block: Catch !bs->drv in bdrv_check()
05bba0
05bba0
Message-id: <1434212556-3927-7-git-send-email-mreitz@redhat.com>
05bba0
Patchwork-id: 66025
05bba0
O-Subject: [RHEL-7.2 qemu-kvm PATCH 06/42] block: Catch !bs->drv in bdrv_check()
05bba0
Bugzilla: 1129893
05bba0
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
05bba0
RH-Acked-by: Fam Zheng <famz@redhat.com>
05bba0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
05bba0
BZ: 1129893
05bba0
05bba0
qemu-img check calls bdrv_check() twice if the first run repaired some
05bba0
inconsistencies. If the first run however again triggered corruption
05bba0
prevention (on qcow2) due to very bad inconsistencies, bs->drv may be
05bba0
NULL afterwards. Thus, bdrv_check() should check whether bs->drv is set.
05bba0
05bba0
Signed-off-by: Max Reitz <mreitz@redhat.com>
05bba0
Reviewed-by: Eric Blake <eblake@redhat.com>
05bba0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
05bba0
(cherry picked from commit 908bcd540f489f7adf2d804347905b0025d808d3)
05bba0
05bba0
Signed-off-by: Max Reitz <mreitz@redhat.com>
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 block.c | 3 +++
05bba0
 1 file changed, 3 insertions(+)
05bba0
05bba0
diff --git a/block.c b/block.c
05bba0
index caea2ea..1afa544 100644
05bba0
--- a/block.c
05bba0
+++ b/block.c
05bba0
@@ -1998,6 +1998,9 @@ bool bdrv_dev_is_medium_locked(BlockDriverState *bs)
05bba0
  */
05bba0
 int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix)
05bba0
 {
05bba0
+    if (bs->drv == NULL) {
05bba0
+        return -ENOMEDIUM;
05bba0
+    }
05bba0
     if (bs->drv->bdrv_check == NULL) {
05bba0
         return -ENOTSUP;
05bba0
     }
05bba0
-- 
05bba0
1.8.3.1
05bba0