From 1bcec7b0c8454072c9a281744af0cf7d13b074f6 Mon Sep 17 00:00:00 2001 From: lcheng Date: Tue, 21 Nov 2023 12:10:40 +0800 Subject: [PATCH] migration: Add case about heavy disk I/O load in vm XXX-298242 - VM live migration with copy storage - migrate vm with heavy disk I/O load in vm Signed-off-by: lcheng --- .../disk_io_load_in_vm.cfg | 40 ++++++++++ .../disk_io_load_in_vm.py | 80 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 libvirt/tests/cfg/migration_with_copy_storage/disk_io_load_in_vm.cfg create mode 100644 libvirt/tests/src/migration_with_copy_storage/disk_io_load_in_vm.py diff --git a/libvirt/tests/cfg/migration_with_copy_storage/disk_io_load_in_vm.cfg b/libvirt/tests/cfg/migration_with_copy_storage/disk_io_load_in_vm.cfg new file mode 100644 index 0000000000..73203b1a90 --- /dev/null +++ b/libvirt/tests/cfg/migration_with_copy_storage/disk_io_load_in_vm.cfg @@ -0,0 +1,40 @@ +- migration_with_copy_storage.disk_io_load_in_vm: + type = disk_io_load_in_vm + migration_setup = 'yes' + # Console output can only be monitored via virsh console output + only_pty = True + take_regular_screendumps = no + # Extra options to pass after + virsh_migrate_extra = "" + # SSH connection time out + ssh_timeout = 60 + # Local URI + virsh_migrate_connect_uri = "qemu:///system" + image_convert = "no" + migrate_desturi_port = "16509" + migrate_desturi_type = "tcp" + virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system" + start_vm = "yes" + setup_nfs = "no" + nfs_mount_dir = + server_ip = "${migrate_dest_host}" + server_user = "root" + server_pwd = "${migrate_dest_pwd}" + client_ip = "${migrate_source_host}" + client_user = "root" + client_pwd = "${migrate_source_pwd}" + status_error = "no" + variants: + - p2p: + virsh_migrate_options = "--live --p2p --verbose" + - non_p2p: + virsh_migrate_options = "--live --verbose" + variants: + - with_sync_writes: + virsh_migrate_extra = "--copy-storage-synchronous-writes" + - without_sync_writes: + variants: + - copy_storage_all: + copy_storage_option = "--copy-storage-all" + - copy_storage_inc: + copy_storage_option = "--copy-storage-inc" diff --git a/libvirt/tests/src/migration_with_copy_storage/disk_io_load_in_vm.py b/libvirt/tests/src/migration_with_copy_storage/disk_io_load_in_vm.py new file mode 100644 index 0000000000..509e53e863 --- /dev/null +++ b/libvirt/tests/src/migration_with_copy_storage/disk_io_load_in_vm.py @@ -0,0 +1,80 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright Redhat +# +# SPDX-License-Identifier: GPL-2.0 +# +# Author: Liping Cheng +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +from virttest import remote +from virttest import utils_package + +from provider.migration import base_steps + + +def run(test, params, env): + """ + To verify that vm migration can succeed when there is heavy disk I/O load + in vm. + + :param test: test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + def setup_test(): + """ + Setup steps + + """ + test.log.info("Setup steps.") + migration_obj.setup_connection() + session = vm.wait_for_login() + utils_package.package_install(["gcc", "fio"], session, 360) + shell_file = "/tmp/fio_test.sh" + fio_cmd = ['while true', + 'do', + ' fio -name=aaa -direct=1 -iodepth=32 -rw=randrw -ioengine=libaio -bs=16k -size=1G -numjobs=2 -group_reporting -directory=/ &>/dev/null', + 'done'] + remote_file = remote.RemoteFile(vm.get_address(), 'scp', 'root', + params.get('password'), 22, + shell_file) + remote_file.truncate() + remote_file.add(fio_cmd) + session.cmd('chmod 777 %s' % shell_file) + session.cmd('%s &' % shell_file) + session.close() + + def verify_test(): + """ + Verify steps + + """ + dest_uri = params.get("virsh_migrate_desturi") + + test.log.info("Verify steps.") + backup_uri, vm.connect_uri = vm.connect_uri, dest_uri + vm.cleanup_serial_console() + vm.create_serial_console() + remote_vm_session = vm.wait_for_serial_login(timeout=360) + remote_vm_dmesg = remote_vm_session.cmd_output("dmesg") + if "I/O error" in remote_vm_dmesg: + test.fail(f"Found I/O error in guest dmesg: {remote_vm_dmesg}") + remote_vm_session.close() + vm.connect_uri = backup_uri + + migration_obj.verify_default() + + vm_name = params.get("migrate_main_vm") + vm = env.get_vm(vm_name) + migration_obj = base_steps.MigrationBase(test, vm, params) + + try: + setup_test() + base_steps.prepare_disks_remote(params, vm) + migration_obj.run_migration() + verify_test() + finally: + migration_obj.cleanup_connection() + base_steps.cleanup_disks_remote(params, vm)