Skip to contentSkip to conversation

Dirty bitmaps migration

RFC PATCH Superseded Vladimir Sementsov-Ogievskiy 3 participants 21 messages Feb 27, 2015 – May 7, 2015

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#11 lore raw

RFC PATCH v4 9/13 iotests: add add_incoming_migration to VM class

In reply to Vladimir Sementsov-Ogievskiy
---
 tests/qemu-iotests/iotests.py | 6 ++++++
 1 file changed, 6 insertions(+)
tests/qemu-iotests/iotests.py +6 -0
index fa756b4..75640b2 100644
@@ -111,6 +111,12 @@ class VM(object):
         self._num_drives += 1
         return self
 
+    def add_incoming_migration(self, desc):
+        '''Add an incoming migration to the VM'''
+        self._args.append('-incoming')
+        self._args.append(desc)
+        return self
+
     def pause_drive(self, drive, event=None):
         '''Pause drive r/w operations'''
         if not event:
Signature · 1 line
1.9.1
#3 lore raw

RFC PATCH v4 3/13 block: tiny refactoring: minimize hbitmap_(set/reset) usage

In reply to Vladimir Sementsov-Ogievskiy
---
 block.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
block.c +3 -4
index e95a5ae..a127fd2 100644
@@ -5670,8 +5670,7 @@ void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
 
 void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap)
 {
-    assert(bdrv_dirty_bitmap_enabled(bitmap));
-    hbitmap_reset(bitmap->bitmap, 0, bitmap->size);
+    bdrv_reset_dirty_bitmap(bitmap, 0, bitmap->size);
 }
 
 const char *bdrv_dirty_bitmap_name(const BdrvDirtyBitmap *bitmap)
@@ -5718,7 +5717,7 @@ static void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
         if (!bdrv_dirty_bitmap_enabled(bitmap)) {
             continue;
         }
-        hbitmap_set(bitmap->bitmap, cur_sector, nr_sectors);
+        bdrv_set_dirty_bitmap(bitmap, cur_sector, nr_sectors);
     }
 }
 
@@ -5730,7 +5729,7 @@ static void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector,
         if (!bdrv_dirty_bitmap_enabled(bitmap)) {
             continue;
         }
-        hbitmap_reset(bitmap->bitmap, cur_sector, nr_sectors);
+        bdrv_reset_dirty_bitmap(bitmap, cur_sector, nr_sectors);
     }
 }
 
Signature · 1 line
1.9.1
#5 lore raw

RFC PATCH v4 5/13 block: add bdrv_next_dirty_bitmap()

In reply to Vladimir Sementsov-Ogievskiy

Like bdrv_next() - bdrv_next_dirty_bitmap() is a function to provide access to private dirty bitmaps list.

---
 block.c               | 10 ++++++++++
 include/block/block.h |  2 ++
 2 files changed, 12 insertions(+)
block.c +10 -0
index e77be2e..7b6251c 100644
@@ -5653,6 +5653,16 @@ BlockDirtyBitmapInfo *bdrv_query_dirty_bitmap(BlockDriverState *bs,
     return info;
 }
 
+BdrvDirtyBitmap *bdrv_next_dirty_bitmap(BlockDriverState *bs,
+                                        BdrvDirtyBitmap *bitmap)
+{
+    if (bitmap == NULL) {
+        return QLIST_FIRST(&bs->dirty_bitmaps);
+    }
+
+    return QLIST_NEXT(bitmap, list);
+}
+
 int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector)
 {
     if (bitmap) {
include/block/block.h +2 -0
index 00e34b5..ae08d51 100644
@@ -487,6 +487,8 @@ void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap *bitmap,
 void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
                                           uint64_t start, uint64_t count);
 void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
+BdrvDirtyBitmap *bdrv_next_dirty_bitmap(BlockDriverState *bs,
+                                        BdrvDirtyBitmap *bitmap);
 
 /* chunk size here is number of bytes of the @bitmap data per one bit of the
  * meta bitmap being created */
Signature · 1 line
1.9.1
#6 lore raw

RFC PATCH v4 6/13 qapi: add dirty-bitmaps migration capability

In reply to Vladimir Sementsov-Ogievskiy
---
 include/migration/migration.h | 1 +
 migration/migration.c         | 9 +++++++++
 qapi-schema.json              | 5 ++++-
 3 files changed, 14 insertions(+), 1 deletion(-)
include/migration/migration.h +1 -0
index f37348b..719875d 100644
@@ -145,6 +145,7 @@ void migrate_del_blocker(Error *reason);
 
 bool migrate_rdma_pin_all(void);
 bool migrate_zero_blocks(void);
+bool migrate_dirty_bitmaps(void);
 
 bool migrate_auto_converge(void);
 
migration/migration.c +9 -0
index b3adbc6..68e7478 100644
@@ -567,6 +567,15 @@ bool migrate_zero_blocks(void)
     return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
 }
 
+bool migrate_dirty_bitmaps(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->enabled_capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
+}
+
 int migrate_use_xbzrle(void)
 {
     MigrationState *s;
qapi-schema.json +4 -1
index 0c31203..70b54ab 100644
@@ -494,10 +494,13 @@
 # @auto-converge: If enabled, QEMU will automatically throttle down the guest
 #          to speed up convergence of RAM migration. (since 1.6)
 #
+# @dirty-bitmaps: If enabled, QEMU will migrate named dirty bitmaps. (since 2.3)
+#
 # Since: 1.2
 ##
 { 'enum': 'MigrationCapability',
-  'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks'] }
+  'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks',
+           'dirty-bitmaps'] }
 
 ##
 # @MigrationCapabilityStatus
Signature · 1 line
1.9.1
#14 lore raw

RFC PATCH v4 11/13 qapi: add md5 checksum of last dirty bitmap level to query-block

In reply to Vladimir Sementsov-Ogievskiy
---
 block.c                | 1 +
 include/qemu/hbitmap.h | 8 ++++++++
 qapi/block-core.json   | 4 +++-
 util/hbitmap.c         | 8 ++++++++
 4 files changed, 20 insertions(+), 1 deletion(-)
block.c +1 -0
index 7b6251c..96bcc05 100644
@@ -5604,6 +5604,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
         info->name = g_strdup(bm->name);
         info->disabled = bm->disabled;
         info->frozen = bdrv_dirty_bitmap_frozen(bm);
