yeahuh / rpms / qemu-kvm

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