+ vm.hmp_qemu_io('drive0', 'discard {} {}'.format(*d))
+
+
def event_seconds(event):
return event['timestamp']['seconds'] + \
event['timestamp']['microseconds'] / 1000000.0
@@ -80,9 +102,7 @@ class
TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
self.vm_b_events = []
def test_postcopy(self):
- discard_size = 0x40000000
granularity = 512
- chunk = 4096
result = self.vm_a.qmp('block-dirty-bitmap-add', node='drive0',
name='bitmap', granularity=granularity)
@@ -92,14 +112,7 @@ class
TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
node='drive0', name='bitmap')
empty_sha256 = result['return']['sha256']
- s = 0
- while s < discard_size:
- self.vm_a.hmp_qemu_io('drive0', 'discard %d %d' % (s,
chunk))
- s += 0x10000
- s = 0x8000
- while s < discard_size:
- self.vm_a.hmp_qemu_io('drive0', 'discard %d %d' % (s,
chunk))
- s += 0x10000
+ apply_discards(self.vm_a, discards1 + discards2)
result = self.vm_a.qmp('x-debug-block-dirty-bitmap-sha256',
node='drive0', name='bitmap')
@@ -111,10 +124,8 @@ class
TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
result = self.vm_a.qmp('block-dirty-bitmap-clear',
node='drive0',
name='bitmap')
self.assert_qmp(result, 'return', {})
- s = 0
- while s < discard_size:
- self.vm_a.hmp_qemu_io('drive0', 'discard %d %d' % (s,
chunk))
- s += 0x10000
+
+ apply_discards(self.vm_a, discards1)
caps = [{'capability': 'dirty-bitmaps', 'state': True},
{'capability': 'events', 'state': True}]
@@ -134,10 +145,7 @@ class
TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
e_resume = self.vm_b.event_wait('RESUME')
self.vm_b_events.append(e_resume)
- s = 0x8000
- while s < discard_size:
- self.vm_b.hmp_qemu_io('drive0', 'discard %d %d' % (s,
chunk))
- s += 0x10000
+ apply_discards(self.vm_b, discards2)
match = {'data': {'status': 'completed'}}
e_complete = self.vm_b.event_wait('MIGRATION', match=match)