+        info->md5 = hbitmap_md5(bm->bitmap);
         entry->value = info;
         *plist = entry;
         plist = &entry->next;
include/qemu/hbitmap.h +8 -0
index 10ce05b..2fb748a 100644
@@ -188,6 +188,14 @@ void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t start, uint64_t count);
 void hbitmap_deserialize_finish(HBitmap *hb);
 
 /**
+ * hbitmap_md5:
+ * @bitmap: HBitmap to operate on.
+ *
+ * Returns md5 checksum of the last level.
+ */
+char *hbitmap_md5(const HBitmap *bitmap);
+
+/**
  * hbitmap_free:
  * @hb: HBitmap to operate on.
  *
qapi/block-core.json +3 -1
index 25dea80..2028d37 100644
@@ -336,11 +336,13 @@
 #
 # @frozen: whether the dirty bitmap is frozen (Since 2.3)
 #
+# @md5: md5 checksum of the last bitmap level (since 2.3)
+#
 # Since: 1.3
 ##
 { 'type': 'BlockDirtyInfo',
   'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
-           'disabled': 'bool', 'frozen': 'bool'} }
+           'disabled': 'bool', 'frozen': 'bool', 'md5': 'str'} }
 
 ##
 # @BlockInfo:
util/hbitmap.c +8 -0
index 1a123da..8de94eb 100644
@@ -525,3 +525,11 @@ bool hbitmap_merge(HBitmap *a, const HBitmap *b)
 
     return true;
 }
+
+char *hbitmap_md5(const HBitmap *bitmap)
+{
+    uint64_t size =
+        MAX((bitmap->size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);
+    const guchar *data = (const guchar *)bitmap->levels[HBITMAP_LEVELS - 1];
+    return g_compute_checksum_for_data(G_CHECKSUM_MD5, data, size);
+}
Signature · 1 line
1.9.1
#2 lore raw

RFC PATCH v4 2/13 block: BdrvDirtyBitmap serialization interface

In reply to Vladimir Sementsov-Ogievskiy

Several functions to provide necessary access to BdrvDirtyBitmap for block-migration.c

---
 block.c               | 36 ++++++++++++++++++++++++++++++++++++
 include/block/block.h | 13 +++++++++++++
 2 files changed, 49 insertions(+)
block.c +36 -0
index e4547d7..e95a5ae 100644
@@ -5674,6 +5674,42 @@ void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap)
     hbitmap_reset(bitmap->bitmap, 0, bitmap->size);
 }
 
+const char *bdrv_dirty_bitmap_name(const BdrvDirtyBitmap *bitmap)
+{
+    return bitmap->name;
+}
+
+uint64_t bdrv_dirty_bitmap_data_size(const BdrvDirtyBitmap *bitmap,
+                                     uint64_t count)
+{
+    return hbitmap_data_size(bitmap->bitmap, count);
+}
+
+void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
+                                      uint8_t *buf, uint64_t start,
+                                      uint64_t count)
+{
+    hbitmap_serialize_part(bitmap->bitmap, buf, start, count);
+}
+
+void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap *bitmap,
+                                        uint8_t *buf, uint64_t start,
+                                        uint64_t count)
+{
+    hbitmap_deserialize_part(bitmap->bitmap, buf, start, count);
+}
+
+void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
+                                          uint64_t start, uint64_t count)
+{
+    hbitmap_deserialize_zeroes(bitmap->bitmap, start, count);
+}
+
+void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap)
+{
+    hbitmap_deserialize_finish(bitmap->bitmap);
+}
+
 static void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector,
                            int nr_sectors)
 {
include/block/block.h +13 -0
index c9d96a6..c6a928d 100644
@@ -474,6 +474,19 @@ 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);
 
+const char *bdrv_dirty_bitmap_name(const BdrvDirtyBitmap *bitmap);
+uint64_t bdrv_dirty_bitmap_data_size(const BdrvDirtyBitmap *bitmap,
+                                     uint64_t count);
+void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap,
+                                      uint8_t *buf, uint64_t start,
+                                      uint64_t count);
+void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap *bitmap,
+                                        uint8_t *buf, uint64_t start,
+                                        uint64_t count);
+void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
+                                          uint64_t start, uint64_t count);
+void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
+
 void bdrv_enable_copy_on_read(BlockDriverState *bs);
 void bdrv_disable_copy_on_read(BlockDriverState *bs);
 
Signature · 1 line
1.9.1
#10 lore raw

RFC PATCH v4 8/13 iotests: maintain several vms in test

In reply to Vladimir Sementsov-Ogievskiy

The only problem with it is the same qmp socket name (which is vm._monitor_path) for all vms. And because of this second vm couldn't be lauched (vm.launch() fails because of socket is already in use). This patch adds a number of vm into vm._monitor_path

---
 tests/qemu-iotests/iotests.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/qemu-iotests/iotests.py +4 -2
index cf5faac..fa756b4 100644
@@ -77,16 +77,18 @@ def create_image(name, size):
 
 class VM(object):
     '''A QEMU VM'''
+    nb_vms = 0
 
     def __init__(self):
-        self._monitor_path = os.path.join(test_dir, 'qemu-mon.%d' % os.getpid())
-        self._qemu_log_path = os.path.join(test_dir, 'qemu-log.%d' % os.getpid())
+        self._monitor_path = os.path.join(test_dir, 'qemu-mon.%d.%d' % (os.getpid(), VM.nb_vms))
+        self._qemu_log_path = os.path.join(test_dir, 'qemu-log.%d.%d' % (os.getpid(), VM.nb_vms))
         self._args = qemu_args + ['-chardev',
                      'socket,id=mon,path=' + self._monitor_path,
                      '-mon', 'chardev=mon,mode=control',
                      '-qtest', 'stdio', '-machine', 'accel=qtest',
                      '-display', 'none', '-vga', 'none']
         self._num_drives = 0
+        VM.nb_vms += 1
 
     # This can be used to add an unused monitor instance.
     def add_monitor_telnet(self, ip, port):
Signature · 1 line
1.9.1
#17 lore raw

RFC PATCH v4 12/13 iotests: add dirty bitmap migration test

In reply to Vladimir Sementsov-Ogievskiy

The test starts two vms (vm_a, vm_b), create dirty bitmap in the first one, do several writes to corresponding device and then migrate vm_a to vm_b with dirty bitmaps.

---
 tests/qemu-iotests/117     | 84 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/117.out |  5 +++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 90 insertions(+)
 create mode 100755 tests/qemu-iotests/117
 create mode 100644 tests/qemu-iotests/117.out
tests/qemu-iotests/117 new file +84 -0
new file mode 100755
index 0000000..9fab5d0
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+#
+# Tests for dirty bitmaps migration.
+#
+# (C) Vladimir Sementsov-Ogievskiy 2015
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import iotests
+import time
+from iotests import qemu_img
+
+disk_a = os.path.join(iotests.test_dir, 'disk_a')
+disk_b = os.path.join(iotests.test_dir, 'disk_b')
+fifo   = os.path.join(iotests.test_dir, 'fifo')
+
+size   = 0x40000000 # 1G
+sector_size = 512
+granularity = 0x10000
+regions = [
+    { 'start': 0,          'count': 0x100000 },
+    { 'start': 0x10000000, 'count': 0x20000  },
+    { 'start': 0x39990000, 'count': 0x10000  }
+    ]
+
+class TestDirtyBitmapMigration(iotests.QMPTestCase):
+
+    def setUp(self):
+        os.mkfifo(fifo)
+        qemu_img('create', '-f', iotests.imgfmt, disk_a, str(size))
+        qemu_img('create', '-f', iotests.imgfmt, disk_b, str(size))
+        self.vm_a = iotests.VM().add_drive(disk_a)
+        self.vm_b = iotests.VM().add_drive(disk_b)
+        self.vm_b.add_incoming_migration("exec: cat " + fifo)
+        self.vm_a.launch()
+        self.vm_b.launch()
+
+    def tearDown(self):
+        self.vm_a.shutdown()
+        self.vm_b.shutdown()
+        os.remove(disk_a)
+        os.remove(disk_b)
+        os.remove(fifo)
+
+    def test_migration(self):
+        result = self.vm_a.qmp('block-dirty-bitmap-add', node='drive0',
+                               name='bitmap', granularity=granularity)
+        self.assert_qmp(result, 'return', {});
+
+        for r in regions:
+          self.vm_a.hmp_qemu_io('drive0',
+                                'write %d %d' % (r['start'], r['count']))
+
+        result = self.vm_a.qmp('query-block');
+        md5 = result['return'][0]['dirty-bitmaps'][0]['md5']
+
+        result = self.vm_a.qmp('migrate-set-capabilities',
+                               capabilities=[{'capability': 'dirty-bitmaps',
+                                              'state': True}])
+        self.assert_qmp(result, 'return', {})
+
+        result = self.vm_a.qmp('migrate', uri='exec:cat>' + fifo)
+        self.assertIsNotNone(self.vm_a.event_wait("STOP"))
+        self.assertIsNotNone(self.vm_b.event_wait("RESUME"))
+
+        result = self.vm_b.qmp('query-block');
+        self.assert_qmp(result, 'return[0]/dirty-bitmaps[0]/md5', md5);
+
+
+if __name__ == '__main__':
+    iotests.main()
tests/qemu-iotests/117.out new file +5 -0
new file mode 100644
index 0000000..ae1213e
@@ -0,0 +1,5 @@
+.
+----------------------------------------------------------------------
+Ran 1 tests
+
+OK
tests/qemu-iotests/group +1 -0
index b4ddf1b..6ad5b55 100644
@@ -118,3 +118,4 @@
 113 rw auto quick
 114 rw auto quick
 116 rw auto quick
+117 rw auto quick
Signature · 1 line
1.9.1
#18 lore raw

RFC PATCH v4 13/13 migration/qemu-file: make functions qemu_(get/put)_string public

In reply to Vladimir Sementsov-Ogievskiy
---
 include/migration/qemu-file.h  | 17 +++++++++++++++++
 migration/block-dirty-bitmap.c | 35 -----------------------------------
 migration/qemu-file.c          | 18 ++++++++++++++++++
 3 files changed, 35 insertions(+), 35 deletions(-)
include/migration/qemu-file.h +17 -0
index a923cec..178ae63 100644
@@ -310,4 +310,21 @@ static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
 {
     qemu_get_be64s(f, (uint64_t *)pv);
 }
+
+/* read name from qemu file:
+ * format:
+ * 1 byte : len = name length (<256)
+ * len bytes : name without last zero byte
+ *
+ * name should point to the buffer >= 256 bytes length
+ */
+char *qemu_get_string(QEMUFile *f, char *name);
+
+/* write name to qemu file:
+ * format:
+ * same as for qemu_get_string
+ *
+ * maximum name length is 255
+ */
+void qemu_put_string(QEMUFile *f, const char *name);
 #endif
