Skip to contentSkip to conversation

external backup api

RFC PATCH Superseded Vladimir Sementsov-Ogievskiy 4 participants 11 messages Jan 22, 2016 – Feb 9, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 external backup api

Hi all.

This is the early begin of the series which aims to add external backup api. This is needed to allow backup software use our dirty bitmaps.

Vmware and Parallels Cloud Server have this feature.

There is only one patch here, about querying dirty bitmap from qemu by qmp command. It is just an updated and clipped (hmp command removed) old my patch "[PATCH RFC v3 01/14] qmp: add query-block-dirty-bitmap".

Before writing the whole thing I'd like to discuss the details. Or, may be there are existing plans on this topic, or may be someone already works on it?

I see it like this:

=====

- add qmp commands for dirty-bitmap functions: create_successor, abdicate, reclaime.
- make create-successor command transaction-able
- add query-block-dirty-bitmap qmp command

then, external backup:

qmp transaction {
external-snapshot
bitmap-create-successor
}

qmp query frozen bitmap, not acquiring aio context.

do external backup, using snapshot and bitmap

if (success backup)
qmp bitmap-abdicate
else
qmp bitmap-reclaime

qmp merge snapshot
=====

In the following patch query-bitmap acquires aio context. This must be ofcourse dropped for frozen bitmap.
But to make it in true way, I think, I should check somehow that this is not just frozen bitmap, but the bitmap frozen by qmp command, to avoid incorrect quering of bitmap frozen by internal backup (or other mechanizm).. May be, it is not necessary.

Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 qmp: add query-block-dirty-bitmap

Add qmp command to query dirty bitmap. This is needed for external backup.

---
 block.c               | 41 ++++++++++++++++++++++++++++++++++++++++
 blockdev.c            | 21 +++++++++++++++++++++
 include/block/block.h |  2 ++
 qapi/block-core.json  | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 qmp-commands.hx       | 22 ++++++++++++++++++++++
 5 files changed, 138 insertions(+)
block.c +41 -0
index 5709d3d..9a28589 100644
@@ -3717,6 +3717,47 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
     }
 }
 
+BlockDirtyBitmapInfo *bdrv_query_dirty_bitmap(BlockDriverState *bs,
+                                              BdrvDirtyBitmap *bitmap)
+{
+    BlockDirtyBitmapInfo *info = g_new0(BlockDirtyBitmapInfo, 1);
+    BlockDirtyRegionList **plist = &info->dirty_regions;
+    uint64_t begin = 0, end = 0, size = bitmap->size;
+    HBitmap *hb = bitmap->bitmap;
+
+    info->dirty_count = bdrv_get_dirty_count(bitmap);
+    info->granularity = bdrv_dirty_bitmap_granularity(bitmap);
+    info->size = bitmap->size;
+    info->name = g_strdup(bitmap->name);
+    info->disabled = bitmap->disabled;
+    info->dirty_regions = NULL;
+
+    for (; begin < size; ++begin) {
+        BlockDirtyRegion *region;
+        BlockDirtyRegionList *entry;
+
+        if (!hbitmap_get(hb, begin)) {
+            continue;
+        }
+
+        for (end = begin + 1; end < size && hbitmap_get(hb, end); ++end) {
+            ;
+        }
+
+        region = g_new0(BlockDirtyRegion, 1);
+        entry = g_new0(BlockDirtyRegionList, 1);
+        region->start = begin;
+        region->count = end - begin;
+        entry->value = region;
+        *plist = entry;
+        plist = &entry->next;
+
+        begin = end;
+    }
+
+    return info;
+}
+
 /**
  * Advance an HBitmapIter to an arbitrary offset.
  */
blockdev.c +21 -0
index 07cfe25..d2bc453 100644
@@ -2734,6 +2734,27 @@ void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
     aio_context_release(aio_context);
 }
 
+BlockDirtyBitmapInfo *qmp_query_block_dirty_bitmap(const char *node,
+                                                   const char *name,
+                                                   Error **errp)
+{
+    AioContext *aio_context;
+    BdrvDirtyBitmap *bitmap;
+    BlockDriverState *bs;
+    BlockDirtyBitmapInfo *ret = NULL;
+
+    bitmap = block_dirty_bitmap_lookup(node, name, &bs, &aio_context, errp);
+    if (!bitmap) {
+        return NULL;
+    }
+
+    ret = bdrv_query_dirty_bitmap(bs, bitmap);
+
+    aio_context_release(aio_context);
+
+    return ret;
+}
+
 void hmp_drive_del(Monitor *mon, const QDict *qdict)
 {
     const char *id = qdict_get_str(qdict, "id");
include/block/block.h +2 -0
index 25f36dc..9d6bd33 100644
@@ -505,6 +505,8 @@ void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
                            int64_t cur_sector, int nr_sectors);
 void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
                              int64_t cur_sector, int nr_sectors);
+BlockDirtyBitmapInfo *bdrv_query_dirty_bitmap(BlockDriverState *bs,
+                                              BdrvDirtyBitmap *bitmap);
 void bdrv_dirty_iter_init(BdrvDirtyBitmap *bitmap, struct HBitmapIter *hbi);
 void bdrv_set_dirty_iter(struct HBitmapIter *hbi, int64_t offset);
 int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);
qapi/block-core.json +52 -0

58 lines not on this page · raw message

