Skip to content

Commit 0d4f9d7

Browse files
committed
Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-11-26' into staging
Block patches for 4.2.0-rc3: - Fix for shared storage migration with persistent dirty bitmaps # gpg: Signature made Tue 26 Nov 2019 13:27:32 GMT # gpg: using RSA key 91BEB60A30DB3E8857D11829F407DB0061D5CF40 # gpg: issuer "[email protected]" # gpg: Good signature from "Max Reitz <[email protected]>" [full] # Primary key fingerprint: 91BE B60A 30DB 3E88 57D1 1829 F407 DB00 61D5 CF40 * remotes/maxreitz/tags/pull-block-2019-11-26: iotests: add new test cases to bitmap migration block/qcow2-bitmap: fix bitmap migration Signed-off-by: Peter Maydell <[email protected]>
2 parents a0aaca7 + d8130f4 commit 0d4f9d7

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

block/qcow2-bitmap.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,26 @@ bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp)
988988
}
989989

990990
QSIMPLEQ_FOREACH(bm, bm_list, entry) {
991-
BdrvDirtyBitmap *bitmap = load_bitmap(bs, bm, errp);
991+
BdrvDirtyBitmap *bitmap;
992+
993+
if ((bm->flags & BME_FLAG_IN_USE) &&
994+
bdrv_find_dirty_bitmap(bs, bm->name))
995+
{
996+
/*
997+
* We already have corresponding BdrvDirtyBitmap, and bitmap in the
998+
* image is marked IN_USE. Firstly, this state is valid, no reason
999+
* to consider existing BdrvDirtyBitmap to be bad. Secondly it's
1000+
* absolutely possible, when we do migration with shared storage
1001+
* with dirty-bitmaps capability enabled: if the bitmap was loaded
1002+
* from this storage before migration start, the storage will
1003+
* of-course contain IN_USE outdated version of the bitmap, and we
1004+
* should not load it on migration target, as we already have this
1005+
* bitmap, being migrated.
1006+
*/
1007+
continue;
1008+
}
1009+
1010+
bitmap = load_bitmap(bs, bm, errp);
9921011
if (bitmap == NULL) {
9931012
goto fail;
9941013
}

tests/qemu-iotests/169

+15-7
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,21 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
134134
self.check_bitmap(self.vm_a, sha256 if persistent else False)
135135

136136
def do_test_migration(self, persistent, migrate_bitmaps, online,
137-
shared_storage):
137+
shared_storage, pre_shutdown):
138138
granularity = 512
139139

140140
# regions = ((start, count), ...)
141141
regions = ((0, 0x10000),
142142
(0xf0000, 0x10000),
143143
(0xa0201, 0x1000))
144144

145-
should_migrate = migrate_bitmaps or persistent and shared_storage
145+
should_migrate = \
146+
(migrate_bitmaps and (persistent or not pre_shutdown)) or \
147+
(persistent and shared_storage)
146148
mig_caps = [{'capability': 'events', 'state': True}]
147149
if migrate_bitmaps:
148150
mig_caps.append({'capability': 'dirty-bitmaps', 'state': True})
149151

150-
result = self.vm_a.qmp('migrate-set-capabilities',
151-
capabilities=mig_caps)
152-
self.assert_qmp(result, 'return', {})
153-
154152
self.vm_b.add_incoming(incoming_cmd if online else "defer")
155153
self.vm_b.add_drive(disk_a if shared_storage else disk_b)
156154

@@ -166,6 +164,14 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
166164
self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % r)
167165
sha256 = self.get_bitmap_hash(self.vm_a)
168166

167+
if pre_shutdown:
168+
self.vm_a.shutdown()
169+
self.vm_a.launch()
170+
171+
result = self.vm_a.qmp('migrate-set-capabilities',
172+
capabilities=mig_caps)
173+
self.assert_qmp(result, 'return', {})
174+
169175
result = self.vm_a.qmp('migrate', uri=mig_cmd)
170176
while True:
171177
event = self.vm_a.event_wait('MIGRATION')
@@ -210,11 +216,13 @@ def inject_test_case(klass, name, method, *args, **kwargs):
210216
mc = operator.methodcaller(method, *args, **kwargs)
211217
setattr(klass, 'test_' + method + name, lambda self: mc(self))
212218

213-
for cmb in list(itertools.product((True, False), repeat=4)):
219+
for cmb in list(itertools.product((True, False), repeat=5)):
214220
name = ('_' if cmb[0] else '_not_') + 'persistent_'
215221
name += ('_' if cmb[1] else '_not_') + 'migbitmap_'
216222
name += '_online' if cmb[2] else '_offline'
217223
name += '_shared' if cmb[3] else '_nonshared'
224+
if (cmb[4]):
225+
name += '__pre_shutdown'
218226

219227
inject_test_case(TestDirtyBitmapMigration, name, 'do_test_migration',
220228
*list(cmb))

tests/qemu-iotests/169.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
....................
1+
....................................
22
----------------------------------------------------------------------
3-
Ran 20 tests
3+
Ran 36 tests
44

55
OK

0 commit comments

Comments
 (0)