mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 21:40:49 +00:00
7d8140595f
Like script_main, but doesn't require a single point of entry. Replace all existing initialization sections with this drop-in replacement. This brings debug support to all existing script-style iotests. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200331000014.11581-12-jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> [mreitz: Give 274 the same treatment] Signed-off-by: Max Reitz <mreitz@redhat.com>
92 lines
2.9 KiB
Python
Executable File
92 lines
2.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
#
|
|
# Tests for temporary external snapshot when we have bitmaps.
|
|
#
|
|
# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
|
|
#
|
|
# 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/>.
|
|
#
|
|
|
|
import iotests
|
|
from iotests import qemu_img_create, file_path, log, filter_qmp_event
|
|
|
|
iotests.script_initialize(
|
|
supported_fmts=['qcow2']
|
|
)
|
|
|
|
base, top = file_path('base', 'top')
|
|
size = 64 * 1024 * 3
|
|
|
|
|
|
def print_bitmap(msg, vm):
|
|
result = vm.qmp('query-block')['return'][0]
|
|
if 'dirty-bitmaps' in result:
|
|
bitmap = result['dirty-bitmaps'][0]
|
|
log('{}: name={} dirty-clusters={}'.format(msg, bitmap['name'],
|
|
bitmap['count'] // 64 // 1024))
|
|
else:
|
|
log(msg + ': not found')
|
|
|
|
|
|
def test(persistent, restart):
|
|
assert persistent or not restart
|
|
log("\nTestcase {}persistent {} restart\n".format(
|
|
'' if persistent else 'non-', 'with' if restart else 'without'))
|
|
|
|
qemu_img_create('-f', iotests.imgfmt, base, str(size))
|
|
|
|
vm = iotests.VM().add_drive(base)
|
|
vm.launch()
|
|
|
|
vm.qmp_log('block-dirty-bitmap-add', node='drive0', name='bitmap0',
|
|
persistent=persistent)
|
|
vm.hmp_qemu_io('drive0', 'write 0 64K')
|
|
print_bitmap('initial bitmap', vm)
|
|
|
|
vm.qmp_log('blockdev-snapshot-sync', device='drive0', snapshot_file=top,
|
|
format=iotests.imgfmt, filters=[iotests.filter_qmp_testfiles])
|
|
vm.hmp_qemu_io('drive0', 'write 64K 512')
|
|
print_bitmap('check that no bitmaps are in snapshot', vm)
|
|
|
|
if restart:
|
|
log("... Restart ...")
|
|
vm.shutdown()
|
|
vm = iotests.VM().add_drive(top)
|
|
vm.launch()
|
|
|
|
vm.qmp_log('block-commit', device='drive0', top=top,
|
|
filters=[iotests.filter_qmp_testfiles])
|
|
ev = vm.events_wait((('BLOCK_JOB_READY', None),
|
|
('BLOCK_JOB_COMPLETED', None)))
|
|
log(filter_qmp_event(ev))
|
|
if (ev['event'] == 'BLOCK_JOB_COMPLETED'):
|
|
vm.shutdown()
|
|
log(vm.get_log())
|
|
exit()
|
|
|
|
vm.qmp_log('block-job-complete', device='drive0')
|
|
ev = vm.event_wait('BLOCK_JOB_COMPLETED')
|
|
log(filter_qmp_event(ev))
|
|
print_bitmap('check bitmap after commit', vm)
|
|
|
|
vm.hmp_qemu_io('drive0', 'write 128K 64K')
|
|
print_bitmap('check updated bitmap', vm)
|
|
|
|
vm.shutdown()
|
|
|
|
|
|
test(persistent=False, restart=False)
|
|
test(persistent=True, restart=False)
|
|
test(persistent=True, restart=True)
|