diff mbox

[15/18] qmp: add block-dirty-bitmap-load

Message ID 20170203154757.36140-16-vsementsov@virtuozzo.com
State New
Headers show

Commit Message

Vladimir Sementsov-Ogievskiy Feb. 3, 2017, 3:47 p.m. UTC
For loading dirty bitmap from nbd server. Or for underlying storages for
other formats.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 blockdev.c           | 28 ++++++++++++++++++++++++++++
 qapi/block-core.json | 14 ++++++++++++++
 2 files changed, 42 insertions(+)

Comments

Fam Zheng Feb. 7, 2017, 12:04 p.m. UTC | #1
On Fri, 02/03 18:47, Vladimir Sementsov-Ogievskiy wrote:
>  ##
> +# @block-dirty-bitmap-load:
> +#
> +# Load a dirty bitmap from the storage (qcow2 file or nbd export)
> +#
> +# Returns: nothing on success
> +#          If @node is not a valid block device, DeviceNotFound
> +#          If @name is not found, GenericError with an explanation
> +#
> +# Since: vz-7.4

Version number doesn't look very familiar :)

Fam

> +##
> +  { 'command': 'block-dirty-bitmap-load',
> +    'data': 'BlockDirtyBitmap' }
> +
> +##
>  # @BlockDirtyBitmapSha256:
>  #
>  # SHA256 hash of dirty bitmap data
> -- 
> 2.11.0
>
Eric Blake Feb. 9, 2017, 3:18 p.m. UTC | #2
On 02/03/2017 09:47 AM, Vladimir Sementsov-Ogievskiy wrote:
> For loading dirty bitmap from nbd server. Or for underlying storages for

s/storages/storage/

> other formats.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  blockdev.c           | 28 ++++++++++++++++++++++++++++
>  qapi/block-core.json | 14 ++++++++++++++
>  2 files changed, 42 insertions(+)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 1bc3fe386a..2529943e7f 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2790,6 +2790,34 @@ void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
>      aio_context_release(aio_context);
>  }
>  
> +void qmp_block_dirty_bitmap_load(const char *node, const char *name,
> +                                 Error **errp)
> +{
> +    AioContext *aio_context;
> +    BlockDriverState *bs;
> +
> +    if (!node) {
> +        error_setg(errp, "Node cannot be NULL");
> +        return;
> +    }
> +    if (!name) {
> +        error_setg(errp, "Bitmap name cannot be NULL");
> +        return;
> +    }

QAPI guarantees that node and name are non-null for non-optional
arguments; these checks are dead code...

> +++ b/qapi/block-core.json
> @@ -1280,6 +1280,20 @@
>    'data': 'BlockDirtyBitmap' }
>  
>  ##
> +# @block-dirty-bitmap-load:
> +#
> +# Load a dirty bitmap from the storage (qcow2 file or nbd export)
> +#
> +# Returns: nothing on success
> +#          If @node is not a valid block device, DeviceNotFound
> +#          If @name is not found, GenericError with an explanation
> +#
> +# Since: vz-7.4
> +##
> +  { 'command': 'block-dirty-bitmap-load',
> +    'data': 'BlockDirtyBitmap' }

...since BlockDirtyBitmap defines them as required fields.
Paolo Bonzini Feb. 15, 2017, 4:57 p.m. UTC | #3
On 03/02/2017 16:47, Vladimir Sementsov-Ogievskiy wrote:
>  ##
> +# @block-dirty-bitmap-load:
> +#
> +# Load a dirty bitmap from the storage (qcow2 file or nbd export)

NBD export only in upstream QEMU?

Paolo

> +# Returns: nothing on success
> +#          If @node is not a valid block device, DeviceNotFound
> +#          If @name is not found, GenericError with an explanation
> +#
diff mbox

Patch

diff --git a/blockdev.c b/blockdev.c
index 1bc3fe386a..2529943e7f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2790,6 +2790,34 @@  void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
     aio_context_release(aio_context);
 }
 
+void qmp_block_dirty_bitmap_load(const char *node, const char *name,
+                                 Error **errp)
+{
+    AioContext *aio_context;
+    BlockDriverState *bs;
+
+    if (!node) {
+        error_setg(errp, "Node cannot be NULL");
+        return;
+    }
+    if (!name) {
+        error_setg(errp, "Bitmap name cannot be NULL");
+        return;
+    }
+    bs = bdrv_lookup_bs(node, node, NULL);
+    if (!bs) {
+        error_setg(errp, "Node '%s' not found", node);
+        return;
+    }
+
+    aio_context = bdrv_get_aio_context(bs);
+    aio_context_acquire(aio_context);
+
+    bdrv_load_dirty_bitmap(bs, name, errp);
+
+    aio_context_release(aio_context);
+}
+
 BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
                                                               const char *name,
                                                               Error **errp)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index b258c45595..63777ea55b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1280,6 +1280,20 @@ 
   'data': 'BlockDirtyBitmap' }
 
 ##
+# @block-dirty-bitmap-load:
+#
+# Load a dirty bitmap from the storage (qcow2 file or nbd export)
+#
+# Returns: nothing on success
+#          If @node is not a valid block device, DeviceNotFound
+#          If @name is not found, GenericError with an explanation
+#
+# Since: vz-7.4
+##
+  { 'command': 'block-dirty-bitmap-load',
+    'data': 'BlockDirtyBitmap' }
+
+##
 # @BlockDirtyBitmapSha256:
 #
 # SHA256 hash of dirty bitmap data