migration/block-dirty-bitmap.c +0 -35
index 2d3ba23..3c610af 100644
@@ -164,41 +164,6 @@ static void qemu_put_flags(QEMUFile *f, uint32_t flags)
     qemu_put_be32(f, flags | DIRTY_BITMAP_MIG_FLAGS_SIZE_32);
 }
 
-/* read name from qemu file:
- * format:
- * 1 byte : len = name length (<256)
- * len bytes : name without last zero byte
- *
- * name should point to the buffer >= 256 bytes length
- */
-static char *qemu_get_string(QEMUFile *f, char *name)
-{
-    int len = qemu_get_byte(f);
-    qemu_get_buffer(f, (uint8_t *)name, len);
-    name[len] = '\0';
-
-    DPRINTF("get name: %d %s\n", len, name);
-
-    return name;
-}
-
-/* write name to qemu file:
- * format:
- * same as for qemu_get_string
- *
- * maximum name length is 255
- */
-static void qemu_put_string(QEMUFile *f, const char *name)
-{
-    int len = strlen(name);
-
-    DPRINTF("put name: %d %s\n", len, name);
-
-    assert(len < 256);
-    qemu_put_byte(f, len);
-    qemu_put_buffer(f, (const uint8_t *)name, len);
-}
-
 static void send_bitmap_header(QEMUFile *f, DirtyBitmapMigBitmapState *dbms,
                                uint32_t additional_flags)
 {
migration/qemu-file.c +18 -0
index e66e557..5439f84 100644
@@ -545,3 +545,21 @@ uint64_t qemu_get_be64(QEMUFile *f)
     v |= qemu_get_be32(f);
     return v;
 }
