mirror of https://gitee.com/openkylin/qemu.git
Pull request
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE+ber27ys35W+dsvQfe+BBqr8OQ4FAlxtldwACgkQfe+BBqr8 OQ62Wg//Qt4wYDs8HT3TzHrfQtfpCp3rKp4rgsK2EE0mogeTW1oy2Gq5z8FEGkkK kYTNixDX2+qLfdu288G5xJvKSHlZ5CFSPjVtV7S2r6VON2H/5ki+as7O2evLgTEQ fVf9tivIC9dHXg/N+lOLZgiC3Ft+vX8oql7NYr0XtRd5xrJ7e1SaCXcnfgTgIy7N v65U4x4lvpvwvMZheBxZrM3rUNcnEldK7/r4p5B7Vh+PtDKUhzwXMa7ccE6cOBcT nUYNW0rp25fG7fEvrt7la8n7oEYBaWmxd/DaaAptDUzhrEm3EIIems1ns5Z287Oy goZAeZrLmkMDIs1i0OZc8w4So3pRZoeUaicNrPOUTU4Ze2fMwU+wGp1fRh7R8o9Y 6KyG2e28uAxzgYZCB3j55cheok9bfztKDSqA+4LN3FKdSveoSVIo6KmCu6Aij7A9 869wz9huiGdW2YlrcoV3KuweY16OUaLZlN9vmudUCG+s5URUzIsMLKOu2ZmDBfWo 4w0q0YimlysHZfR1hYVwoPp5rUkqvaCv3qB86DfFFnrD8NNGqdKlsxUIBRRo4DTX 8z/m14OPLKviihBtma2oFap4TPrV4KDNEGP61JzxkJsepj1gMtDRhp7lpuTdCNB+ EgO6h75nkjQUyLiZcS8FqiumaDGIV0R/Po2D/81EvPXkR7SzZWg= =0E17 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into staging Pull request # gpg: Signature made Wed 20 Feb 2019 18:01:00 GMT # gpg: using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full] # Primary key fingerprint: FAEB 9711 A12C F475 812F 18F2 88A9 064D 1835 61EB # Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76 CBD0 7DEF 8106 AAFC 390E * remotes/jnsnow/tags/bitmaps-pull-request: blockdev: acquire aio_context for bitmap add/remove block/dirty-bitmap: Documentation and Comment fixups dirty-bitmap: Expose persistent flag to 'query-block' Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
fc3dbb90f2
|
@ -29,12 +29,20 @@
|
|||
#include "block/blockjob.h"
|
||||
|
||||
/**
|
||||
* A BdrvDirtyBitmap can be in three possible states:
|
||||
* (1) successor is NULL and disabled is false: full r/w mode
|
||||
* (2) successor is NULL and disabled is true: read only mode ("disabled")
|
||||
* (3) successor is set: frozen mode.
|
||||
* A frozen bitmap cannot be renamed, deleted, anonymized, cleared, set,
|
||||
* or enabled. A frozen bitmap can only abdicate() or reclaim().
|
||||
* A BdrvDirtyBitmap can be in four possible user-visible states:
|
||||
* (1) Active: successor is NULL, and disabled is false: full r/w mode
|
||||
* (2) Disabled: successor is NULL, and disabled is true: qualified r/w mode,
|
||||
* guest writes are dropped, but monitor writes are possible,
|
||||
* through commands like merge and clear.
|
||||
* (3) Frozen: successor is not NULL.
|
||||
* A frozen bitmap cannot be renamed, deleted, cleared, set,
|
||||
* enabled, merged to, etc. A frozen bitmap can only abdicate()
|
||||
* or reclaim().
|
||||
* In this state, the anonymous successor bitmap may be either
|
||||
* Active and recording writes from the guest (e.g. backup jobs),
|
||||
* but it can be Disabled and not recording writes.
|
||||
* (4) Locked: Whether Active or Disabled, the user cannot modify this bitmap
|
||||
* in any way from the monitor.
|
||||
*/
|
||||
struct BdrvDirtyBitmap {
|
||||
QemuMutex *mutex;
|
||||
|
@ -440,6 +448,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
|
|||
info->has_name = !!bm->name;
|
||||
info->name = g_strdup(bm->name);
|
||||
info->status = bdrv_dirty_bitmap_status(bm);
|
||||
info->persistent = bm->persistent;
|
||||
entry->value = info;
|
||||
*plist = entry;
|
||||
plist = &entry->next;
|
||||
|
|
26
blockdev.c
26
blockdev.c
|
@ -2820,6 +2820,7 @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name,
|
|||
{
|
||||
BlockDriverState *bs;
|
||||
BdrvDirtyBitmap *bitmap;
|
||||
AioContext *aio_context = NULL;
|
||||
|
||||
if (!name || name[0] == '\0') {
|
||||
error_setg(errp, "Bitmap name cannot be empty");
|
||||
|
@ -2854,15 +2855,17 @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name,
|
|||
disabled = false;
|
||||
}
|
||||
|
||||
if (persistent &&
|
||||
!bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp))
|
||||
{
|
||||
return;
|
||||
if (persistent) {
|
||||
aio_context = bdrv_get_aio_context(bs);
|
||||
aio_context_acquire(aio_context);
|
||||
if (!bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp)) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp);
|
||||
if (bitmap == NULL) {
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (disabled) {
|
||||
|
@ -2870,6 +2873,10 @@ void qmp_block_dirty_bitmap_add(const char *node, const char *name,
|
|||
}
|
||||
|
||||
bdrv_dirty_bitmap_set_persistance(bitmap, persistent);
|
||||
out:
|
||||
if (aio_context) {
|
||||
aio_context_release(aio_context);
|
||||
}
|
||||
}
|
||||
|
||||
void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
|
||||
|
@ -2878,6 +2885,7 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
|
|||
BlockDriverState *bs;
|
||||
BdrvDirtyBitmap *bitmap;
|
||||
Error *local_err = NULL;
|
||||
AioContext *aio_context = NULL;
|
||||
|
||||
bitmap = block_dirty_bitmap_lookup(node, name, &bs, errp);
|
||||
if (!bitmap || !bs) {
|
||||
|
@ -2892,14 +2900,20 @@ void qmp_block_dirty_bitmap_remove(const char *node, const char *name,
|
|||
}
|
||||
|
||||
if (bdrv_dirty_bitmap_get_persistance(bitmap)) {
|
||||
aio_context = bdrv_get_aio_context(bs);
|
||||
aio_context_acquire(aio_context);
|
||||
bdrv_remove_persistent_dirty_bitmap(bs, name, &local_err);
|
||||
if (local_err != NULL) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
bdrv_release_dirty_bitmap(bs, bitmap);
|
||||
out:
|
||||
if (aio_context) {
|
||||
aio_context_release(aio_context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -420,17 +420,27 @@
|
|||
#
|
||||
# An enumeration of possible states that a dirty bitmap can report to the user.
|
||||
#
|
||||
# @frozen: The bitmap is currently in-use by a backup operation or block job,
|
||||
# and is immutable.
|
||||
# @frozen: The bitmap is currently in-use by some operation and is immutable.
|
||||
# If the bitmap was @active prior to the operation, new writes by the
|
||||
# guest are being recorded in a temporary buffer, and will not be lost.
|
||||
# Generally, bitmaps are cleared on successful use in an operation and
|
||||
# the temporary buffer is committed into the bitmap. On failure, the
|
||||
# temporary buffer is merged back into the bitmap without first
|
||||
# clearing it.
|
||||
# Please refer to the documentation for each bitmap-using operation,
|
||||
# See also @blockdev-backup, @drive-backup.
|
||||
#
|
||||
# @disabled: The bitmap is currently in-use by an internal operation and is
|
||||
# read-only. It can still be deleted.
|
||||
# @disabled: The bitmap is not currently recording new writes by the guest.
|
||||
# This is requested explicitly via @block-dirty-bitmap-disable.
|
||||
# It can still be cleared, deleted, or used for backup operations.
|
||||
#
|
||||
# @active: The bitmap is actively monitoring for new writes, and can be cleared,
|
||||
# deleted, or used for backup operations.
|
||||
#
|
||||
# @locked: The bitmap is currently in-use by some operation and can not be
|
||||
# cleared, deleted, or used for backup operations. (Since 2.12)
|
||||
# @locked: The bitmap is currently in-use by some operation and is immutable.
|
||||
# If the bitmap was @active prior to the operation, it is still
|
||||
# recording new writes. If the bitmap was @disabled, it is not
|
||||
# recording new writes. (Since 2.12)
|
||||
#
|
||||
# Since: 2.4
|
||||
##
|
||||
|
@ -450,11 +460,14 @@
|
|||
#
|
||||
# @status: current status of the dirty bitmap (since 2.4)
|
||||
#
|
||||
# @persistent: true if the bitmap will eventually be flushed to persistent
|
||||
# storage (since 4.0)
|
||||
#
|
||||
# Since: 1.3
|
||||
##
|
||||
{ 'struct': 'BlockDirtyInfo',
|
||||
'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
|
||||
'status': 'DirtyBitmapStatus'} }
|
||||
'status': 'DirtyBitmapStatus', 'persistent': 'bool' } }
|
||||
|
||||
##
|
||||
# @Qcow2BitmapInfoFlags:
|
||||
|
@ -2091,9 +2104,15 @@
|
|||
# @block-dirty-bitmap-merge:
|
||||
#
|
||||
# Merge dirty bitmaps listed in @bitmaps to the @target dirty bitmap.
|
||||
# The @bitmaps dirty bitmaps are unchanged.
|
||||
# Dirty bitmaps in @bitmaps will be unchanged, except if it also appears
|
||||
# as the @target bitmap. Any bits already set in @target will still be
|
||||
# set after the merge, i.e., this operation does not clear the target.
|
||||
# On error, @target is unchanged.
|
||||
#
|
||||
# The resulting bitmap will count as dirty any clusters that were dirty in any
|
||||
# of the source bitmaps. This can be used to achieve backup checkpoints, or in
|
||||
# simpler usages, to copy bitmaps.
|
||||
#
|
||||
# Returns: nothing on success
|
||||
# If @node is not a valid block device, DeviceNotFound
|
||||
# If any bitmap in @bitmaps or @target is not found, GenericError
|
||||
|
@ -2128,7 +2147,7 @@
|
|||
##
|
||||
# @x-debug-block-dirty-bitmap-sha256:
|
||||
#
|
||||
# Get bitmap SHA256
|
||||
# Get bitmap SHA256.
|
||||
#
|
||||
# Returns: BlockDirtyBitmapSha256 on success
|
||||
# If @node is not a valid block device, DeviceNotFound
|
||||
|
|
|
@ -350,6 +350,7 @@ class TestIncrementalBackup(TestIncrementalBackupBase):
|
|||
self.assert_qmp(result, 'return[0]/dirty-bitmaps[0]/count', 458752)
|
||||
self.assert_qmp(result, 'return[0]/dirty-bitmaps[0]/granularity', 65536)
|
||||
self.assert_qmp(result, 'return[0]/dirty-bitmaps[0]/status', 'active')
|
||||
self.assert_qmp(result, 'return[0]/dirty-bitmaps[0]/persistent', False)
|
||||
|
||||
# Prepare a cluster_size=128k backup target without a backing file.
|
||||
(target, _) = bitmap0.new_target()
|
||||
|
|
|
@ -25,12 +25,14 @@ write -P0xcd 0x3ff0000 64k
|
|||
"count": 262144,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapB",
|
||||
"persistent": false,
|
||||
"status": "active"
|
||||
},
|
||||
{
|
||||
"count": 262144,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapA",
|
||||
"persistent": false,
|
||||
"status": "active"
|
||||
}
|
||||
]
|
||||
|
@ -85,12 +87,14 @@ write -P0xcd 0x3ff0000 64k
|
|||
"count": 262144,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapB",
|
||||
"persistent": false,
|
||||
"status": "active"
|
||||
},
|
||||
{
|
||||
"count": 262144,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapA",
|
||||
"persistent": false,
|
||||
"status": "active"
|
||||
}
|
||||
]
|
||||
|
@ -183,18 +187,21 @@ write -P0xea 0x3fe0000 64k
|
|||
"count": 393216,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapC",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
},
|
||||
{
|
||||
"count": 262144,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapB",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
},
|
||||
{
|
||||
"count": 458752,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapA",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
}
|
||||
]
|
||||
|
@ -247,18 +254,21 @@ write -P0xea 0x3fe0000 64k
|
|||
"count": 393216,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapC",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
},
|
||||
{
|
||||
"count": 262144,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapB",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
},
|
||||
{
|
||||
"count": 458752,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapA",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
}
|
||||
]
|
||||
|
@ -304,24 +314,28 @@ write -P0xea 0x3fe0000 64k
|
|||
"count": 458752,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapD",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
},
|
||||
{
|
||||
"count": 393216,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapC",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
},
|
||||
{
|
||||
"count": 262144,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapB",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
},
|
||||
{
|
||||
"count": 458752,
|
||||
"granularity": 65536,
|
||||
"name": "bitmapA",
|
||||
"persistent": false,
|
||||
"status": "disabled"
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue