MAINTAINERS: Cover docs/igd-assign.txt in VFIO section
[qemu/ar7.git] / tests / qemu-iotests / 260
bloba35cb7b61f183dbd8ca30503b3801541cfb39f31
1 #!/usr/bin/env python3
2 # group: rw quick
4 # Tests for temporary external snapshot when we have bitmaps.
6 # Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 import iotests
23 from iotests import qemu_img_create, file_path, log, filter_qmp_event
25 iotests.script_initialize(
26     supported_fmts=['qcow2']
29 base, top = file_path('base', 'top')
30 size = 64 * 1024 * 3
33 def print_bitmap(msg, vm):
34     result = vm.qmp('query-block')['return'][0]
35     if 'dirty-bitmaps' in result:
36         bitmap = result['dirty-bitmaps'][0]
37         log('{}: name={} dirty-clusters={}'.format(msg, bitmap['name'],
38             bitmap['count'] // 64 // 1024))
39     else:
40         log(msg + ': not found')
43 def test(persistent, restart):
44     assert persistent or not restart
45     log("\nTestcase {}persistent {} restart\n".format(
46             '' if persistent else 'non-', 'with' if restart else 'without'))
48     qemu_img_create('-f', iotests.imgfmt, base, str(size))
50     vm = iotests.VM().add_drive(base)
51     vm.launch()
53     vm.qmp_log('block-dirty-bitmap-add', node='drive0', name='bitmap0',
54                persistent=persistent)
55     vm.hmp_qemu_io('drive0', 'write 0 64K')
56     print_bitmap('initial bitmap', vm)
58     vm.qmp_log('blockdev-snapshot-sync', device='drive0', snapshot_file=top,
59                format=iotests.imgfmt, filters=[iotests.filter_qmp_testfiles])
60     vm.hmp_qemu_io('drive0', 'write 64K 512')
61     print_bitmap('check that no bitmaps are in snapshot', vm)
63     if restart:
64         log("... Restart ...")
65         vm.shutdown()
66         vm = iotests.VM().add_drive(top)
67         vm.launch()
69     vm.qmp_log('block-commit', device='drive0', top=top,
70                filters=[iotests.filter_qmp_testfiles])
71     ev = vm.events_wait((('BLOCK_JOB_READY', None),
72                          ('BLOCK_JOB_COMPLETED', None)))
73     log(filter_qmp_event(ev))
74     if (ev['event'] == 'BLOCK_JOB_COMPLETED'):
75         vm.shutdown()
76         log(vm.get_log())
77         exit()
79     vm.qmp_log('block-job-complete', device='drive0')
80     ev = vm.event_wait('BLOCK_JOB_COMPLETED')
81     log(filter_qmp_event(ev))
82     print_bitmap('check bitmap after commit', vm)
84     vm.hmp_qemu_io('drive0', 'write 128K 64K')
85     print_bitmap('check updated bitmap', vm)
87     vm.shutdown()
90 test(persistent=False, restart=False)
91 test(persistent=True, restart=False)
92 test(persistent=True, restart=True)