+
+char *qemu_get_string(QEMUFile *f, char *name)
+{
+    int len = qemu_get_byte(f);
+    qemu_get_buffer(f, (uint8_t *)name, len);
+    name[len] = '\0';
+
+    return name;
+}
+
+void qemu_put_string(QEMUFile *f, const char *name)
+{
+    int len = strlen(name);
+
+    assert(len < 256);
+    qemu_put_byte(f, len);
+    qemu_put_buffer(f, (const uint8_t *)name, len);
+}
Signature · 1 line
1.9.1
#0 lore raw

v4 cover Dirty bitmaps migration

These patches provide dirty bitmap migration feature. Only named dirty bitmaps are to be migrated. Migration may be enabled using migration capabilities.

v4 significant changes:
0001: tiny bugfix: out[i] -> out[i-start], same for 'in' 0007: set chunk size to 1kb, disable live iteration for
migrating data < 1mb size.

tests: only one with md5 sum is here. used function event_wait
by John Snow. (I hope, you don't mind me just adding this function with your 'Signed-off-by')

rfc: This patch set is based on v13 of
"block: incremental backup series" by John Snow, which are not pushed yet.

v3:
based on v13 of "block: incremental backup series" by John Snow.

changes from v2:
removed patch for adding dirty parameter (migration capablities used instead).

0001: printf's dropped, qapi used
0002: part0 -> zeroes
0003: part0 -> zeroes
0005: dirty_dirty -> meta
add comments about meta bitmap

0006: the format is changed, nodes used instead of devices.

other patches are new.

rfc: there are two tests. They are the same but using different
interfaces: md5 checksum of the bitmap last layer in query-block or separate query-block-dirty-bitmap with dirty bitmap regions. The second form is more appropriate for debugging, the first is more appropriate for simple regression control. Which should go to upstream?

v2:
1. bug-fixes, that are already in upstream, and renaming of function bdrv_reset_dirty_bitmap (which is already in Snow's series) are dropped
2. bitmap store/restore: the concept renamed to serialization, added function hbitmap_deserialize_part0, to not transfer zero blocks
3. migration dirty parameter: added description comment
4. Other patches are new.

v2.rfc:
Actually, in this version of the series I'm trying not use migration/block.c at all. Instead a separate migration unit is added in the new file migration/dirty-bitmap.c. Now bitmaps are migrated like blocks in block migration, they have their "dirty-dirty" bitmaps, for tracking set/unset changes during migration.

The advantages are:
- no complications of migration/block.c
- separate dirty-dirty bitmaps provide handling of "unset's"
- more effective meta-data/data ratio - no tiny bitmap-blocks.

v1:
These patches provide dirty bitmap migration feature. Only named dirty bitmaps are to be migrated. Migration is made as a part of block migration in block-migration.c.

Dirty bitmap migration may be enabled by "dirty" parameter for qmp migrate command. If "blk" and "inc" parameters are false when "dirty" is true block migration is actually skipped: no allocatoions, no bdrv_read's, no bdrv_write's, only bitmaps are migrated.

The patch set includes two my previous bug fixes, which are necessary for it. The patch set is based on Incremental backup series by John Snow.

*** BLURB HERE ***

Vladimir Sementsov-Ogievskiy (13):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interface
block: tiny refactoring: minimize hbitmap_(set/reset) usage
block: add meta bitmaps
block: add bdrv_next_dirty_bitmap()
qapi: add dirty-bitmaps migration capability
migration: add migration/block-dirty-bitmap.c
iotests: maintain several vms in test
iotests: add add_incoming_migration to VM class
iotests: add event_wait to VM class
qapi: add md5 checksum of last dirty bitmap level to query-block
iotests: add dirty bitmap migration test migration/qemu-file: make functions qemu_(get/put)_string public

 block.c                        |  98 +++++-
 include/block/block.h          |  22 ++
 include/migration/block.h      |   1 +
 include/migration/migration.h  |   1 +
 include/migration/qemu-file.h  |  17 +
 include/qemu/hbitmap.h         |  67 ++++
 migration/Makefile.objs        |   2 +-
 migration/block-dirty-bitmap.c | 693 +++++++++++++++++++++++++++++++++++++++++
 migration/migration.c          |   9 +
 migration/qemu-file.c          |  18 ++
 qapi-schema.json               |   5 +-
 qapi/block-core.json           |   4 +-
 tests/qemu-iotests/117         |  84 +++++
 tests/qemu-iotests/117.out     |   5 +
 tests/qemu-iotests/group       |   1 +
 tests/qemu-iotests/iotests.py  |  19 +-
 util/hbitmap.c                 | 106 +++++++
 vl.c                           |   1 +
 18 files changed, 1144 insertions(+), 9 deletions(-)
 create mode 100644 migration/block-dirty-bitmap.c
 create mode 100755 tests/qemu-iotests/117
 create mode 100644 tests/qemu-iotests/117.out
Signature · 1 line
1.9.1
#1 lore raw

RFC PATCH v4 1/13 hbitmap: serialization

Functions to serialize / deserialize(restore) HBitmap. HBitmap should be saved to linear sequence of bits independently of endianness and bitmap array element (unsigned long) size. Therefore Little Endian is chosen.

These functions are appropriate for dirty bitmap migration, restoring the bitmap in several steps is available. To save performance, every step writes only the last level of the bitmap. All other levels are restored by hbitmap_deserialize_finish() as a last step of restoring. So, HBitmap is inconsistent while restoring.

---
 include/qemu/hbitmap.h | 59 ++++++++++++++++++++++++++++++
 util/hbitmap.c         | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 157 insertions(+)
include/qemu/hbitmap.h +59 -0
index c19c1cb..10ce05b 100644
@@ -129,6 +129,65 @@ void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count);
 bool hbitmap_get(const HBitmap *hb, uint64_t item);
 
 /**
+ * hbitmap_data_size:
+ * @hb: HBitmap to operate on.
+ * @count: Number of bits
+ *
+ * Return amount of bytes hbitmap_serialize_part needs
+ */
+uint64_t hbitmap_data_size(const HBitmap *hb, uint64_t count);
+
+/**
+ * hbitmap_serialize_part
+ * @hb: HBitmap to oprate on.
+ * @buf: Buffer to store serialized bitmap.
+ * @start: First bit to store.
+ * @count: Number of bits to store.
+ *
+ * Stores HBitmap data corresponding to given region. The format of saved data
+ * is linear sequence of bits, so it can be used by hbitmap_deserialize_part
+ * independently of endianness and size of HBitmap level array elements
+ */
+void hbitmap_serialize_part(const HBitmap *hb, uint8_t *buf,
+                            uint64_t start, uint64_t count);
+
+/**
+ * hbitmap_deserialize_part
+ * @hb: HBitmap to operate on.
+ * @buf: Buffer to restore bitmap data from.
+ * @start: First bit to restore.
+ * @count: Number of bits to restore.
+ *
+ * Retores HBitmap data corresponding to given region. The format is the same
+ * as for hbitmap_serialize_part.
+ *
+ * ! The bitmap becomes inconsistent after this operation.
+ * hbitmap_serialize_finish should be called before using the bitmap after
+ * data restoring.
+ */
+void hbitmap_deserialize_part(HBitmap *hb, uint8_t *buf,
+                              uint64_t start, uint64_t count);
+
+/**
+ * hbitmap_deserialize_zeroes
+ * @hb: HBitmap to operate on.
+ * @start: First bit to restore.
+ * @count: Number of bits to restore.
+ *
+ * Same as hbitmap_serialize_part, but fills the bitmap with zeroes.
+ */
+void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t start, uint64_t count);
+
+/**
+ * hbitmap_deserialize_finish
+ * @hb: HBitmap to operate on.
+ *
+ * Repair HBitmap after calling hbitmap_deserialize_data. Actually, all HBitmap
+ * layers are restored here.
+ */
+void hbitmap_deserialize_finish(HBitmap *hb);
+
+/**
  * hbitmap_free:
  * @hb: HBitmap to operate on.
  *
util/hbitmap.c +98 -0

104 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

RFC PATCH v4 4/13 block: add meta bitmaps

In reply to Vladimir Sementsov-Ogievskiy

Meta bitmap is a 'dirty bitmap' for the BdrvDirtyBitmap. It tracks changes (set/unset) of this BdrvDirtyBitmap. It is needed for live migration of block dirty bitmaps.

---
 block.c               | 44 ++++++++++++++++++++++++++++++++++++++++++++
 include/block/block.h |  7 +++++++
 2 files changed, 51 insertions(+)
block.c +44 -0
index a127fd2..e77be2e 100644
@@ -58,9 +58,15 @@
  * (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().
+ *
+ * Meta bitmap:
+ * Meta bitmap is a 'dirty bitmap' for the BdrvDirtyBitmap. It tracks changes
+ * (set/unset) of this BdrvDirtyBitmap. It is needed for live migration of
+ * block dirty bitmaps.
  */
 struct BdrvDirtyBitmap {
     HBitmap *bitmap;            /* Dirty sector bitmap implementation */
+    HBitmap *meta_bitmap;       /* Meta bitmap */
     BdrvDirtyBitmap *successor; /* Anonymous child; implies frozen status */
     char *name;                 /* Optional non-empty unique ID */
     int64_t size;               /* Size of the bitmap (Number of sectors) */
@@ -5398,6 +5404,35 @@ void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap)
     bitmap->name = NULL;
 }
 
