Block patches for 4.2.0-rc3:

- Fix for shared storage migration with persistent dirty bitmaps
 -----BEGIN PGP SIGNATURE-----
 
 iQFGBAABCAAwFiEEkb62CjDbPohX0Rgp9AfbAGHVz0AFAl3dKEQSHG1yZWl0ekBy
 ZWRoYXQuY29tAAoJEPQH2wBh1c9A9i0H/jtePaUsYXnkcZ09PqCLFtGp1euIOU6S
 hM3BP38EQoO6na7+rmq3OGHxyxkfCg3rO1Vp9zp57TzB46D7GzNzHU1E9LByJtQk
 vkflspgK8OuJk78r6Tm9AJx0dXvyrTUC+BsyySjJPZ80B7zZGrNAUxezvzaAVotJ
 dwKRNOFOn+nyEjEWfPJhdx7C9P+8vXhL3jL+CKwQkHpBmZ9Vx4hMHtoZEfc5+Lhv
 30aOGBrY2kwkhTjQ10UNg2ErlIP79gYbYsw4asSWEKqKeYBRtd3AtTN1ybZaJJf1
 rBNzIh+XEmyqtUqLn4W87uKKldLul30VOcNVCjoWZ6YOF4aJt5mikEo=
 =fTgW
 -----END PGP SIGNATURE-----

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 "mreitz@redhat.com"
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>" [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 <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-11-26 17:29:29 +00:00
commit 0d4f9d7dc7
3 changed files with 37 additions and 10 deletions

View File

@ -988,7 +988,26 @@ bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp)
}
QSIMPLEQ_FOREACH(bm, bm_list, entry) {
BdrvDirtyBitmap *bitmap = load_bitmap(bs, bm, errp);
BdrvDirtyBitmap *bitmap;
if ((bm->flags & BME_FLAG_IN_USE) &&
bdrv_find_dirty_bitmap(bs, bm->name))
{
/*
* We already have corresponding BdrvDirtyBitmap, and bitmap in the
* image is marked IN_USE. Firstly, this state is valid, no reason
* to consider existing BdrvDirtyBitmap to be bad. Secondly it's
* absolutely possible, when we do migration with shared storage
* with dirty-bitmaps capability enabled: if the bitmap was loaded
* from this storage before migration start, the storage will
* of-course contain IN_USE outdated version of the bitmap, and we
* should not load it on migration target, as we already have this
* bitmap, being migrated.
*/
continue;
}
bitmap = load_bitmap(bs, bm, errp);
if (bitmap == NULL) {
goto fail;
}

View File

@ -134,7 +134,7 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
self.check_bitmap(self.vm_a, sha256 if persistent else False)
def do_test_migration(self, persistent, migrate_bitmaps, online,
shared_storage):
shared_storage, pre_shutdown):
granularity = 512
# regions = ((start, count), ...)
@ -142,15 +142,13 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
(0xf0000, 0x10000),
(0xa0201, 0x1000))
should_migrate = migrate_bitmaps or persistent and shared_storage
should_migrate = \
(migrate_bitmaps and (persistent or not pre_shutdown)) or \
(persistent and shared_storage)
mig_caps = [{'capability': 'events', 'state': True}]
if migrate_bitmaps:
mig_caps.append({'capability': 'dirty-bitmaps', 'state': True})
result = self.vm_a.qmp('migrate-set-capabilities',
capabilities=mig_caps)
self.assert_qmp(result, 'return', {})
self.vm_b.add_incoming(incoming_cmd if online else "defer")
self.vm_b.add_drive(disk_a if shared_storage else disk_b)
@ -166,6 +164,14 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % r)
sha256 = self.get_bitmap_hash(self.vm_a)
if pre_shutdown:
self.vm_a.shutdown()
self.vm_a.launch()
result = self.vm_a.qmp('migrate-set-capabilities',
capabilities=mig_caps)
self.assert_qmp(result, 'return', {})
result = self.vm_a.qmp('migrate', uri=mig_cmd)
while True:
event = self.vm_a.event_wait('MIGRATION')
@ -210,11 +216,13 @@ def inject_test_case(klass, name, method, *args, **kwargs):
mc = operator.methodcaller(method, *args, **kwargs)
setattr(klass, 'test_' + method + name, lambda self: mc(self))
for cmb in list(itertools.product((True, False), repeat=4)):
for cmb in list(itertools.product((True, False), repeat=5)):
name = ('_' if cmb[0] else '_not_') + 'persistent_'
name += ('_' if cmb[1] else '_not_') + 'migbitmap_'
name += '_online' if cmb[2] else '_offline'
name += '_shared' if cmb[3] else '_nonshared'
if (cmb[4]):
name += '__pre_shutdown'
inject_test_case(TestDirtyBitmapMigration, name, 'do_test_migration',
*list(cmb))

View File

@ -1,5 +1,5 @@
....................
....................................
----------------------------------------------------------------------
Ran 20 tests
Ran 36 tests
OK