|
|
7711c0 |
From 09fa7fdc08f3edc26fd143bd7f3f6a863e6f1f17 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Wed, 3 Apr 2019 22:42:50 +0200
|
|
|
7711c0 |
Subject: [PATCH 155/163] block/qcow2-bitmap: Don't check size for IN_USE
|
|
|
7711c0 |
bitmap
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190403224253.5251-3-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 85435
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 2/5] block/qcow2-bitmap: Don't check size for IN_USE bitmap
|
|
|
7711c0 |
Bugzilla: 1666884
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
We are going to allow image resize when there are persistent bitmaps.
|
|
|
7711c0 |
It may lead to appearing of inconsistent bitmaps (IN_USE=1) with
|
|
|
7711c0 |
inconsistent size. But we still want to load them as inconsistent.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
Message-id: 20190311185147.52309-3-vsementsov@virtuozzo.com
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit bf5f0cf5d819cce45dd578a19386d8b60022654f)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
block/qcow2-bitmap.c | 21 ++++++++++++++++++---
|
|
|
7711c0 |
1 file changed, 18 insertions(+), 3 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
|
|
|
7711c0 |
index 4d093da..fe4a6a2 100644
|
|
|
7711c0 |
--- a/block/qcow2-bitmap.c
|
|
|
7711c0 |
+++ b/block/qcow2-bitmap.c
|
|
|
7711c0 |
@@ -464,10 +464,25 @@ static int check_dir_entry(BlockDriverState *bs, Qcow2BitmapDirEntry *entry)
|
|
|
7711c0 |
return len;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
- fail = (phys_bitmap_bytes > BME_MAX_PHYS_SIZE) ||
|
|
|
7711c0 |
- (len > ((phys_bitmap_bytes * 8) << entry->granularity_bits));
|
|
|
7711c0 |
+ if (phys_bitmap_bytes > BME_MAX_PHYS_SIZE) {
|
|
|
7711c0 |
+ return -EINVAL;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
|
|
|
7711c0 |
- return fail ? -EINVAL : 0;
|
|
|
7711c0 |
+ if (!(entry->flags & BME_FLAG_IN_USE) &&
|
|
|
7711c0 |
+ (len > ((phys_bitmap_bytes * 8) << entry->granularity_bits)))
|
|
|
7711c0 |
+ {
|
|
|
7711c0 |
+ /*
|
|
|
7711c0 |
+ * We've loaded a valid bitmap (IN_USE not set) or we are going to
|
|
|
7711c0 |
+ * store a valid bitmap, but the allocated bitmap table size is not
|
|
|
7711c0 |
+ * enough to store this bitmap.
|
|
|
7711c0 |
+ *
|
|
|
7711c0 |
+ * Note, that it's OK to have an invalid bitmap with invalid size due
|
|
|
7711c0 |
+ * to a bitmap that was not correctly saved after image resize.
|
|
|
7711c0 |
+ */
|
|
|
7711c0 |
+ return -EINVAL;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ return 0;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
static inline void bitmap_directory_to_be(uint8_t *dir, size_t size)
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|