+HBitmap *bdrv_create_meta_bitmap(BdrvDirtyBitmap *bitmap,
+                                 uint64_t chunk_size)
+{
+    uint64_t sector_granularity;
+
+    assert((chunk_size & (chunk_size - 1)) == 0);
+
+    /* one chunk is corresponding to one bit of the meta bitmap, and each bit
+     * of the chunk is corresponding to 'bdrv_dirty_bitmap_granularity(bitmap)'
+     * bytes of the node */
+    sector_granularity =
+        (chunk_size * 8 * bdrv_dirty_bitmap_granularity(bitmap))
+        >> BDRV_SECTOR_BITS;
+    assert(sector_granularity);
+
+    bitmap->meta_bitmap =
+        hbitmap_alloc(bitmap->size, ffsll(sector_granularity) - 1);
+
+    return bitmap->meta_bitmap;
+}
+
+void bdrv_release_meta_bitmap(BdrvDirtyBitmap *bitmap)
+{
+    if (bitmap->meta_bitmap) {
+        hbitmap_free(bitmap->meta_bitmap);
+        bitmap->meta_bitmap = NULL;
+    }
+}
+
 BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
                                           uint32_t granularity,
                                           const char *name,
@@ -5532,6 +5567,9 @@ void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
             assert(!bdrv_dirty_bitmap_frozen(bm));
             QLIST_REMOVE(bitmap, list);
             hbitmap_free(bitmap->bitmap);
+            if (bitmap->meta_bitmap) {
+                hbitmap_free(bitmap->meta_bitmap);
+            }
             g_free(bitmap->name);
             g_free(bitmap);
             return;
@@ -5659,6 +5697,9 @@ void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
 {
     assert(bdrv_dirty_bitmap_enabled(bitmap));
     hbitmap_set(bitmap->bitmap, cur_sector, nr_sectors);
+    if (bitmap->meta_bitmap) {
+        hbitmap_set(bitmap->meta_bitmap, cur_sector, nr_sectors);
+    }
 }
 
 void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
@@ -5666,6 +5707,9 @@ void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
 {
     assert(bdrv_dirty_bitmap_enabled(bitmap));
     hbitmap_reset(bitmap->bitmap, cur_sector, nr_sectors);
+    if (bitmap->meta_bitmap) {
+        hbitmap_set(bitmap->meta_bitmap, cur_sector, nr_sectors);
+    }
 }
 
 void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap)
include/block/block.h +7 -0
index c6a928d..00e34b5 100644
@@ -4,6 +4,7 @@
 #include "block/aio.h"
 #include "qemu-common.h"
 #include "qemu/option.h"
+#include "qemu/hbitmap.h"
 #include "block/coroutine.h"
 #include "block/accounting.h"
 #include "qapi/qmp/qobject.h"
@@ -487,6 +488,12 @@ void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
                                           uint64_t start, uint64_t count);
 void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
 
+/* chunk size here is number of bytes of the @bitmap data per one bit of the
+ * meta bitmap being created */
+HBitmap *bdrv_create_meta_bitmap(BdrvDirtyBitmap *bitmap,
+                                 uint64_t granularity);
+void bdrv_release_meta_bitmap(BdrvDirtyBitmap *bitmap);
+
 void bdrv_enable_copy_on_read(BlockDriverState *bs);
 void bdrv_disable_copy_on_read(BlockDriverState *bs);
 
