4 # Tests dirty-bitmap backup with unaligned bitmap granularity
6 # Copyright (c) 2020 Proxmox Server Solutions
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/>.
21 # owner=s.reiter@proxmox.com
24 from iotests import qemu_img_create, qemu_img_log, file_path
26 iotests.script_initialize(supported_fmts=['qcow2'],
27 supported_protocols=['file'])
29 test_img = file_path('test.qcow2')
30 target_img = file_path('target.qcow2')
32 # unaligned by one byte
34 bitmap_granularity = 4096
36 qemu_img_create('-f', iotests.imgfmt, test_img, str(image_len))
39 vm = iotests.VM().add_drive(test_img)
42 # write to the entire image
43 vm.hmp_qemu_io('drive0', 'write -P0x16 0 4096');
44 vm.hmp_qemu_io('drive0', 'write -P0x17 4096 1');
46 # do backup and wait for completion
47 vm.qmp('drive-backup', **{
53 event = vm.event_wait(name='BLOCK_JOB_COMPLETED',
54 match={'data': {'device': 'drive0'}},
57 # shutdown to sync images
60 # backup succeeded, check if image is correct
61 qemu_img_log('compare', test_img, target_img)