hw/intc/i8259: Refactor pic_read_irq() to avoid uninitialized variable
[qemu/ar7.git] / tests / qemu-iotests / tests / parallels-read-bitmap
blobaf6b9c5db3ed8ff3d6ab2da440a2526ee811ada2
1 #!/usr/bin/env python3
3 # Test parallels load bitmap
5 # Copyright (c) 2021 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 json
22 import iotests
23 from iotests import qemu_nbd_popen, qemu_img_pipe, log, file_path
25 iotests.script_initialize(supported_fmts=['parallels'])
27 nbd_sock = file_path('nbd-sock', base_dir=iotests.sock_dir)
28 disk = iotests.file_path('disk')
29 bitmap = 'e4f2eed0-37fe-4539-b50b-85d2e7fd235f'
30 nbd_opts = f'driver=nbd,server.type=unix,server.path={nbd_sock}' \
31         f',x-dirty-bitmap=qemu:dirty-bitmap:{bitmap}'
34 iotests.unarchive_sample_image('parallels-with-bitmap', disk)
37 with qemu_nbd_popen('--read-only', f'--socket={nbd_sock}',
38                     f'--bitmap={bitmap}', '-f', iotests.imgfmt, disk):
39     out = qemu_img_pipe('map', '--output=json', '--image-opts', nbd_opts)
40     chunks = json.loads(out)
41     cluster = 64 * 1024
43     log('dirty clusters (cluster size is 64K):')
44     for c in chunks:
45         assert c['start'] % cluster == 0
46         assert c['length'] % cluster == 0
47         if c['data']:
48             continue
50         a = c['start'] // cluster
51         b = (c['start'] + c['length']) // cluster
52         if b - a > 1:
53             log(f'{a}-{b-1}')
54         else:
55             log(a)