|
|
ddf19c |
From 41d6c207c482093df8669f7cdcdb49bb25dba741 Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: Eric Blake <eblake@redhat.com>
|
|
|
ddf19c |
Date: Tue, 2 Jun 2020 02:34:12 +0100
|
|
|
ddf19c |
Subject: [PATCH 07/26] block: Make it easier to learn which BDS support
|
|
|
ddf19c |
bitmaps
|
|
|
ddf19c |
MIME-Version: 1.0
|
|
|
ddf19c |
Content-Type: text/plain; charset=UTF-8
|
|
|
ddf19c |
Content-Transfer-Encoding: 8bit
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Eric Blake <eblake@redhat.com>
|
|
|
ddf19c |
Message-id: <20200602023420.2133649-5-eblake@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 97071
|
|
|
ddf19c |
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 04/12] block: Make it easier to learn which BDS support bitmaps
|
|
|
ddf19c |
Bugzilla: 1779893 1779904
|
|
|
ddf19c |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
Upcoming patches will enhance bitmap support in qemu-img, but in doing
|
|
|
ddf19c |
so, it turns out to be nice to suppress output when persistent bitmaps
|
|
|
ddf19c |
make no sense (such as on a qcow2 v2 image). Add a hook to make this
|
|
|
ddf19c |
easier to query.
|
|
|
ddf19c |
|
|
|
ddf19c |
This patch adds a new callback .bdrv_supports_persistent_dirty_bitmap,
|
|
|
ddf19c |
rather than trying to shoehorn the answer in via existing callbacks.
|
|
|
ddf19c |
In particular, while it might have been possible to overload
|
|
|
ddf19c |
.bdrv_co_can_store_new_dirty_bitmap to special-case a NULL input to
|
|
|
ddf19c |
answer whether any persistent bitmaps are supported, that is at odds
|
|
|
ddf19c |
with whether a particular bitmap can be stored (for example, even on
|
|
|
ddf19c |
an image that supports persistent bitmaps but has currently filled up
|
|
|
ddf19c |
the maximum number of bitmaps, attempts to store another one should
|
|
|
ddf19c |
fail); and the new functionality doesn't require coroutine safety.
|
|
|
ddf19c |
Similarly, we could have added one more piece of information to
|
|
|
ddf19c |
.bdrv_get_info, but then again, most callers to that function tend to
|
|
|
ddf19c |
already discard extraneous information, and making it a catch-all
|
|
|
ddf19c |
rather than a series of dedicated scalar queries hasn't really
|
|
|
ddf19c |
simplified life.
|
|
|
ddf19c |
|
|
|
ddf19c |
In the future, when we improve the ability to look up bitmaps through
|
|
|
ddf19c |
a filter, we will probably also want to teach the block layer to
|
|
|
ddf19c |
automatically let filters pass this request on through.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
ddf19c |
Message-Id: <20200513011648.166876-4-eblake@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
ddf19c |
(cherry picked from commit ef893b5c84f3199d777e33966dc28839f71b1a5c)
|
|
|
ddf19c |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
block/dirty-bitmap.c | 9 +++++++++
|
|
|
ddf19c |
block/qcow2-bitmap.c | 7 +++++++
|
|
|
ddf19c |
block/qcow2.c | 2 ++
|
|
|
ddf19c |
block/qcow2.h | 1 +
|
|
|
ddf19c |
include/block/block_int.h | 1 +
|
|
|
ddf19c |
include/block/dirty-bitmap.h | 1 +
|
|
|
ddf19c |
6 files changed, 21 insertions(+)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
|
|
|
ddf19c |
index 7039e82..2f96acc 100644
|
|
|
ddf19c |
--- a/block/dirty-bitmap.c
|
|
|
ddf19c |
+++ b/block/dirty-bitmap.c
|
|
|
ddf19c |
@@ -478,6 +478,15 @@ int bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name,
|
|
|
ddf19c |
}
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
+bool
|
|
|
ddf19c |
+bdrv_supports_persistent_dirty_bitmap(BlockDriverState *bs)
|
|
|
ddf19c |
+{
|
|
|
ddf19c |
+ if (bs->drv && bs->drv->bdrv_supports_persistent_dirty_bitmap) {
|
|
|
ddf19c |
+ return bs->drv->bdrv_supports_persistent_dirty_bitmap(bs);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ return false;
|
|
|
ddf19c |
+}
|
|
|
ddf19c |
+
|
|
|
ddf19c |
static bool coroutine_fn
|
|
|
ddf19c |
bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
|
|
|
ddf19c |
uint32_t granularity, Error **errp)
|
|
|
ddf19c |
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
|
|
|
ddf19c |
index c6c8ebb..cbac905 100644
|
|
|
ddf19c |
--- a/block/qcow2-bitmap.c
|
|
|
ddf19c |
+++ b/block/qcow2-bitmap.c
|
|
|
ddf19c |
@@ -1759,3 +1759,10 @@ fail:
|
|
|
ddf19c |
name, bdrv_get_device_or_node_name(bs));
|
|
|
ddf19c |
return false;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+bool qcow2_supports_persistent_dirty_bitmap(BlockDriverState *bs)
|
|
|
ddf19c |
+{
|
|
|
ddf19c |
+ BDRVQcow2State *s = bs->opaque;
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ return s->qcow_version >= 3;
|
|
|
ddf19c |
+}
|
|
|
ddf19c |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
ddf19c |
index af0ad4a..36b0f7d 100644
|
|
|
ddf19c |
--- a/block/qcow2.c
|
|
|
ddf19c |
+++ b/block/qcow2.c
|
|
|
ddf19c |
@@ -5551,6 +5551,8 @@ BlockDriver bdrv_qcow2 = {
|
|
|
ddf19c |
.bdrv_detach_aio_context = qcow2_detach_aio_context,
|
|
|
ddf19c |
.bdrv_attach_aio_context = qcow2_attach_aio_context,
|
|
|
ddf19c |
|
|
|
ddf19c |
+ .bdrv_supports_persistent_dirty_bitmap =
|
|
|
ddf19c |
+ qcow2_supports_persistent_dirty_bitmap,
|
|
|
ddf19c |
.bdrv_co_can_store_new_dirty_bitmap = qcow2_co_can_store_new_dirty_bitmap,
|
|
|
ddf19c |
.bdrv_co_remove_persistent_dirty_bitmap =
|
|
|
ddf19c |
qcow2_co_remove_persistent_dirty_bitmap,
|
|
|
ddf19c |
diff --git a/block/qcow2.h b/block/qcow2.h
|
|
|
ddf19c |
index 0942126..ceb1ceb 100644
|
|
|
ddf19c |
--- a/block/qcow2.h
|
|
|
ddf19c |
+++ b/block/qcow2.h
|
|
|
ddf19c |
@@ -767,6 +767,7 @@ bool qcow2_co_can_store_new_dirty_bitmap(BlockDriverState *bs,
|
|
|
ddf19c |
int qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs,
|
|
|
ddf19c |
const char *name,
|
|
|
ddf19c |
Error **errp);
|
|
|
ddf19c |
+bool qcow2_supports_persistent_dirty_bitmap(BlockDriverState *bs);
|
|
|
ddf19c |
|
|
|
ddf19c |
ssize_t coroutine_fn
|
|
|
ddf19c |
qcow2_co_compress(BlockDriverState *bs, void *dest, size_t dest_size,
|
|
|
ddf19c |
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
|
ddf19c |
index 562dca1..cc18e8d 100644
|
|
|
ddf19c |
--- a/include/block/block_int.h
|
|
|
ddf19c |
+++ b/include/block/block_int.h
|
|
|
ddf19c |
@@ -568,6 +568,7 @@ struct BlockDriver {
|
|
|
ddf19c |
uint64_t parent_perm, uint64_t parent_shared,
|
|
|
ddf19c |
uint64_t *nperm, uint64_t *nshared);
|
|
|
ddf19c |
|
|
|
ddf19c |
+ bool (*bdrv_supports_persistent_dirty_bitmap)(BlockDriverState *bs);
|
|
|
ddf19c |
bool (*bdrv_co_can_store_new_dirty_bitmap)(BlockDriverState *bs,
|
|
|
ddf19c |
const char *name,
|
|
|
ddf19c |
uint32_t granularity,
|
|
|
ddf19c |
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
|
|
|
ddf19c |
index e2b20ec..f6e9a38 100644
|
|
|
ddf19c |
--- a/include/block/dirty-bitmap.h
|
|
|
ddf19c |
+++ b/include/block/dirty-bitmap.h
|
|
|
ddf19c |
@@ -16,6 +16,7 @@ typedef enum BitmapCheckFlags {
|
|
|
ddf19c |
|
|
|
ddf19c |
#define BDRV_BITMAP_MAX_NAME_SIZE 1023
|
|
|
ddf19c |
|
|
|
ddf19c |
+bool bdrv_supports_persistent_dirty_bitmap(BlockDriverState *bs);
|
|
|
ddf19c |
BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
|
|
|
ddf19c |
uint32_t granularity,
|
|
|
ddf19c |
const char *name,
|
|
|
ddf19c |
--
|
|
|
ddf19c |
1.8.3.1
|
|
|
ddf19c |
|