Signature · 1 line
1.9.1
#12 lore raw

RFC PATCH v4 10/13 iotests: add event_wait to VM class

In reply to Vladimir Sementsov-Ogievskiy
---
 tests/qemu-iotests/iotests.py | 7 +++++++
 1 file changed, 7 insertions(+)
tests/qemu-iotests/iotests.py +7 -0
index 75640b2..294b158 100644
@@ -203,6 +203,13 @@ class VM(object):
         self._qmp.clear_events()
         return events
 
+    def event_wait(self, name='BLOCK_JOB_COMPLETED', maxwait=10):
+        for _ in range(maxwait):
+            for event in self.get_qmp_events(wait=True):
+                if event['event'] == name:
+                    return event
+            return None
+
 index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
 
 class QMPTestCase(unittest.TestCase):
Signature · 1 line
1.9.1
#9 lore raw

RFC PATCH v4 7/13 migration: add migration/block-dirty-bitmap.c

In reply to Vladimir Sementsov-Ogievskiy

Live migration of dirty bitmaps. Only named dirty bitmaps, associated with root nodes and non-root named nodes are migrated.

If destination qemu is already containing a dirty bitmap with the same name as a migrated bitmap (for the same node), than, if their granularities are the same the migration will be done, otherwise the error will be generated.

If destination qemu doesn't contain such bitmap it will be created.

---
 include/migration/block.h      |   1 +
 migration/Makefile.objs        |   2 +-
 migration/block-dirty-bitmap.c | 728 +++++++++++++++++++++++++++++++++++++++++
 vl.c                           |   1 +
 4 files changed, 731 insertions(+), 1 deletion(-)
 create mode 100644 migration/block-dirty-bitmap.c
include/migration/block.h +1 -0
index ffa8ac0..566bb9f 100644
@@ -14,6 +14,7 @@
 #ifndef BLOCK_MIGRATION_H
 #define BLOCK_MIGRATION_H
 
+void dirty_bitmap_mig_init(void);
 void blk_mig_init(void);
 int blk_mig_active(void);
 uint64_t blk_mig_bytes_transferred(void);
migration/Makefile.objs +1 -1
index d929e96..128612d 100644
@@ -6,5 +6,5 @@ common-obj-y += xbzrle.o
 common-obj-$(CONFIG_RDMA) += rdma.o
 common-obj-$(CONFIG_POSIX) += exec.o unix.o fd.o
 
-common-obj-y += block.o
+common-obj-y += block.o block-dirty-bitmap.o
 
migration/block-dirty-bitmap.c new file +728 -0

728 lines not on this page · raw message

vl.c +1 -0
index 8c8f142..723a362 100644
@@ -4147,6 +4147,7 @@ int main(int argc, char **argv, char **envp)
 
     blk_mig_init();
     ram_mig_init();
+    dirty_bitmap_mig_init();
 
     /* If the currently selected machine wishes to override the units-per-bus
      * property of its default HBA interface type, do so now. */
Signature · 1 line
1.9.1
Reviewed-by on v4 6/13
#7 lore raw

Re: [Qemu-devel] [PATCH RFC v4 06/13] qapi: add dirty-bitmaps migration capability

In reply to Vladimir Sementsov-Ogievskiy
Quoted 7 lines · Vladimir Sementsov-Ogievskiy
---
 include/migration/migration.h | 1 +
 migration/migration.c         | 9 +++++++++
 qapi-schema.json              | 5 ++++-
 3 files changed, 14 insertions(+), 1 deletion(-)
Quoted 2 lines

#
+# @dirty-bitmaps: If enabled, QEMU will migrate named dirty bitmaps. (since 2.3)

Just to make sure, this only affects the source side, and does not have to be set on the destination (that is, the destination will automatically handle incoming dirty bitmaps correctly without having to tweak the knob first)? Of course, libvirt will check that the destination advertises the feature before enabling the knob on the source (to avoid the case of the source sending something the destination won't understand).

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v4 11/13
#15 lore raw

Re: [Qemu-devel] [PATCH RFC v4 11/13] qapi: add md5 checksum of last dirty bitmap level to query-block

In reply to Vladimir Sementsov-Ogievskiy
Quoted 13 lines · Vladimir Sementsov-Ogievskiy
---
 block.c                | 1 +
 include/qemu/hbitmap.h | 8 ++++++++
 qapi/block-core.json   | 4 +++-
 util/hbitmap.c         | 8 ++++++++
 4 files changed, 20 insertions(+), 1 deletion(-)

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

qapi/block-core.json +0 -0
@@ -336,11 +336,13 @@
 #

qapi/block-core.json line 345

Quoted 10 lines
qapi/block-core.json +3 -1
 # @frozen: whether the dirty bitmap is frozen (Since 2.3)
 #
+# @md5: md5 checksum of the last bitmap level (since 2.3)
+#
 # Since: 1.3
 ##
 { 'type': 'BlockDirtyInfo',
   'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
-           'disabled': 'bool', 'frozen': 'bool'} }
+           'disabled': 'bool', 'frozen': 'bool', 'md5': 'str'} }

How long does it take to compute the md5 sum? Is enabling this information unconditionally going to significantly slow down the call, when the information is useful primarily only for debugging?

That said, it looks okay code-wise, so as long as I am not uncovering a design flaw:

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#16 lore raw

Re: [Qemu-devel] [PATCH RFC v4 11/13] qapi: add md5 checksum of last dirty bitmap level to query-block

Quoted 29 lines · Eric Blake
Quoted 13 lines · Vladimir Sementsov-Ogievskiy
---
  block.c                | 1 +
  include/qemu/hbitmap.h | 8 ++++++++
  qapi/block-core.json   | 4 +++-
  util/hbitmap.c         | 8 ++++++++
  4 files changed, 20 insertions(+), 1 deletion(-)

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

qapi/block-core.json +0 -0
@@ -336,11 +336,13 @@
  #

qapi/block-core.json line 345

Quoted 10 lines
qapi/block-core.json +3 -1
  # @frozen: whether the dirty bitmap is frozen (Since 2.3)
  #