qmp-commands.hx +22 -0
index db072a6..75d9345 100644
@@ -1457,6 +1457,28 @@ Example:
 EQMP
 
     {
+        .name       = "query-block-dirty-bitmap",
+        .args_type  = "node:B,name:s",
+        .mhandler.cmd_new = qmp_marshal_query_block_dirty_bitmap,
+    },
+
+SQMP
+
+query-block-dirty-bitmap
+------------------------
+Since 2.6
+
+Get dirty bitmap info, including contents. Bitmap data are returned as array of
+dirty regions
+
+Arguments:
+
+- "node": device/node on which to remove dirty bitmap (json-string)
+- "name": name of the dirty bitmap to remove (json-string)
+
+EQMP
+
+    {
         .name       = "blockdev-snapshot-sync",
         .args_type  = "device:s?,node-name:s?,snapshot-file:s,snapshot-node-name:s?,format:s?,mode:s?",
         .mhandler.cmd_new = qmp_marshal_blockdev_snapshot_sync,
Signature · 1 line
1.8.3.1
#3 lore raw

Re: [Qemu-devel] [PATCH] qmp: add query-block-dirty-bitmap

In reply to Denis V. Lunev
Quoted 43 lines · Denis V. Lunev
Quoted 42 lines · Vladimir Sementsov-Ogievskiy

Add qmp command to query dirty bitmap. This is needed for external backup.

---
  block.c               | 41 ++++++++++++++++++++++++++++++++++++++++
  blockdev.c            | 21 +++++++++++++++++++++
  include/block/block.h |  2 ++
  qapi/block-core.json  | 52 
+++++++++++++++++++++++++++++++++++++++++++++++++++
  qmp-commands.hx       | 22 ++++++++++++++++++++++
  5 files changed, 138 insertions(+)
block.c +20 -0
index 5709d3d..9a28589 100644
@@ -3717,6 +3717,47 @@ void bdrv_set_dirty(BlockDriverState *bs, 
 int64_t cur_sector,
      }
  }
  +BlockDirtyBitmapInfo *bdrv_query_dirty_bitmap(BlockDriverState *bs,
+                                              BdrvDirtyBitmap *bitmap)
+{
+    BlockDirtyBitmapInfo *info = g_new0(BlockDirtyBitmapInfo, 1);
+    BlockDirtyRegionList **plist = &info->dirty_regions;
+    uint64_t begin = 0, end = 0, size = bitmap->size;
+    HBitmap *hb = bitmap->bitmap;
+
+    info->dirty_count = bdrv_get_dirty_count(bitmap);
+    info->granularity = bdrv_dirty_bitmap_granularity(bitmap);
+    info->size = bitmap->size;
+    info->name = g_strdup(bitmap->name);
+    info->disabled = bitmap->disabled;
+    info->dirty_regions = NULL;
+
+    for (; begin < size; ++begin) {
+        BlockDirtyRegion *region;
+        BlockDirtyRegionList *entry;
+
+        if (!hbitmap_get(hb, begin)) {
+            continue;
Quoted 8 lines

block.c void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, · line 3745

Quoted 6 lines
block.c +6 -0
+        }
+
+        for (end = begin + 1; end < size && hbitmap_get(hb, end); 
++end) {
+            ;
+        }

let us implemented faster finder. This would be useful in other places. It could be 100 times faster!

I'll use iterators here, if the whole way is ok (querying regions, not blob)

Quoted 121 lines
Quoted 121 lines
block.c +15 -0
+
+        region = g_new0(BlockDirtyRegion, 1);
+        entry = g_new0(BlockDirtyRegionList, 1);
+        region->start = begin;
+        region->count = end - begin;
+        entry->value = region;
+        *plist = entry;
+        plist = &entry->next;
+
+        begin = end;
+    }
+
+    return info;
+}
+
  /**
   * Advance an HBitmapIter to an arbitrary offset.
   */
blockdev.c +20 -0
index 07cfe25..d2bc453 100644
@@ -2734,6 +2734,27 @@ void qmp_block_dirty_bitmap_clear(const char 
 *node, const char *name,
      aio_context_release(aio_context);
  }
  +BlockDirtyBitmapInfo *qmp_query_block_dirty_bitmap(const char *node,
+                                                   const char *name,
+                                                   Error **errp)
+{
+    AioContext *aio_context;
+    BdrvDirtyBitmap *bitmap;
+    BlockDriverState *bs;
+    BlockDirtyBitmapInfo *ret = NULL;
+
+    bitmap = block_dirty_bitmap_lookup(node, name, &bs, 
 &aio_context, errp);
+    if (!bitmap) {
+        return NULL;
+    }
+
+    ret = bdrv_query_dirty_bitmap(bs, bitmap);
+
+    aio_context_release(aio_context);
+
+    return ret;
+}
+
  void hmp_drive_del(Monitor *mon, const QDict *qdict)
  {
      const char *id = qdict_get_str(qdict, "id");
include/block/block.h +2 -0
index 25f36dc..9d6bd33 100644
@@ -505,6 +505,8 @@ void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
                             int64_t cur_sector, int nr_sectors);
  void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
                               int64_t cur_sector, int nr_sectors);
+BlockDirtyBitmapInfo *bdrv_query_dirty_bitmap(BlockDriverState *bs,
+                                              BdrvDirtyBitmap *bitmap);
  void bdrv_dirty_iter_init(BdrvDirtyBitmap *bitmap, struct 
 HBitmapIter *hbi);
  void bdrv_set_dirty_iter(struct HBitmapIter *hbi, int64_t offset);
  int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);
qapi/block-core.json +42 -0
index 0a915ed..12ed759 100644
@@ -414,6 +414,58 @@
  ##
  { 'command': 'query-block', 'returns': ['BlockInfo'] }
  +##
+# @BlockDirtyRegion:
+#
+# Region in bytes.
+#
+# @start: first byte
+#
+# @count: number of bytes in the region
+#
+# Since: 2.3
+##
+{ 'struct': 'BlockDirtyRegion',
+  'data': { 'start': 'int', 'count': 'int' } }
+
+##
+# @BlockDirtyBitmapInfo
+#
+# @name: the name of the dirty bitmap
+#
+# @size: size of the dirty bitmap in sectors
+#
+# @granularity: granularity of the dirty bitmap in bytes
+#
+# @disabled: whether the dirty bitmap is disabled
+#
+# @dirty-count: number of dirty bytes according to the dirty bitmap
+#
+# @dirty-regions: dirty regions of the bitmap
+#
+# Since 2.3
+##
+{ 'struct': 'BlockDirtyBitmapInfo',
+  'data': { 'name': 'str',
+            'size': 'int',
+            'granularity': 'int',
+            'disabled': 'bool',
+            'dirty-count': 'int',
+            'dirty-regions': ['BlockDirtyRegion'] } }
+
+##
+# @query-block-dirty-bitmap
+#
+# Get a description for specified dirty bitmap including it's dirty 

regions.

qapi/block-core.json +4 -0
+# This command is in general for testing purposes.
+#
+# Returns: @BlockDirtyBitmapInfo
+#
Quoted 8 lines

qapi/block-core.json line 468

Quoted 5 lines
qapi/block-core.json +5 -0
+# Since: 2.3
+##
+{ 'command': 'query-block-dirty-bitmap',
+  'data': 'BlockDirtyBitmap',
+  'returns': 'BlockDirtyBitmapInfo' }

1) should we consider part-by-part retrieval? This could be useful for large discs.
2) Change to since 2.6
3) Do you think that content should be retrieved separately than data?

3 - what do you mean?

Quoted 31 lines
Quoted 31 lines

    ##

# @BlockDeviceTimedStats:

qmp-commands.hx +12 -0
index db072a6..75d9345 100644
@@ -1457,6 +1457,28 @@ Example:
  EQMP
        {
+        .name       = "query-block-dirty-bitmap",
+        .args_type  = "node:B,name:s",
+        .mhandler.cmd_new = qmp_marshal_query_block_dirty_bitmap,
+    },
+
+SQMP
+
+query-block-dirty-bitmap
+------------------------
+Since 2.6
+
+Get dirty bitmap info, including contents. Bitmap data are returned 

as array of

