qmp: add autoload parameter to block-dirty-bitmap-add

Optional. Default is false.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-id: 20170628120530.31251-25-vsementsov@virtuozzo.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2017-06-28 15:05:24 +03:00 committed by Max Reitz
parent fd5ae4ccbe
commit eb738bb50f
2 changed files with 21 additions and 3 deletions

View File

@ -1984,6 +1984,7 @@ static void block_dirty_bitmap_add_prepare(BlkActionState *common,
qmp_block_dirty_bitmap_add(action->node, action->name, qmp_block_dirty_bitmap_add(action->node, action->name,
action->has_granularity, action->granularity, action->has_granularity, action->granularity,
action->has_persistent, action->persistent, action->has_persistent, action->persistent,
action->has_autoload, action->autoload,
&local_err); &local_err);
if (!local_err) { if (!local_err) {
@ -2710,6 +2711,7 @@ out:
void qmp_block_dirty_bitmap_add(const char *node, const char *name, void qmp_block_dirty_bitmap_add(const char *node, const char *name,
bool has_granularity, uint32_t granularity, bool has_granularity, uint32_t granularity,
bool has_persistent, bool persistent, bool has_persistent, bool persistent,
bool has_autoload, bool autoload,
Error **errp) Error **errp)
{ {
BlockDriverState *bs; BlockDriverState *bs;
@ -2739,6 +2741,15 @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name,
if (!has_persistent) { if (!has_persistent) {
persistent = false; persistent = false;
} }
if (!has_autoload) {
autoload = false;
}
if (has_autoload && !persistent) {
error_setg(errp, "Autoload flag must be used only for persistent "
"bitmaps");
return;
}
if (persistent && if (persistent &&
!bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp)) !bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp))
@ -2747,9 +2758,12 @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name,
} }
bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp); bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp);
if (bitmap != NULL) { if (bitmap == NULL) {
bdrv_dirty_bitmap_set_persistance(bitmap, persistent); return;
} }
bdrv_dirty_bitmap_set_persistance(bitmap, persistent);
bdrv_dirty_bitmap_set_autoload(bitmap, autoload);
} }
void qmp_block_dirty_bitmap_remove(const char *node, const char *name, void qmp_block_dirty_bitmap_remove(const char *node, const char *name,

View File

@ -1558,11 +1558,15 @@
# Qcow2 disks support persistent bitmaps. Default is false for # Qcow2 disks support persistent bitmaps. Default is false for
# block-dirty-bitmap-add. (Since: 2.10) # block-dirty-bitmap-add. (Since: 2.10)
# #
# @autoload: the bitmap will be automatically loaded when the image it is stored
# in is opened. This flag may only be specified for persistent
# bitmaps. Default is false for block-dirty-bitmap-add. (Since: 2.10)
#
# Since: 2.4 # Since: 2.4
## ##
{ 'struct': 'BlockDirtyBitmapAdd', { 'struct': 'BlockDirtyBitmapAdd',
'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32', 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32',
'*persistent': 'bool' } } '*persistent': 'bool', '*autoload': 'bool' } }
## ##
# @block-dirty-bitmap-add: # @block-dirty-bitmap-add: