mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
iotests: add test for unaligned granularity bitmap backup
Start a VM with a 4097 byte image attached, add a 4096 byte granularity dirty bitmap, mark it dirty, and then do a backup. This used to run into an assert and fail, check that it works as expected and also check the created image to ensure that misaligned backups in general work correctly. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com> Message-Id: <20200810095523.15071-2-s.reiter@proxmox.com> [mreitz: Drop bitmap, and do not write past the image's end] Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
7661a886a1
commit
1f3765b652
60
tests/qemu-iotests/304
Executable file
60
tests/qemu-iotests/304
Executable file
|
@ -0,0 +1,60 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Tests dirty-bitmap backup with unaligned bitmap granularity
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Proxmox Server Solutions
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# owner=s.reiter@proxmox.com
|
||||||
|
|
||||||
|
import iotests
|
||||||
|
from iotests import qemu_img_create, qemu_img_log, file_path
|
||||||
|
|
||||||
|
iotests.script_initialize(supported_fmts=['qcow2'],
|
||||||
|
supported_protocols=['file'])
|
||||||
|
|
||||||
|
test_img = file_path('test.qcow2')
|
||||||
|
target_img = file_path('target.qcow2')
|
||||||
|
|
||||||
|
# unaligned by one byte
|
||||||
|
image_len = 4097
|
||||||
|
bitmap_granularity = 4096
|
||||||
|
|
||||||
|
qemu_img_create('-f', iotests.imgfmt, test_img, str(image_len))
|
||||||
|
|
||||||
|
# create VM
|
||||||
|
vm = iotests.VM().add_drive(test_img)
|
||||||
|
vm.launch()
|
||||||
|
|
||||||
|
# write to the entire image
|
||||||
|
vm.hmp_qemu_io('drive0', 'write -P0x16 0 4096');
|
||||||
|
vm.hmp_qemu_io('drive0', 'write -P0x17 4096 1');
|
||||||
|
|
||||||
|
# do backup and wait for completion
|
||||||
|
vm.qmp('drive-backup', **{
|
||||||
|
'device': 'drive0',
|
||||||
|
'sync': 'full',
|
||||||
|
'target': target_img
|
||||||
|
})
|
||||||
|
|
||||||
|
event = vm.event_wait(name='BLOCK_JOB_COMPLETED',
|
||||||
|
match={'data': {'device': 'drive0'}},
|
||||||
|
timeout=5.0)
|
||||||
|
|
||||||
|
# shutdown to sync images
|
||||||
|
vm.shutdown()
|
||||||
|
|
||||||
|
# backup succeeded, check if image is correct
|
||||||
|
qemu_img_log('compare', test_img, target_img)
|
2
tests/qemu-iotests/304.out
Normal file
2
tests/qemu-iotests/304.out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Images are identical.
|
||||||
|
|
|
@ -309,3 +309,4 @@
|
||||||
299 auto quick
|
299 auto quick
|
||||||
301 backing quick
|
301 backing quick
|
||||||
302 quick
|
302 quick
|
||||||
|
304 rw quick
|
||||||
|
|
Loading…
Reference in a new issue