qmp-commands.hx +7 -0
+dirty regions
+
+Arguments:
+
+- "node": device/node on which to remove dirty bitmap (json-string)
+- "name": name of the dirty bitmap to remove (json-string)
+
Quoted 8 lines
Quoted 7 lines
qmp-commands.hx +3 -0
+EQMP
+
+    {
          .name       = "blockdev-snapshot-sync",
          .args_type  = 

"device:s?,node-name:s?,snapshot-file:s,snapshot-node-name:s?,format:s?,mode:s?",
.mhandler.cmd_new = qmp_marshal_blockdev_snapshot_sync,

can you pls use [email protected] addr sending patches to me?

ok, sorry.

Signature · 3 lines
Best regards,
Vladimir
* now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.
#2 lore raw

Re: [Qemu-devel] [PATCH] qmp: add query-block-dirty-bitmap

In reply to Vladimir Sementsov-Ogievskiy
Quoted 36 lines · Vladimir Sementsov-Ogievskiy

Add qmp command to query dirty bitmap. This is needed for external backup.

---
  block.c               | 41 ++++++++++++++++++++++++++++++++++++++++
  blockdev.c            | 21 +++++++++++++++++++++
  include/block/block.h |  2 ++
  qapi/block-core.json  | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
  qmp-commands.hx       | 22 ++++++++++++++++++++++
  5 files changed, 138 insertions(+)
block.c +16 -0
index 5709d3d..9a28589 100644
@@ -3717,6 +3717,47 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
      }
  }
 
+BlockDirtyBitmapInfo *bdrv_query_dirty_bitmap(BlockDriverState *bs,
+                                              BdrvDirtyBitmap *bitmap)
+{
+    BlockDirtyBitmapInfo *info = g_new0(BlockDirtyBitmapInfo, 1);
+    BlockDirtyRegionList **plist = &info->dirty_regions;
+    uint64_t begin = 0, end = 0, size = bitmap->size;
+    HBitmap *hb = bitmap->bitmap;
+
+    info->dirty_count = bdrv_get_dirty_count(bitmap);
+    info->granularity = bdrv_dirty_bitmap_granularity(bitmap);
+    info->size = bitmap->size;
+    info->name = g_strdup(bitmap->name);
+    info->disabled = bitmap->disabled;
+    info->dirty_regions = NULL;
+
+    for (; begin < size; ++begin) {

block.c void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, · line 3745

Quoted 10 lines
block.c +10 -0
+        BlockDirtyRegion *region;
+        BlockDirtyRegionList *entry;
+
+        if (!hbitmap_get(hb, begin)) {
+            continue;
+        }
+
+        for (end = begin + 1; end < size && hbitmap_get(hb, end); ++end) {
+            ;
+        }

let us implemented faster finder. This would be useful in other places. It could be 100 times faster!

Quoted 113 lines
block.c +15 -0
+
+        region = g_new0(BlockDirtyRegion, 1);
+        entry = g_new0(BlockDirtyRegionList, 1);
+        region->start = begin;
+        region->count = end - begin;
+        entry->value = region;
+        *plist = entry;
+        plist = &entry->next;
+
+        begin = end;
+    }
+
+    return info;
+}
+
  /**
   * Advance an HBitmapIter to an arbitrary offset.
   */
blockdev.c +21 -0
index 07cfe25..d2bc453 100644
@@ -2734,6 +2734,27 @@ void qmp_block_dirty_bitmap_clear(const char *node, const char *name,
      aio_context_release(aio_context);
  }
 
+BlockDirtyBitmapInfo *qmp_query_block_dirty_bitmap(const char *node,
+                                                   const char *name,
+                                                   Error **errp)
+{
+    AioContext *aio_context;
+    BdrvDirtyBitmap *bitmap;
+    BlockDriverState *bs;
+    BlockDirtyBitmapInfo *ret = NULL;
+
+    bitmap = block_dirty_bitmap_lookup(node, name, &bs, &aio_context, errp);
+    if (!bitmap) {
+        return NULL;
+    }
+
+    ret = bdrv_query_dirty_bitmap(bs, bitmap);
+
+    aio_context_release(aio_context);
+
+    return ret;
+}
+
  void hmp_drive_del(Monitor *mon, const QDict *qdict)
  {
      const char *id = qdict_get_str(qdict, "id");
include/block/block.h +2 -0
index 25f36dc..9d6bd33 100644
@@ -505,6 +505,8 @@ void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
                             int64_t cur_sector, int nr_sectors);
  void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
                               int64_t cur_sector, int nr_sectors);
+BlockDirtyBitmapInfo *bdrv_query_dirty_bitmap(BlockDriverState *bs,
+                                              BdrvDirtyBitmap *bitmap);
  void bdrv_dirty_iter_init(BdrvDirtyBitmap *bitmap, struct HBitmapIter *hbi);
  void bdrv_set_dirty_iter(struct HBitmapIter *hbi, int64_t offset);
  int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);
qapi/block-core.json +42 -0
index 0a915ed..12ed759 100644
@@ -414,6 +414,58 @@
  ##
  { 'command': 'query-block', 'returns': ['BlockInfo'] }
 
+##
+# @BlockDirtyRegion:
+#
+# Region in bytes.
+#
+# @start: first byte
+#
+# @count: number of bytes in the region
+#
+# Since: 2.3
+##
+{ 'struct': 'BlockDirtyRegion',
+  'data': { 'start': 'int', 'count': 'int' } }
+
+##
+# @BlockDirtyBitmapInfo
+#
+# @name: the name of the dirty bitmap
+#
+# @size: size of the dirty bitmap in sectors
+#
+# @granularity: granularity of the dirty bitmap in bytes
+#
+# @disabled: whether the dirty bitmap is disabled
+#
+# @dirty-count: number of dirty bytes according to the dirty bitmap
+#
+# @dirty-regions: dirty regions of the bitmap
+#
+# Since 2.3
+##
+{ 'struct': 'BlockDirtyBitmapInfo',
+  'data': { 'name': 'str',
+            'size': 'int',
+            'granularity': 'int',
+            'disabled': 'bool',
+            'dirty-count': 'int',
+            'dirty-regions': ['BlockDirtyRegion'] } }
+
+##
+# @query-block-dirty-bitmap
+#

qapi/block-core.json line 468

Quoted 10 lines
qapi/block-core.json +10 -0
+# Get a description for specified dirty bitmap including it's dirty regions.
+# This command is in general for testing purposes.
+#
+# Returns: @BlockDirtyBitmapInfo
+#
+# Since: 2.3
+##
+{ 'command': 'query-block-dirty-bitmap',
+  'data': 'BlockDirtyBitmap',
+  'returns': 'BlockDirtyBitmapInfo' }

1) should we consider part-by-part retrieval? This could be useful for large discs.
2) Change to since 2.6
3) Do you think that content should be retrieved separately than data?

Quoted 26 lines
qapi/block-core.json +0 -0
  ##
  # @BlockDeviceTimedStats:
qmp-commands.hx +15 -0
index db072a6..75d9345 100644
@@ -1457,6 +1457,28 @@ Example:
  EQMP
 
      {
+        .name       = "query-block-dirty-bitmap",
+        .args_type  = "node:B,name:s",
+        .mhandler.cmd_new = qmp_marshal_query_block_dirty_bitmap,
+    },
+
+SQMP
+
+query-block-dirty-bitmap
+------------------------
+Since 2.6
+
+Get dirty bitmap info, including contents. Bitmap data are returned as array of
+dirty regions
+
+Arguments:

qmp-commands.hx Example: · line 1484

Quoted 10 lines
qmp-commands.hx +7 -0
+
+- "node": device/node on which to remove dirty bitmap (json-string)
+- "name": name of the dirty bitmap to remove (json-string)
+
+EQMP
+
+    {
          .name       = "blockdev-snapshot-sync",
          .args_type  = "device:s?,node-name:s?,snapshot-file:s,snapshot-node-name:s?,format:s?,mode:s?",
          .mhandler.cmd_new = qmp_marshal_blockdev_snapshot_sync,

can you pls use [email protected] addr sending patches to me?

#4 lore raw

Re: [Qemu-devel] [PATCH] qmp: add query-block-dirty-bitmap

In reply to Vladimir Sementsov-Ogievskiy
Quoted 53 lines · Vladimir Sementsov-Ogievskiy
Quoted 52 lines · Denis V. Lunev

On 01/22/2016 08:07 PM, Vladimir Sementsov-Ogievskiy wrote:
{ 'command': 'query-block', 'returns': ['BlockInfo'] }
+##

qapi/block-core.json +42 -0
+# @BlockDirtyRegion:
+#
+# Region in bytes.
+#
+# @start: first byte
+#
+# @count: number of bytes in the region
+#
+# Since: 2.3
+##
+{ 'struct': 'BlockDirtyRegion',
+  'data': { 'start': 'int', 'count': 'int' } }
+
+##
+# @BlockDirtyBitmapInfo
+#
+# @name: the name of the dirty bitmap
+#
+# @size: size of the dirty bitmap in sectors
+#
+# @granularity: granularity of the dirty bitmap in bytes
+#
+# @disabled: whether the dirty bitmap is disabled
+#
+# @dirty-count: number of dirty bytes according to the dirty bitmap
+#
+# @dirty-regions: dirty regions of the bitmap
+#
+# Since 2.3
+##
+{ 'struct': 'BlockDirtyBitmapInfo',
+  'data': { 'name': 'str',
+            'size': 'int',
+            'granularity': 'int',
+            'disabled': 'bool',
+            'dirty-count': 'int',
+            'dirty-regions': ['BlockDirtyRegion'] } }
+
+##
+# @query-block-dirty-bitmap
+#
+# Get a description for specified dirty bitmap including it's dirty 

regions.

qapi/block-core.json +6 -0
+# This command is in general for testing purposes.
+#
+# Returns: @BlockDirtyBitmapInfo
+#
+# Since: 2.3
+##
Quoted 9 lines
Quoted 6 lines
qapi/block-core.json +3 -0
+{ 'command': 'query-block-dirty-bitmap',
+  'data': 'BlockDirtyBitmap',
+  'returns': 'BlockDirtyBitmapInfo' }

1) should we consider part-by-part retrieval? This could be useful for large discs.
2) Change to since 2.6
3) Do you think that content should be retrieved separately than data?

3 - what do you mean?

sorry, I mean bitmap description separately from bitmap bits aka data

#5 lore raw

Re: [Qemu-devel] [PATCH] qmp: add query-block-dirty-bitmap

In reply to Vladimir Sementsov-Ogievskiy
Quoted 11 lines · Vladimir Sementsov-Ogievskiy

Add qmp command to query dirty bitmap. This is needed for external backup.

---
 block.c               | 41 ++++++++++++++++++++++++++++++++++++++++
 blockdev.c            | 21 +++++++++++++++++++++
 include/block/block.h |  2 ++
 qapi/block-core.json  | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 qmp-commands.hx       | 22 ++++++++++++++++++++++
 5 files changed, 138 insertions(+)

Just an interface review at this time:

Quoted 5 lines

+++ b/qapi/block-core.json

qapi/block-core.json +0 -0
@@ -414,6 +414,58 @@
 ##
 { 'command': 'query-block', 'returns': ['BlockInfo'] }
 

qapi/block-core.json line 426

Quoted 10 lines
qapi/block-core.json +10 -0
+##
+# @BlockDirtyRegion:
+#
+# Region in bytes.
+#
+# @start: first byte
+#
+# @count: number of bytes in the region
+#
+# Since: 2.3

Don't you mean 2.6?

Quoted 10 lines
qapi/block-core.json +10 -0
+##
+{ 'struct': 'BlockDirtyRegion',
+  'data': { 'start': 'int', 'count': 'int' } }
+
+##
+# @BlockDirtyBitmapInfo
+#
+# @name: the name of the dirty bitmap
+#
+# @size: size of the dirty bitmap in sectors

qapi/block-core.json line 446

Quoted 10 lines
qapi/block-core.json +10 -0
+#
+# @granularity: granularity of the dirty bitmap in bytes
+#
+# @disabled: whether the dirty bitmap is disabled
+#
+# @dirty-count: number of dirty bytes according to the dirty bitmap
+#
+# @dirty-regions: dirty regions of the bitmap
+#
+# Since 2.3

and again

Quoted 8 lines
qapi/block-core.json +8 -0
+##
+{ 'struct': 'BlockDirtyBitmapInfo',
+  'data': { 'name': 'str',
+            'size': 'int',
+            'granularity': 'int',
+            'disabled': 'bool',
+            'dirty-count': 'int',
+            'dirty-regions': ['BlockDirtyRegion'] } }

qapi/block-core.json line 464

Quoted 10 lines
qapi/block-core.json +10 -0
+
+##
+# @query-block-dirty-bitmap
+#
+# Get a description for specified dirty bitmap including it's dirty regions.
+# This command is in general for testing purposes.
+#
+# Returns: @BlockDirtyBitmapInfo
+#
+# Since: 2.3

and again

qapi/block-core.json line 468

Quoted 4 lines
qapi/block-core.json +4 -0
+##
+{ 'command': 'query-block-dirty-bitmap',
+  'data': 'BlockDirtyBitmap',
+  'returns': 'BlockDirtyBitmapInfo' }

Seems reasonable for getting at the information for one bitmap. But would it be smarter to have:

{ 'command': 'query-block-dirty-bitmap',
'data': { 'node':'str', '*name':'str' },
'returns': [ 'BlockDirtyBitmapInfo' ] }

so that you could get ALL the dirty bitmaps for a single node (with optional filtering to get an array of just one, if 'name' was provided)?
Or, should BlockDirtyBitmapInfo also include a node name, then you
could query all dirty bitmaps for all nodes at once? Is that too much data for one QMP command?

qmp-commands.hx Example: · line 1476

Quoted 11 lines
qmp-commands.hx +11 -0
+
+query-block-dirty-bitmap
+------------------------
+Since 2.6
+
+Get dirty bitmap info, including contents. Bitmap data are returned as array of
+dirty regions
+
+Arguments:
+
+- "node": device/node on which to remove dirty bitmap (json-string)

Too much copy-and-paste; you aren't removing the bitmap.

Review

Quoted 3 lines

+- "name": name of the dirty bitmap to remove (json-string)

