blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
/*
|
|
|
|
* QEMU block dirty bitmap QMP commands
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2008 Fabrice Bellard
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or
|
|
|
|
* later. See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following copyright and
|
|
|
|
* permission notice:
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2008 Fabrice Bellard
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
|
2022-12-21 16:35:49 +03:00
|
|
|
#include "block/block-io.h"
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
#include "block/block_int.h"
|
2022-12-21 16:35:49 +03:00
|
|
|
#include "block/dirty-bitmap.h"
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
#include "qapi/qapi-commands-block.h"
|
|
|
|
#include "qapi/error.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* block_dirty_bitmap_lookup:
|
|
|
|
* Return a dirty bitmap (if present), after validating
|
|
|
|
* the node reference and bitmap names.
|
|
|
|
*
|
|
|
|
* @node: The name of the BDS node to search for bitmaps
|
|
|
|
* @name: The name of the bitmap to search for
|
|
|
|
* @pbs: Output pointer for BDS lookup, if desired. Can be NULL.
|
|
|
|
* @errp: Output pointer for error information. Can be NULL.
|
|
|
|
*
|
|
|
|
* @return: A bitmap object on success, or NULL on failure.
|
|
|
|
*/
|
|
|
|
BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node,
|
|
|
|
const char *name,
|
|
|
|
BlockDriverState **pbs,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
BlockDriverState *bs;
|
|
|
|
BdrvDirtyBitmap *bitmap;
|
|
|
|
|
2022-03-03 18:15:57 +03:00
|
|
|
GLOBAL_STATE_CODE();
|
|
|
|
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
if (!node) {
|
|
|
|
error_setg(errp, "Node cannot be NULL");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!name) {
|
|
|
|
error_setg(errp, "Bitmap name cannot be NULL");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
bs = bdrv_lookup_bs(node, node, NULL);
|
|
|
|
if (!bs) {
|
|
|
|
error_setg(errp, "Node '%s' not found", node);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bitmap = bdrv_find_dirty_bitmap(bs, name);
|
|
|
|
if (!bitmap) {
|
|
|
|
error_setg(errp, "Dirty bitmap '%s' not found", name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pbs) {
|
|
|
|
*pbs = bs;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qmp_block_dirty_bitmap_add(const char *node, const char *name,
|
|
|
|
bool has_granularity, uint32_t granularity,
|
|
|
|
bool has_persistent, bool persistent,
|
|
|
|
bool has_disabled, bool disabled,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
BlockDriverState *bs;
|
|
|
|
BdrvDirtyBitmap *bitmap;
|
|
|
|
AioContext *aio_context;
|
|
|
|
|
|
|
|
if (!name || name[0] == '\0') {
|
|
|
|
error_setg(errp, "Bitmap name cannot be empty");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bs = bdrv_lookup_bs(node, node, errp);
|
|
|
|
if (!bs) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aio_context = bdrv_get_aio_context(bs);
|
|
|
|
aio_context_acquire(aio_context);
|
|
|
|
|
|
|
|
if (has_granularity) {
|
|
|
|
if (granularity < 512 || !is_power_of_2(granularity)) {
|
|
|
|
error_setg(errp, "Granularity must be power of 2 "
|
|
|
|
"and at least 512");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Default to cluster size, if available: */
|
|
|
|
granularity = bdrv_get_default_bitmap_granularity(bs);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_persistent) {
|
|
|
|
persistent = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_disabled) {
|
|
|
|
disabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (persistent &&
|
|
|
|
!bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp))
|
|
|
|
{
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp);
|
|
|
|
if (bitmap == NULL) {
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
bdrv_disable_dirty_bitmap(bitmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
bdrv_dirty_bitmap_set_persistence(bitmap, persistent);
|
|
|
|
|
|
|
|
out:
|
|
|
|
aio_context_release(aio_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
BdrvDirtyBitmap *block_dirty_bitmap_remove(const char *node, const char *name,
|
|
|
|
bool release,
|
|
|
|
BlockDriverState **bitmap_bs,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
BlockDriverState *bs;
|
|
|
|
BdrvDirtyBitmap *bitmap;
|
|
|
|
AioContext *aio_context;
|
|
|
|
|
2022-03-03 18:15:57 +03:00
|
|
|
GLOBAL_STATE_CODE();
|
|
|
|
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
|
|
|
|
if (!bitmap || !bs) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
aio_context = bdrv_get_aio_context(bs);
|
|
|
|
aio_context_acquire(aio_context);
|
|
|
|
|
|
|
|
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_BUSY | BDRV_BITMAP_RO,
|
|
|
|
errp)) {
|
|
|
|
aio_context_release(aio_context);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bdrv_dirty_bitmap_get_persistence(bitmap) &&
|
|
|
|
bdrv_remove_persistent_dirty_bitmap(bs, name, errp) < 0)
|
|
|
|
{
|
|
|
|
aio_context_release(aio_context);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (release) {
|
|
|
|
bdrv_release_dirty_bitmap(bitmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bitmap_bs) {
|
|
|
|
*bitmap_bs = bs;
|
|
|
|
}
|
|
|
|
|
|
|
|
aio_context_release(aio_context);
|
|
|
|
return release ? NULL : bitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
block_dirty_bitmap_remove(node, name, true, NULL, errp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Completely clear a bitmap, for the purposes of synchronizing a bitmap
|
|
|
|
* immediately after a full backup operation.
|
|
|
|
*/
|
|
|
|
void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
BdrvDirtyBitmap *bitmap;
|
|
|
|
BlockDriverState *bs;
|
|
|
|
|
|
|
|
bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
|
|
|
|
if (!bitmap || !bs) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bdrv_clear_dirty_bitmap(bitmap, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void qmp_block_dirty_bitmap_enable(const char *node, const char *name,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
BlockDriverState *bs;
|
|
|
|
BdrvDirtyBitmap *bitmap;
|
|
|
|
|
|
|
|
bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
|
|
|
|
if (!bitmap) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bdrv_enable_dirty_bitmap(bitmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void qmp_block_dirty_bitmap_disable(const char *node, const char *name,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
BlockDriverState *bs;
|
|
|
|
BdrvDirtyBitmap *bitmap;
|
|
|
|
|
|
|
|
bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
|
|
|
|
if (!bitmap) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bdrv_disable_dirty_bitmap(bitmap);
|
|
|
|
}
|
|
|
|
|
2023-09-21 15:13:09 +03:00
|
|
|
BdrvDirtyBitmap *block_dirty_bitmap_merge(const char *dst_node,
|
|
|
|
const char *dst_bitmap,
|
2022-03-15 00:32:24 +03:00
|
|
|
BlockDirtyBitmapOrStrList *bms,
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
HBitmap **backup, Error **errp)
|
|
|
|
{
|
|
|
|
BlockDriverState *bs;
|
2022-05-17 14:12:05 +03:00
|
|
|
BdrvDirtyBitmap *dst, *src;
|
2022-03-15 00:32:24 +03:00
|
|
|
BlockDirtyBitmapOrStrList *lst;
|
2023-09-21 15:13:09 +03:00
|
|
|
const char *src_node, *src_bitmap;
|
2022-05-17 14:12:05 +03:00
|
|
|
HBitmap *local_backup = NULL;
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
|
2022-03-03 18:15:57 +03:00
|
|
|
GLOBAL_STATE_CODE();
|
|
|
|
|
2023-09-21 15:13:09 +03:00
|
|
|
dst = block_dirty_bitmap_lookup(dst_node, dst_bitmap, &bs, errp);
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
if (!dst) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (lst = bms; lst; lst = lst->next) {
|
|
|
|
switch (lst->value->type) {
|
|
|
|
case QTYPE_QSTRING:
|
2023-09-21 15:13:09 +03:00
|
|
|
src_bitmap = lst->value->u.local;
|
|
|
|
src = bdrv_find_dirty_bitmap(bs, src_bitmap);
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
if (!src) {
|
2023-09-21 15:13:09 +03:00
|
|
|
error_setg(errp, "Dirty bitmap '%s' not found", src_bitmap);
|
2022-05-17 14:12:05 +03:00
|
|
|
goto fail;
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case QTYPE_QDICT:
|
2023-09-21 15:13:09 +03:00
|
|
|
src_node = lst->value->u.external.node;
|
|
|
|
src_bitmap = lst->value->u.external.name;
|
|
|
|
src = block_dirty_bitmap_lookup(src_node, src_bitmap, NULL, errp);
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
if (!src) {
|
2022-05-17 14:12:05 +03:00
|
|
|
goto fail;
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2022-05-17 14:12:05 +03:00
|
|
|
/* We do backup only for first merge operation */
|
|
|
|
if (!bdrv_merge_dirty_bitmap(dst, src,
|
|
|
|
local_backup ? NULL : &local_backup,
|
|
|
|
errp))
|
|
|
|
{
|
|
|
|
goto fail;
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-17 14:12:05 +03:00
|
|
|
if (backup) {
|
|
|
|
*backup = local_backup;
|
|
|
|
} else {
|
|
|
|
hbitmap_free(local_backup);
|
2022-05-17 14:12:04 +03:00
|
|
|
}
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
|
|
|
|
return dst;
|
2022-05-17 14:12:05 +03:00
|
|
|
|
|
|
|
fail:
|
|
|
|
if (local_backup) {
|
|
|
|
bdrv_restore_dirty_bitmap(dst, local_backup);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void qmp_block_dirty_bitmap_merge(const char *node, const char *target,
|
2022-03-15 00:32:24 +03:00
|
|
|
BlockDirtyBitmapOrStrList *bitmaps,
|
blockdev: Split off basic bitmap operations for qemu-img
Upcoming patches want to add some basic bitmap manipulation abilities
to qemu-img. But blockdev.o is too heavyweight to link into qemu-img
(among other things, it would drag in block jobs and transaction
support - qemu-img does offline manipulation, where atomicity is less
important because there are no concurrent modifications to compete
with), so it's time to split off the bare bones of what we will need
into a new file block/monitor/bitmap-qmp-cmds.o.
This is sufficient to expose 6 QMP commands for use by qemu-img (add,
remove, clear, enable, disable, merge), as well as move the three
helper functions touched in the previous patch. Regarding
MAINTAINERS, the new file is automatically part of block core, but
also makes sense as related to other dirty bitmap files.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513011648.166876-6-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2020-05-18 21:53:07 +03:00
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
block_dirty_bitmap_merge(node, target, bitmaps, NULL, errp);
|
|
|
|
}
|