qemu-devel
[Top][All Lists]
Advanced

[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.

Attachment: pgp_Lozdisn72.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]