(quoted diff) +2 -0
+
+EQMP

Worth showing example output?

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#6 lore raw
In reply to Vladimir Sementsov-Ogievskiy
Quoted 7 lines · Vladimir Sementsov-Ogievskiy

Hi all.

This is the early begin of the series which aims to add external backup api. This is needed to allow backup software use our dirty bitmaps.

Vmware and Parallels Cloud Server have this feature.

Have a link to the equivalent feature that VMWare exposes? (Or Parallels Cloud Server) ... I'm curious about what the API there looks like.

Quoted 8 lines

There is only one patch here, about querying dirty bitmap from qemu by qmp command. It is just an updated and clipped (hmp command removed) old my patch "[PATCH RFC v3 01/14] qmp: add query-block-dirty-bitmap".

Before writing the whole thing I'd like to discuss the details. Or, may be there are existing plans on this topic, or may be someone already works on it?

Quoted 6 lines

I see it like this:

=====

- add qmp commands for dirty-bitmap functions: create_successor, abdicate, reclaime.

Hm, why do we need such low-level control over splitting and merging bitmaps from an external client?

Quoted 14 lines

- make create-successor command transaction-able
- add query-block-dirty-bitmap qmp command

then, external backup:

qmp transaction {
external-snapshot
bitmap-create-successor
}

qmp query frozen bitmap, not acquiring aio context.

do external backup, using snapshot and bitmap

Quoted 8 lines

if (success backup)
qmp bitmap-abdicate
else
qmp bitmap-reclaime

qmp merge snapshot
=====

Hm, I see -- so you're hoping to manage the backup *entirely* externally, so you want to be able to reach inside of QEMU and control some status conditions to guarantee it'll be safe.

I'm not convinced QEMU can guarantee such things -- due to various flush properties, race conditions on write, etc. QEMU handles all of this internally in a non-public way at the moment.

Quoted 10 lines

In the following patch query-bitmap acquires aio context. This must be ofcourse dropped for frozen bitmap.
But to make it in true way, I think, I should check somehow that this is not just frozen bitmap, but the bitmap frozen by qmp command, to avoid incorrect quering of bitmap frozen by internal backup (or other mechanizm).. May be, it is not necessary.

#7 lore raw
Quoted 11 lines · John Snow
Quoted 7 lines · Vladimir Sementsov-Ogievskiy

Hi all.

This is the early begin of the series which aims to add external backup api. This is needed to allow backup software use our dirty bitmaps.

Vmware and Parallels Cloud Server have this feature.

Have a link to the equivalent feature that VMWare exposes? (Or Parallels Cloud Server) ... I'm curious about what the API there looks like.

For VMware you need their Virtual Disk Api Programming Guide
http://pubs.vmware.com/vsphere-60/topic/com.vmware.ICbase/PDF/vddk60_programming.pdf
Look at Changed Block Tracking (CBT) , Backup and Restore.

For PCS here is part of SDK header, related to the topic:

