Merge remote-tracking branch 'remotes/nvme/tags/nvme-fixes-20210407-pull-request...
[qemu/ar7.git] / tests / qemu-iotests / 304
blob198f2820871e26fb7e7d39f2f716c7abb30aa3cf
1 #!/usr/bin/env python3
2 # group: rw quick
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
23 import iotests
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
33 image_len = 4097
34 bitmap_granularity = 4096
36 qemu_img_create('-f', iotests.imgfmt, test_img, str(image_len))
38 # create VM
39 vm = iotests.VM().add_drive(test_img)
40 vm.launch()
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', **{
48     'device': 'drive0',
49     'sync': 'full',
50     'target': target_img
53 event = vm.event_wait(name='BLOCK_JOB_COMPLETED',
54                       match={'data': {'device': 'drive0'}},
55                       timeout=5.0)
57 # shutdown to sync images
58 vm.shutdown()
60 # backup succeeded, check if image is correct
61 qemu_img_log('compare', test_img, target_img)