+# @md5: md5 checksum of the last bitmap level (since 2.3)
+#
  # Since: 1.3
  ##
  { 'type': 'BlockDirtyInfo',
    'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
-           'disabled': 'bool', 'frozen': 'bool'} }
+           'disabled': 'bool', 'frozen': 'bool', 'md5': 'str'} }

How long does it take to compute the md5 sum? Is enabling this information unconditionally going to significantly slow down the call, when the information is useful primarily only for debugging?

Quoted 4 lines

That said, it looks okay code-wise, so as long as I am not uncovering a design flaw:

A dirty bitmap that contains 1MiB of raw data using the default granularity of 64KiB describes 512GiB of disk space.

Allocating 1MiB, filling each byte with a pattern (255 % offset), computing the MD5 checksum and printing the hash takes, on my computer, .006 seconds.

The same procedure with 8MiB (4TiB) and timing exclusively the hash computation, it's 0.014033 seconds.

The time starts to get appreciable at around 64MiB of data, which would imply 32TiB of disk, which takes about a tenth of a second.

#19 lore raw
In reply to Vladimir Sementsov-Ogievskiy
Quoted 114 lines · Vladimir Sementsov-Ogievskiy

These patches provide dirty bitmap migration feature. Only named dirty bitmaps are to be migrated. Migration may be enabled using migration capabilities.

v4 significant changes:
0001: tiny bugfix: out[i] -> out[i-start], same for 'in' 0007: set chunk size to 1kb, disable live iteration for
migrating data < 1mb size.

tests: only one with md5 sum is here. used function event_wait
by John Snow. (I hope, you don't mind me just adding this function with your 'Signed-off-by')

rfc: This patch set is based on v13 of
"block: incremental backup series" by John Snow, which are not pushed yet.

v3:
based on v13 of "block: incremental backup series" by John Snow.

changes from v2:
removed patch for adding dirty parameter (migration capablities used instead).

0001: printf's dropped, qapi used
0002: part0 -> zeroes
0003: part0 -> zeroes
0005: dirty_dirty -> meta
add comments about meta bitmap

0006: the format is changed, nodes used instead of devices.

other patches are new.

rfc: there are two tests. They are the same but using different
interfaces: md5 checksum of the bitmap last layer in query-block or separate query-block-dirty-bitmap with dirty bitmap regions. The second form is more appropriate for debugging, the first is more appropriate for simple regression control. Which should go to upstream?

v2:
1. bug-fixes, that are already in upstream, and renaming of function bdrv_reset_dirty_bitmap (which is already in Snow's series) are dropped
2. bitmap store/restore: the concept renamed to serialization, added function hbitmap_deserialize_part0, to not transfer zero blocks
3. migration dirty parameter: added description comment
4. Other patches are new.

v2.rfc:
Actually, in this version of the series I'm trying not use migration/block.c at all. Instead a separate migration unit is added in the new file migration/dirty-bitmap.c. Now bitmaps are migrated like blocks in block migration, they have their "dirty-dirty" bitmaps, for tracking set/unset changes during migration.

The advantages are:
- no complications of migration/block.c
- separate dirty-dirty bitmaps provide handling of "unset's"
- more effective meta-data/data ratio - no tiny bitmap-blocks.

v1:
These patches provide dirty bitmap migration feature. Only named dirty bitmaps are to be migrated. Migration is made as a part of block migration in block-migration.c.

Dirty bitmap migration may be enabled by "dirty" parameter for qmp migrate command. If "blk" and "inc" parameters are false when "dirty" is true block migration is actually skipped: no allocatoions, no bdrv_read's, no bdrv_write's, only bitmaps are migrated.

The patch set includes two my previous bug fixes, which are necessary for it. The patch set is based on Incremental backup series by John Snow.

*** BLURB HERE ***

Vladimir Sementsov-Ogievskiy (13):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interface
block: tiny refactoring: minimize hbitmap_(set/reset) usage
block: add meta bitmaps
block: add bdrv_next_dirty_bitmap()
qapi: add dirty-bitmaps migration capability
migration: add migration/block-dirty-bitmap.c
iotests: maintain several vms in test
iotests: add add_incoming_migration to VM class
iotests: add event_wait to VM class
qapi: add md5 checksum of last dirty bitmap level to query-block
iotests: add dirty bitmap migration test migration/qemu-file: make functions qemu_(get/put)_string public

  block.c                        |  98 +++++-
  include/block/block.h          |  22 ++
  include/migration/block.h      |   1 +
  include/migration/migration.h  |   1 +
  include/migration/qemu-file.h  |  17 +
  include/qemu/hbitmap.h         |  67 ++++
  migration/Makefile.objs        |   2 +-
  migration/block-dirty-bitmap.c | 693 +++++++++++++++++++++++++++++++++++++++++
  migration/migration.c          |   9 +
  migration/qemu-file.c          |  18 ++
  qapi-schema.json               |   5 +-
  qapi/block-core.json           |   4 +-
  tests/qemu-iotests/117         |  84 +++++
  tests/qemu-iotests/117.out     |   5 +
  tests/qemu-iotests/group       |   1 +
  tests/qemu-iotests/iotests.py  |  19 +-
  util/hbitmap.c                 | 106 +++++++
  vl.c                           |   1 +
  18 files changed, 1144 insertions(+), 9 deletions(-)
Quoted 4 lines

create mode 100644 migration/block-dirty-bitmap.c create mode 100755 tests/qemu-iotests/117 create mode 100644 tests/qemu-iotests/117.out

I think you forgot to CC me on the series.

Unless -- you're not trying to get rid of me, are you? :>

#8 lore raw

Re: [Qemu-devel] [PATCH RFC v4 06/13] qapi: add dirty-bitmaps migration capability

In reply to Eric Blake
Quoted 13 lines · Eric Blake
Quoted 7 lines · Vladimir Sementsov-Ogievskiy
---
  include/migration/migration.h | 1 +
  migration/migration.c         | 9 +++++++++
  qapi-schema.json              | 5 ++++-
  3 files changed, 14 insertions(+), 1 deletion(-)
Quoted 2 lines

#
+# @dirty-bitmaps: If enabled, QEMU will migrate named dirty bitmaps. (since 2.3)

Quoted 8 lines

Just to make sure, this only affects the source side, and does not have to be set on the destination (that is, the destination will automatically handle incoming dirty bitmaps correctly without having to tweak the knob first)? Of course, libvirt will check that the destination advertises the feature before enabling the knob on the source (to avoid the case of the source sending something the destination won't understand).

Yes, live migration in the destination will call load_state iff such block is found in the migration stream.

Signature · 2 lines
Best regards,
Vladimir
#20 lore raw
In reply to John Snow
Quoted 123 lines · John Snow
Quoted 115 lines · Vladimir Sementsov-Ogievskiy

These patches provide dirty bitmap migration feature. Only named dirty bitmaps are to be migrated. Migration may be enabled using migration capabilities.

v4 significant changes:
0001: tiny bugfix: out[i] -> out[i-start], same for 'in' 0007: set chunk size to 1kb, disable live iteration for
migrating data < 1mb size.

tests: only one with md5 sum is here. used function event_wait
by John Snow. (I hope, you don't mind me just adding this function with your 'Signed-off-by')

rfc: This patch set is based on v13 of
"block: incremental backup series" by John Snow, which are not pushed yet.

v3:
based on v13 of "block: incremental backup series" by John Snow.

changes from v2:
removed patch for adding dirty parameter (migration capablities used instead).

0001: printf's dropped, qapi used
0002: part0 -> zeroes
0003: part0 -> zeroes
0005: dirty_dirty -> meta
add comments about meta bitmap

0006: the format is changed, nodes used instead of devices.

other patches are new.

rfc: there are two tests. They are the same but using different
interfaces: md5 checksum of the bitmap last layer in query-block or separate query-block-dirty-bitmap with dirty bitmap regions. The second form is more appropriate for debugging, the first is more appropriate for simple regression control. Which should go to upstream?

v2:
1. bug-fixes, that are already in upstream, and renaming of function bdrv_reset_dirty_bitmap (which is already in Snow's series) are dropped
2. bitmap store/restore: the concept renamed to serialization, added function hbitmap_deserialize_part0, to not transfer zero blocks
3. migration dirty parameter: added description comment
4. Other patches are new.

v2.rfc:
Actually, in this version of the series I'm trying not use migration/block.c at all. Instead a separate migration unit is added in the new file migration/dirty-bitmap.c. Now bitmaps are migrated like blocks in block migration, they have their "dirty-dirty" bitmaps, for tracking set/unset changes during migration.

The advantages are:
- no complications of migration/block.c
- separate dirty-dirty bitmaps provide handling of "unset's"
- more effective meta-data/data ratio - no tiny bitmap-blocks.

v1:
These patches provide dirty bitmap migration feature. Only named dirty bitmaps are to be migrated. Migration is made as a part of block migration in block-migration.c.

Dirty bitmap migration may be enabled by "dirty" parameter for qmp migrate command. If "blk" and "inc" parameters are false when "dirty" is true block migration is actually skipped: no allocatoions, no bdrv_read's, no bdrv_write's, only bitmaps are migrated.

The patch set includes two my previous bug fixes, which are necessary for it. The patch set is based on Incremental backup series by John Snow.

*** BLURB HERE ***

Vladimir Sementsov-Ogievskiy (13):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interface
block: tiny refactoring: minimize hbitmap_(set/reset) usage
block: add meta bitmaps
block: add bdrv_next_dirty_bitmap()
qapi: add dirty-bitmaps migration capability
migration: add migration/block-dirty-bitmap.c
iotests: maintain several vms in test
iotests: add add_incoming_migration to VM class
iotests: add event_wait to VM class
qapi: add md5 checksum of last dirty bitmap level to query-block
iotests: add dirty bitmap migration test migration/qemu-file: make functions qemu_(get/put)_string public

  block.c                        |  98 +++++-
  include/block/block.h          |  22 ++
  include/migration/block.h      |   1 +
  include/migration/migration.h  |   1 +
  include/migration/qemu-file.h  |  17 +
  include/qemu/hbitmap.h         |  67 ++++
  migration/Makefile.objs        |   2 +-
  migration/block-dirty-bitmap.c | 693 
+++++++++++++++++++++++++++++++++++++++++
  migration/migration.c          |   9 +
  migration/qemu-file.c          |  18 ++
  qapi-schema.json               |   5 +-
  qapi/block-core.json           |   4 +-
  tests/qemu-iotests/117         |  84 +++++
  tests/qemu-iotests/117.out     |   5 +
  tests/qemu-iotests/group       |   1 +
  tests/qemu-iotests/iotests.py  |  19 +-
  util/hbitmap.c                 | 106 +++++++
  vl.c                           |   1 +
  18 files changed, 1144 insertions(+), 9 deletions(-)
Quoted 4 lines

create mode 100644 migration/block-dirty-bitmap.c create mode 100755 tests/qemu-iotests/117 create mode 100644 tests/qemu-iotests/117.out

Quoted 3 lines

I think you forgot to CC me on the series.

Unless -- you're not trying to get rid of me, are you? :>

Ohh, I'm sorry) It's a mistake. Hm, I've forgotten this for v3 too, because I wanted to CC people, added by you. So, I've just copy-pasted the CC list, but you wasn't in it as a sender. And for v4 the same command line was used..

Signature · 2 lines
Best regards,
Vladimir
#13 lore raw

Re: [Qemu-devel] [PATCH RFC v4 10/13] iotests: add event_wait to VM class

In reply to Vladimir Sementsov-Ogievskiy
Quoted 15 lines · Vladimir Sementsov-Ogievskiy
---
 tests/qemu-iotests/iotests.py | 7 +++++++
 1 file changed, 7 insertions(+)
tests/qemu-iotests/iotests.py +0 -0
index 75640b2..294b158 100644
@@ -203,6 +203,13 @@ class VM(object):
         self._qmp.clear_events()
         return events
 

tests/qemu-iotests/iotests.py class VM(object): · line 215

Quoted 10 lines
tests/qemu-iotests/iotests.py +7 -0
+    def event_wait(self, name='BLOCK_JOB_COMPLETED', maxwait=10):
+        for _ in range(maxwait):
+            for event in self.get_qmp_events(wait=True):
+                if event['event'] == name:
+                    return event
+            return None
+
 index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
 
 class QMPTestCase(unittest.TestCase):

For v5, I have already included this upstream and expanded it slightly to include a proper timeout mechanism as well as a new "match" parameter that accepts a dict that can be used as a "filter" to only select events for which 'match' is a recursive subset.

This patch can likely be dropped again.