====================================
/*
* Builds a map of the disk contents changes between 2 PITs. Parameters
hDisk : A handle of type PHT_VIRTUAL_DISK identifying
the virtual disk.

   sPit1Uuid :   Uuid of the older PIT.
   sPit2Uuid :   Uuid of the later PIT.
   phMap :       A pointer to a variable which receives the

result (a handle of type PHT_VIRTUAL_DISK_MAP).
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

                PrlDisk_GetChangesMap_Local, (
        PRL_HANDLE hDisk,
        PRL_CONST_STR sPit1Uuid,
        PRL_CONST_STR sPit2Uuid,
        PRL_HANDLE_PTR phMap) );

/*
* Reports the number of significant bits in the map. Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
phSize : A pointer to a variable which receives the
result.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

                PrlDiskMap_GetSize, (
        PRL_HANDLE hMap,
        PRL_UINT32_PTR pnSize) );

/*
* Reports the size (in bytes) of a block mapped by a single bit
* in the map.
Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
phSize : A pointer to a variable which receives the
result.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

                PrlDiskMap_GetGranularity, (
        PRL_HANDLE hMap,
        PRL_UINT32_PTR pnSize) );

/*
* Returns bits from the blocks map.
Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
pBuffer : A pointer to a store.
pnCapacity : A pointer to a variable holding the size
of the buffer and receiving the number of bytes actually written.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

                PrlDiskMap_Read, (
        PRL_HANDLE hMap,
        PRL_VOID_PTR pBuffer,
        PRL_UINT32_PTR pnCapacity) );

=======================================

Quoted 40 lines
Quoted 9 lines

There is only one patch here, about querying dirty bitmap from qemu by qmp command. It is just an updated and clipped (hmp command removed) old my patch "[PATCH RFC v3 01/14] qmp: add query-block-dirty-bitmap".

Before writing the whole thing I'd like to discuss the details. Or, may be there are existing plans on this topic, or may be someone already works on it?

Quoted 6 lines

I see it like this:

=====

- add qmp commands for dirty-bitmap functions: create_successor, abdicate, reclaime.

Hm, why do we need such low-level control over splitting and merging bitmaps from an external client?

Quoted 14 lines

- make create-successor command transaction-able
- add query-block-dirty-bitmap qmp command

then, external backup:

qmp transaction {
external-snapshot
bitmap-create-successor
}

qmp query frozen bitmap, not acquiring aio context.

do external backup, using snapshot and bitmap

Quoted 8 lines

if (success backup)
qmp bitmap-abdicate
else
qmp bitmap-reclaime

qmp merge snapshot
=====

Quoted 7 lines

Hm, I see -- so you're hoping to manage the backup *entirely* externally, so you want to be able to reach inside of QEMU and control some status conditions to guarantee it'll be safe.

I'm not convinced QEMU can guarantee such things -- due to various flush properties, race conditions on write, etc. QEMU handles all of this internally in a non-public way at the moment.

Hm, can you be more concrete? What operations are dangerous? We can do them in paused state for example.

Quoted 12 lines
Quoted 10 lines

In the following patch query-bitmap acquires aio context. This must be ofcourse dropped for frozen bitmap.
But to make it in true way, I think, I should check somehow that this is not just frozen bitmap, but the bitmap frozen by qmp command, to avoid incorrect quering of bitmap frozen by internal backup (or other mechanizm).. May be, it is not necessary.

Signature · 2 lines
Best regards,
Vladimir
#8 lore raw
Quoted 8 lines · Vladimir Sementsov-Ogievskiy
Quoted 7 lines · John Snow
Quoted 5 lines · Vladimir Sementsov-Ogievskiy

Hi all.

This is the early begin of the series which aims to add external backup api. This is needed to allow backup software use our dirty bitmaps.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Vmware and Parallels Cloud Server have this feature.

Have a link to the equivalent feature that VMWare exposes? (Or Parallels Cloud Server) ... I'm curious about what the API there looks like.

For VMware you need their Virtual Disk Api Programming Guide
http://pubs.vmware.com/vsphere-60/topic/com.vmware.ICbase/PDF/vddk60_programming.pdf

Great, thanks!

Quoted 18 lines

Look at Changed Block Tracking (CBT) , Backup and Restore.

For PCS here is part of SDK header, related to the topic:

====================================
/*
* Builds a map of the disk contents changes between 2 PITs. Parameters
hDisk : A handle of type PHT_VIRTUAL_DISK identifying
the virtual disk.

   sPit1Uuid :   Uuid of the older PIT.
   sPit2Uuid :   Uuid of the later PIT.
   phMap :       A pointer to a variable which receives the

result (a handle of type PHT_VIRTUAL_DISK_MAP).
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 6 lines
                PrlDisk_GetChangesMap_Local, (
        PRL_HANDLE hDisk,
        PRL_CONST_STR sPit1Uuid,
        PRL_CONST_STR sPit2Uuid,
        PRL_HANDLE_PTR phMap) );

Effectively giving you a dirty bitmap diff between two snapshots. Something we don't currently genuinely support in QEMU.

Quoted 11 lines

/*
* Reports the number of significant bits in the map. Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
phSize : A pointer to a variable which receives the
result.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 4 lines
                PrlDiskMap_GetSize, (
        PRL_HANDLE hMap,
        PRL_UINT32_PTR pnSize) );

I assume this is roughly the dirty bit count, for us, this would be dirty clusters. (Or whatever granularity you specified, but usually clusters.)

Quoted 12 lines

/*
* Reports the size (in bytes) of a block mapped by a single bit
* in the map.
Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
phSize : A pointer to a variable which receives the
result.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 4 lines
                PrlDiskMap_GetGranularity, (
        PRL_HANDLE hMap,
        PRL_UINT32_PTR pnSize) );

Basically a granularity query.

Quoted 13 lines

/*
* Returns bits from the blocks map.
Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
pBuffer : A pointer to a store.
pnCapacity : A pointer to a variable holding the size
of the buffer and receiving the number of bytes actually written.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 5 lines
                PrlDiskMap_Read, (
        PRL_HANDLE hMap,
        PRL_VOID_PTR pBuffer,
        PRL_UINT32_PTR pnCapacity) );

And this would be a direct bitmap query.

Is the expected usage here that the third party client will use this bitmap to read the source image? Or do you query for the data from API?

I think the thought among block devs would be to opt for more of the second option, and less allowing clients to directly interface with the image files.

Quoted 48 lines

=======================================

Quoted 45 lines
Quoted 9 lines

There is only one patch here, about querying dirty bitmap from qemu by qmp command. It is just an updated and clipped (hmp command removed) old my patch "[PATCH RFC v3 01/14] qmp: add query-block-dirty-bitmap".

Before writing the whole thing I'd like to discuss the details. Or, may be there are existing plans on this topic, or may be someone already works on it?

Quoted 7 lines

I see it like this:

=====

- add qmp commands for dirty-bitmap functions: create_successor, abdicate,
reclaime.

Hm, why do we need such low-level control over splitting and merging bitmaps from an external client?

Quoted 14 lines

- make create-successor command transaction-able
- add query-block-dirty-bitmap qmp command

then, external backup:

qmp transaction {
external-snapshot
bitmap-create-successor
}

qmp query frozen bitmap, not acquiring aio context.

do external backup, using snapshot and bitmap

Quoted 8 lines

if (success backup)
qmp bitmap-abdicate
else
qmp bitmap-reclaime

qmp merge snapshot
=====

Hm, I see -- so you're hoping to manage the backup *entirely* externally, so you want to be able to reach inside of QEMU and control some status conditions to guarantee it'll be safe.

Quoted 7 lines
Quoted 3 lines

I'm not convinced QEMU can guarantee such things -- due to various flush properties, race conditions on write, etc. QEMU handles all of this internally in a non-public way at the moment.

Hm, can you be more concrete? What operations are dangerous? We can do them in paused state for example.

I suppose if you're going to pause the VM, then it should be reasonably safe, but recently there have been endeavors to augment the .qcow2 format to prohibit concurrent access, which might include a paused VM as well, I'm not clear on the implementation.

If you do it via paused only, then you also don't need to expose the freeze/rollback mechanisms: the existing clear mechanism alone is sufficient:

(A) The frozen backup fails. Nothing new has been written, so we don't need to adjust anything, we can just try again.
(B) The frozen backup succeeds. We can just clear the bitmap before unfreezing.

I definitely have reservations about using this as a live fleecing mechanism -- the backup block job uses a write-notifier to make just-in-time backups of data before it is altered, leaving it the only "safe" live backup mechanism in QEMU currently. (Alongside mirror.)

I actually have some patches from Fam to introduce a live fleecing mechanism into QEMU (The idea being you create a point-in-time drive you can get data from via NBD, then delete it when done) that might be more appropriate, but I ran into a lot of problems with the patch. I'll post the WIP for that patch to try to solicit comments on the best way forward.

Otherwise, My biggest question here is:
"What does fleecing a backup externally provide as a benefit over backing up to an NBD target?"

You can already today perform incremental backups to an NBD target to copy the data out via an external mechanism, is this not sufficient for Parallels? If not, why?

Quoted 13 lines
Quoted 12 lines
Quoted 10 lines

In the following patch query-bitmap acquires aio context. This must be ofcourse dropped for frozen bitmap.
But to make it in true way, I think, I should check somehow that this is not just frozen bitmap, but the bitmap frozen by qmp command, to avoid incorrect quering of bitmap frozen by internal backup (or other mechanizm).. May be, it is not necessary.

#9 lore raw
Quoted 42 lines · John Snow
Quoted 7 lines · Vladimir Sementsov-Ogievskiy
Quoted 6 lines · John Snow
Quoted 5 lines · Vladimir Sementsov-Ogievskiy

Hi all.

This is the early begin of the series which aims to add external backup api. This is needed to allow backup software use our dirty bitmaps.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Vmware and Parallels Cloud Server have this feature.

Have a link to the equivalent feature that VMWare exposes? (Or Parallels Cloud Server) ... I'm curious about what the API there looks like.

For VMware you need their Virtual Disk Api Programming Guide
http://pubs.vmware.com/vsphere-60/topic/com.vmware.ICbase/PDF/vddk60_programming.pdf

Great, thanks!

Quoted 18 lines

Look at Changed Block Tracking (CBT) , Backup and Restore.

For PCS here is part of SDK header, related to the topic:

====================================
/*
* Builds a map of the disk contents changes between 2 PITs. Parameters
hDisk : A handle of type PHT_VIRTUAL_DISK identifying
the virtual disk.
sPit1Uuid : Uuid of the older PIT.
sPit2Uuid : Uuid of the later PIT.
phMap : A pointer to a variable which receives the
result (a handle of type PHT_VIRTUAL_DISK_MAP).
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 6 lines
                 PrlDisk_GetChangesMap_Local, (
         PRL_HANDLE hDisk,
         PRL_CONST_STR sPit1Uuid,
         PRL_CONST_STR sPit2Uuid,
         PRL_HANDLE_PTR phMap) );
Quoted 2 lines

Effectively giving you a dirty bitmap diff between two snapshots. Something we don't currently genuinely support in QEMU.

Just start dirty bitmap at point a and stop at point b..

Quoted 56 lines
Quoted 12 lines

/*
* Reports the number of significant bits in the map. Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
phSize : A pointer to a variable which receives the
result.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 4 lines
                 PrlDiskMap_GetSize, (
         PRL_HANDLE hMap,
         PRL_UINT32_PTR pnSize) );

I assume this is roughly the dirty bit count, for us, this would be dirty clusters. (Or whatever granularity you specified, but usually clusters.)

Quoted 12 lines

/*
* Reports the size (in bytes) of a block mapped by a single bit
* in the map.
Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
phSize : A pointer to a variable which receives the
result.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 4 lines
                 PrlDiskMap_GetGranularity, (
         PRL_HANDLE hMap,
         PRL_UINT32_PTR pnSize) );

Basically a granularity query.

Quoted 13 lines

/*
* Returns bits from the blocks map.
Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
pBuffer : A pointer to a store.
pnCapacity : A pointer to a variable holding the size
of the buffer and receiving the number of bytes actually written.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 5 lines
                 PrlDiskMap_Read, (
         PRL_HANDLE hMap,
         PRL_VOID_PTR pBuffer,
         PRL_UINT32_PTR pnCapacity) );
Quoted 4 lines

And this would be a direct bitmap query.

Is the expected usage here that the third party client will use this bitmap to read the source image? Or do you query for the data from API?

- from API.

Quoted 63 lines

I think the thought among block devs would be to opt for more of the second option, and less allowing clients to directly interface with the image files.

Quoted 47 lines

=======================================

Quoted 44 lines
Quoted 8 lines

There is only one patch here, about querying dirty bitmap from qemu by qmp command. It is just an updated and clipped (hmp command removed) old my patch "[PATCH RFC v3 01/14] qmp: add query-block-dirty-bitmap".

Before writing the whole thing I'd like to discuss the details. Or, may be there are existing plans on this topic, or may be someone already works on it?

Quoted 7 lines

I see it like this:

=====

- add qmp commands for dirty-bitmap functions: create_successor, abdicate,
reclaime.

Hm, why do we need such low-level control over splitting and merging bitmaps from an external client?

Quoted 14 lines

- make create-successor command transaction-able
- add query-block-dirty-bitmap qmp command

then, external backup:

qmp transaction {
external-snapshot
bitmap-create-successor
}

qmp query frozen bitmap, not acquiring aio context.

do external backup, using snapshot and bitmap

Quoted 8 lines

if (success backup)
qmp bitmap-abdicate
else
qmp bitmap-reclaime

qmp merge snapshot
=====

Hm, I see -- so you're hoping to manage the backup *entirely* externally, so you want to be able to reach inside of QEMU and control some status conditions to guarantee it'll be safe.

Quoted 6 lines
Quoted 3 lines

I'm not convinced QEMU can guarantee such things -- due to various flush properties, race conditions on write, etc. QEMU handles all of this internally in a non-public way at the moment.

Hm, can you be more concrete? What operations are dangerous? We can do them in paused state for example.

I suppose if you're going to pause the VM, then it should be reasonably safe, but recently there have been endeavors to augment the .qcow2 format to prohibit concurrent access, which might include a paused VM as well, I'm not clear on the implementation.

Quoted 8 lines

If you do it via paused only, then you also don't need to expose the freeze/rollback mechanisms: the existing clear mechanism alone is sufficient:

(A) The frozen backup fails. Nothing new has been written, so we don't need to adjust anything, we can just try again.
(B) The frozen backup succeeds. We can just clear the bitmap before unfreezing.

We can't query bitmap in paused state - it may take too much time.

Quoted 11 lines

I definitely have reservations about using this as a live fleecing mechanism -- the backup block job uses a write-notifier to make just-in-time backups of data before it is altered, leaving it the only "safe" live backup mechanism in QEMU currently. (Alongside mirror.)

I actually have some patches from Fam to introduce a live fleecing mechanism into QEMU (The idea being you create a point-in-time drive you can get data from via NBD, then delete it when done) that might be more appropriate, but I ran into a lot of problems with the patch. I'll post the WIP for that patch to try to solicit comments on the best way forward.

After adding
=============

block.c +3 -0
@@ -1276,6 +1276,9 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
     /* Otherwise we won't be able to commit due to check in bdrv_commit */
     bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_COMMIT_TARGET,
                     bs->backing_blocker);
