hw: usb: hcd-ohci: check for processed TD before retire
[qemu/ar7.git] / tests / qemu-iotests / 303
blob6c2177448348bb18b36811f3e6332a8e53eceea8
1 #!/usr/bin/env python3
3 # Test for dumping of qcow2 image metadata
5 # Copyright (c) 2020 Virtuozzo International GmbH
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 import iotests
22 import subprocess
23 from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io
25 iotests.script_initialize(supported_fmts=['qcow2'])
27 disk = file_path('disk')
28 chunk = 1024 * 1024
31 def create_bitmap(bitmap_number, disabled):
32     granularity = 1 << (14 + bitmap_number)
33     bitmap_name = 'bitmap-' + str(bitmap_number)
34     args = ['bitmap', '--add', '-g', f'{granularity}', '-f', iotests.imgfmt,
35             disk, bitmap_name]
36     if disabled:
37         args.append('--disable')
39     iotests.qemu_img_pipe(*args)
42 def write_to_disk(offset, size):
43     write = f'write {offset} {size}'
44     log(qemu_io('-c', write, disk), filters=[filter_qemu_io])
47 def add_bitmap(num, begin, end, disabled):
48     log(f'Add bitmap {num}')
49     create_bitmap(num, disabled)
50     for i in range(begin, end):
51         write_to_disk((i) * chunk, chunk)
52     log('')
55 qemu_img_create('-f', iotests.imgfmt, disk, '10M')
57 add_bitmap(1, 0, 6, False)
58 add_bitmap(2, 6, 8, True)
59 dump = ['qcow2.py', disk, 'dump-header']
60 subprocess.run(dump)
61 # Dump the metadata in JSON format
62 dump.append('-j')
63 subprocess.run(dump)