[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/22] qcow2-bitmap: add IN_USE flag
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-devel] [PATCH 12/22] qcow2-bitmap: add IN_USE flag |
Date: |
Fri, 30 Sep 2016 13:53:18 +0300 |
This flag means that the bitmap is now in use by the software or was not
successfully saved. In any way, with this flag set the bitmap data must
be considered inconsistent and should not be loaded.
With current implementation this flag is never set, as we just remove
bitmaps from the image after loading. But it defined in qcow2 spec and
must be handled. Also, it can be used in future, if async schemes of
bitmap loading/saving are implemented.
We also remove in-use bitmaps from the image on open.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/qcow2-bitmap.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index a5be25a..8cf40f0 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -28,6 +28,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/cutils.h"
+#include "exec/log.h"
#include "block/block_int.h"
#include "block/qcow2.h"
@@ -44,7 +45,8 @@
#define BME_MAX_NAME_SIZE 1023
/* Bitmap directory entry flags */
-#define BME_RESERVED_FLAGS 0xfffffffd
+#define BME_RESERVED_FLAGS 0xfffffffc
+#define BME_FLAG_IN_USE 1
#define BME_FLAG_AUTO (1U << 1)
/* bits [1, 8] U [56, 63] are reserved */
@@ -287,6 +289,11 @@ static BdrvDirtyBitmap *load_bitmap(BlockDriverState *bs,
BdrvDirtyBitmap *bitmap = NULL;
char *name = g_strndup(dir_entry_name_notcstr(entry), entry->name_size);
+ if (entry->flags & BME_FLAG_IN_USE) {
+ error_setg(errp, "Bitmap '%s' is in use", name);
+ goto fail;
+ }
+
ret = bitmap_table_load(bs, entry, &bitmap_table);
if (ret < 0) {
error_setg_errno(errp, -ret,
@@ -533,6 +540,14 @@ int qcow2_read_bitmaps(BlockDriverState *bs, Error **errp)
for_each_bitmap_dir_entry(e, dir, dir_size) {
uint32_t fl = e->flags;
+ if (fl & BME_FLAG_IN_USE) {
+ qemu_log("qcow2 warning: "
+ "removing in_use bitmap '%.*s' for image %s.\n",
+ e->name_size, (char *)(e + 1),
bdrv_get_device_or_node_name(bs));
+
+ continue;
+ }
+
if (fl & BME_FLAG_AUTO) {
BdrvDirtyBitmap *bitmap = load_bitmap(bs, e, errp);
if (bitmap == NULL) {
--
1.8.3.1
- [Qemu-devel] [PATCH 17/22] qmp: add autoload parameter to block-dirty-bitmap-add, (continued)
- [Qemu-devel] [PATCH 17/22] qmp: add autoload parameter to block-dirty-bitmap-add, Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 02/22] tests: add hbitmap iter test, Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 13/22] qcow2-bitmap: check constraints, Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 09/22] block: introduce persistent dirty bitmaps, Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 05/22] qcow2-bitmap: structs and consts, Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 20/22] qcow2-dirty-bitmap: refcounts, Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 04/22] block/dirty-bitmap: add deserialize_ones func, Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 07/22] qcow2-bitmap: introduce auto-loading bitmaps, Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 11/22] qcow2-bitmap: add qcow2_store_persistent_bitmaps(), Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 22/22] specs/qcow2: do not use wording 'bitmap header', Vladimir Sementsov-Ogievskiy, 2016/09/30
- [Qemu-devel] [PATCH 12/22] qcow2-bitmap: add IN_USE flag,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-devel] [PATCH 08/22] block/dirty-bitmap: add autoload field to BdrvDirtyBitmap, Vladimir Sementsov-Ogievskiy, 2016/09/30