+
+    bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_SOURCE,
+                    bs->backing_blocker);
 out:
     bdrv_refresh_limits(bs, NULL);
 }

==============
and tiny fix for qemu_io interface in iotest

Fam's "qemu-iotests: Image fleecing test case 089" works for me. Isn't it enough?

Quoted 4 lines

Otherwise, My biggest question here is:
"What does fleecing a backup externally provide as a benefit over backing up to an NBD target?"

Look at our answers on v2 of these series:

Quoted 30 lines · Denis V. Lunev
Quoted 9 lines · Fam Zheng
Quoted 6 lines · Vladimir Sementsov-Ogievskiy

Hi all.

These series which aims to add external backup api. This is needed to allow backup software use our dirty bitmaps.

Vmware and Parallels Cloud Server have this feature.

What is the advantage of this appraoch over "drive-backup sync=incremental ..."?

This will allow third-party vendors to backup QEMU VMs into their own formats or to the cloud etc.

You can already today perform incremental backups to an NBD target to copy the data out via an external mechanism, is this not sufficient for Parallels? If not, why?

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

In the following patch query-bitmap acquires aio context. This must be ofcourse dropped for frozen bitmap.
But to make it in true way, I think, I should check somehow that this is not just frozen bitmap, but the bitmap frozen by qmp command, to avoid incorrect quering of bitmap frozen by internal backup (or other mechanizm).. May be, it is not necessary.

Signature · 2 lines
Best regards,
Vladimir
#10 lore raw
Quoted 184 lines · Vladimir Sementsov-Ogievskiy
Quoted 45 lines · John Snow
Quoted 8 lines · Vladimir Sementsov-Ogievskiy
Quoted 7 lines · John Snow
Quoted 6 lines · Vladimir Sementsov-Ogievskiy

Hi all.

This is the early begin of the series which aims to add external backup
api. This is needed to allow backup software use our dirty bitmaps.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Vmware and Parallels Cloud Server have this feature.

Have a link to the equivalent feature that VMWare exposes? (Or Parallels
Cloud Server) ... I'm curious about what the API there looks like.

For VMware you need their Virtual Disk Api Programming Guide
http://pubs.vmware.com/vsphere-60/topic/com.vmware.ICbase/PDF/vddk60_programming.pdf

Great, thanks!

Quoted 18 lines

Look at Changed Block Tracking (CBT) , Backup and Restore.

For PCS here is part of SDK header, related to the topic:

