[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v9 06/10] qmp: Add block-dirty-bitmap-enable and
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v9 06/10] qmp: Add block-dirty-bitmap-enable and block-dirty-bitmap-disable |
Date: |
Tue, 9 Dec 2014 17:28:00 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Mon, Dec 01, 2014 at 03:30:12PM -0500, John Snow wrote:
> +/**
> + * Return a dirty bitmap (if present), after validating
> + * the device and bitmap names. Returns NULL on error,
> + * including when the device and/or bitmap is not found.
> + */
> +static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *device,
> + const char *name,
> + Error **errp)
> +{
> + BlockDriverState *bs;
> + BdrvDirtyBitmap *bitmap;
> +
> + if (!device) {
> + error_setg(errp, "Device cannot be NULL");
> + return NULL;
> + }
> + if (!name) {
> + error_setg(errp, "Bitmap name cannot be NULL");
> + return NULL;
> + }
> +
> + bs = bdrv_lookup_bs(device, NULL, errp);
> + if (!bs) {
> + return NULL;
> + }
> +
> + bitmap = bdrv_find_dirty_bitmap(bs, name);
> + if (!bitmap) {
> + error_setg(errp, "Dirty bitmap not found: %s", name);
> + return NULL;
> + }
> +
> + return bitmap;
> +}
qmp_block_dirty_bitmap_remove() in an earlier patch should use this
instead of duplicating code.
> +
> /* New and old BlockDriverState structs for atomic group operations */
>
> typedef struct BlkTransactionState BlkTransactionState;
> @@ -1948,6 +1983,32 @@ void qmp_block_dirty_bitmap_remove(const char *device,
> const char *name,
> bdrv_release_dirty_bitmap(bs, bitmap);
> }
>
> +void qmp_block_dirty_bitmap_enable(const char *device, const char *name,
> + Error **errp)
> +{
> + BdrvDirtyBitmap *bitmap;
> +
> + bitmap = block_dirty_bitmap_lookup(device, name, errp);
> + if (!bitmap) {
> + return;
> + }
> +
> + bdrv_enable_dirty_bitmap(bitmap);
> +}
> +
> +void qmp_block_dirty_bitmap_disable(const char *device, const char *name,
> + Error **errp)
> +{
> + BdrvDirtyBitmap *bitmap;
> +
> + bitmap = block_dirty_bitmap_lookup(device, name, errp);
> + if (!bitmap) {
> + return;
> + }
> +
> + bdrv_disable_dirty_bitmap(bitmap);
> +}
The dirty bitmap is accessed during the BDS request processing code
path and is owned by the BDS, so it should be protected by AioContext
too.
pgp_Lozdisn72.pgp
Description: PGP signature
- [Qemu-devel] [PATCH v9 04/10] hbitmap: Add hbitmap_copy, (continued)
- [Qemu-devel] [PATCH v9 04/10] hbitmap: Add hbitmap_copy, John Snow, 2014/12/01
- [Qemu-devel] [PATCH v9 02/10] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove, John Snow, 2014/12/01
- [Qemu-devel] [PATCH v9 07/10] qmp: Add support of "dirty-bitmap" sync mode for drive-backup, John Snow, 2014/12/01
- [Qemu-devel] [PATCH v9 06/10] qmp: Add block-dirty-bitmap-enable and block-dirty-bitmap-disable, John Snow, 2014/12/01
- Re: [Qemu-devel] [PATCH v9 06/10] qmp: Add block-dirty-bitmap-enable and block-dirty-bitmap-disable,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH v9 05/10] block: Add bdrv_copy_dirty_bitmap and bdrv_reset_dirty_bitmap, John Snow, 2014/12/01
- [Qemu-devel] [PATCH v9 08/10] qapi: Add transaction support to block-dirty-bitmap-{add, enable, disable}, John Snow, 2014/12/01
- [Qemu-devel] [PATCH v9 10/10] qemu-iotests: Add tests for drive-backup sync=dirty-bitmap, John Snow, 2014/12/01
- [Qemu-devel] [PATCH v9 09/10] qmp: Add dirty bitmap 'enabled' field in query-block, John Snow, 2014/12/01