3 # Tests dirty-bitmap backup with unaligned bitmap granularity
5 # Copyright (c) 2020 Proxmox Server Solutions
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/>.
20 # owner=s.reiter@proxmox.com
23 from iotests import qemu_img_create, qemu_img_log, file_path
25 iotests.script_initialize(supported_fmts=['qcow2'],
26 supported_protocols=['file'])
28 test_img = file_path('test.qcow2')
29 target_img = file_path('target.qcow2')
31 # unaligned by one byte
33 bitmap_granularity = 4096
35 qemu_img_create('-f', iotests.imgfmt, test_img, str(image_len))
38 vm = iotests.VM().add_drive(test_img)
41 # write to the entire image
42 vm.hmp_qemu_io('drive0', 'write -P0x16 0 4096');
43 vm.hmp_qemu_io('drive0', 'write -P0x17 4096 1');
45 # do backup and wait for completion
46 vm.qmp('drive-backup', **{
52 event = vm.event_wait(name='BLOCK_JOB_COMPLETED',
53 match={'data': {'device': 'drive0'}},
56 # shutdown to sync images
59 # backup succeeded, check if image is correct
60 qemu_img_log('compare', test_img, target_img)