====================================
/*
* Builds a map of the disk contents changes between 2 PITs. Parameters
hDisk : A handle of type PHT_VIRTUAL_DISK identifying
the virtual disk.
sPit1Uuid : Uuid of the older PIT.
sPit2Uuid : Uuid of the later PIT.
phMap : A pointer to a variable which receives the
result (a handle of type PHT_VIRTUAL_DISK_MAP).
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 6 lines
                 PrlDisk_GetChangesMap_Local, (
         PRL_HANDLE hDisk,
         PRL_CONST_STR sPit1Uuid,
         PRL_CONST_STR sPit2Uuid,
         PRL_HANDLE_PTR phMap) );
Quoted 2 lines

Effectively giving you a dirty bitmap diff between two snapshots. Something we don't currently genuinely support in QEMU.

Just start dirty bitmap at point a and stop at point b..

Quoted 56 lines
Quoted 12 lines

/*
* Reports the number of significant bits in the map. Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
phSize : A pointer to a variable which receives the
result.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 4 lines
                 PrlDiskMap_GetSize, (
         PRL_HANDLE hMap,
         PRL_UINT32_PTR pnSize) );

I assume this is roughly the dirty bit count, for us, this would be dirty clusters. (Or whatever granularity you specified, but usually clusters.)

Quoted 12 lines

/*
* Reports the size (in bytes) of a block mapped by a single bit
* in the map.
Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
phSize : A pointer to a variable which receives the
result.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 4 lines
                 PrlDiskMap_GetGranularity, (
         PRL_HANDLE hMap,
         PRL_UINT32_PTR pnSize) );

Basically a granularity query.

Quoted 13 lines

/*
* Returns bits from the blocks map.
Parameters
hMap : A handle of type PHT_VIRTUAL_DISK_MAP identifying
the changes map.
pBuffer : A pointer to a store.
pnCapacity : A pointer to a variable holding the size
of the buffer and receiving the number of bytes actually written.
Returns
PRL_RESULT.
*/
PRL_METHOD_DECL( PARALLELS_API_VER_5,

Quoted 5 lines
                 PrlDiskMap_Read, (
         PRL_HANDLE hMap,
         PRL_VOID_PTR pBuffer,
         PRL_UINT32_PTR pnCapacity) );
Quoted 4 lines

And this would be a direct bitmap query.

Is the expected usage here that the third party client will use this bitmap to read the source image? Or do you query for the data from API?

- from API.

Quoted 70 lines

I think the thought among block devs would be to opt for more of the second option, and less allowing clients to directly interface with the image files.

Quoted 49 lines

=======================================

Quoted 46 lines
Quoted 10 lines

There is only one patch here, about querying dirty bitmap from qemu by qmp command. It is just an updated and clipped (hmp command removed) old
my patch "[PATCH RFC v3 01/14] qmp: add query-block-dirty-bitmap".

Before writing the whole thing I'd like to discuss the details. Or, may
be there are existing plans on this topic, or may be someone already works on it?

Quoted 7 lines

I see it like this:

=====

- add qmp commands for dirty-bitmap functions: create_successor, abdicate,
reclaime.

Hm, why do we need such low-level control over splitting and merging bitmaps from an external client?

Quoted 14 lines

- make create-successor command transaction-able
- add query-block-dirty-bitmap qmp command

then, external backup:

qmp transaction {
external-snapshot
bitmap-create-successor
}

qmp query frozen bitmap, not acquiring aio context.

do external backup, using snapshot and bitmap

Quoted 8 lines

if (success backup)
qmp bitmap-abdicate
else
qmp bitmap-reclaime

qmp merge snapshot
=====

Hm, I see -- so you're hoping to manage the backup *entirely* externally, so you want to be able to reach inside of QEMU and control some status conditions to guarantee it'll be safe.

Quoted 7 lines
Quoted 4 lines

I'm not convinced QEMU can guarantee such things -- due to various flush
properties, race conditions on write, etc. QEMU handles all of this internally in a non-public way at the moment.

Hm, can you be more concrete? What operations are dangerous? We can do them in paused state for example.

I suppose if you're going to pause the VM, then it should be reasonably safe, but recently there have been endeavors to augment the .qcow2 format to prohibit concurrent access, which might include a paused VM as well, I'm not clear on the implementation.

If you do it via paused only, then you also don't need to expose the freeze/rollback mechanisms: the existing clear mechanism alone is sufficient:

Quoted 7 lines
Quoted 4 lines

(A) The frozen backup fails. Nothing new has been written, so we don't need to adjust anything, we can just try again.
(B) The frozen backup succeeds. We can just clear the bitmap before unfreezing.

We can't query bitmap in paused state - it may take too much time.

And I think it is currently unsafe to fetch the data from disk while the VM is running, so you'll have to solve one or the other problem...

Quoted 79 lines
Quoted 6 lines

I definitely have reservations about using this as a live fleecing mechanism -- the backup block job uses a write-notifier to make just-in-time backups of data before it is altered, leaving it the only "safe" live backup mechanism in QEMU currently. (Alongside mirror.)

Quoted 6 lines

I actually have some patches from Fam to introduce a live fleecing mechanism into QEMU (The idea being you create a point-in-time drive you can get data from via NBD, then delete it when done) that might be more appropriate, but I ran into a lot of problems with the patch. I'll post the WIP for that patch to try to solicit comments on the best way forward.

After adding
=============

block.c +3 -0
@@ -1276,6 +1276,9 @@ void bdrv_set_backing_hd(BlockDriverState *bs,
 BlockDriverState *backing_hd)
     /* Otherwise we won't be able to commit due to check in bdrv_commit */
     bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_COMMIT_TARGET,
                     bs->backing_blocker);
+
+    bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_SOURCE,
+                    bs->backing_blocker);
 out:
     bdrv_refresh_limits(bs, NULL);

}
==============
and tiny fix for qemu_io interface in iotest

Fam's "qemu-iotests: Image fleecing test case 089" works for me. Isn't it enough?

Quoted 4 lines

Otherwise, My biggest question here is:
"What does fleecing a backup externally provide as a benefit over backing up to an NBD target?"

Look at our answers on v2 of these series:

Quoted 33 lines · Denis V. Lunev
Quoted 11 lines · Fam Zheng
Quoted 7 lines · Vladimir Sementsov-Ogievskiy

Hi all.

These series which aims to add external backup api. This is needed to allow
backup software use our dirty bitmaps.

Vmware and Parallels Cloud Server have this feature.

What is the advantage of this appraoch over "drive-backup sync=incremental
..."?

This will allow third-party vendors to backup QEMU VMs into their own formats or to the cloud etc.

You can already today perform incremental backups to an NBD target to copy the data out via an external mechanism, is this not sufficient for Parallels? If not, why?

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

In the following patch query-bitmap acquires aio context. This must be ofcourse dropped for frozen bitmap.
But to make it in true way, I think, I should check somehow that this is
not just frozen bitmap, but the bitmap frozen by qmp command, to avoid incorrect quering of bitmap frozen by internal backup (or other mechanizm).. May be, it is not necessary.