diff --git a/libvirt/tests/cfg/migration/async_ops/pause_resume_vm_during_migration.cfg b/libvirt/tests/cfg/migration/async_ops/pause_resume_vm_during_migration.cfg new file mode 100644 index 0000000000..50ea21413c --- /dev/null +++ b/libvirt/tests/cfg/migration/async_ops/pause_resume_vm_during_migration.cfg @@ -0,0 +1,45 @@ +- migration.async_ops.pause_resume_vm_during_migration: + type = pause_resume_vm_during_migration + migration_setup = 'yes' + storage_type = 'nfs' + setup_local_nfs = 'yes' + disk_type = "file" + disk_source_protocol = "netfs" + mnt_path_name = ${nfs_mount_dir} + # 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' + virsh_migrate_dest_state = "running" + virsh_migrate_src_state = "shut off" + image_convert = 'no' + server_ip = "${migrate_dest_host}" + server_user = "root" + server_pwd = "${migrate_dest_pwd}" + status_error = "no" + check_network_accessibility_after_mig = "yes" + migrate_desturi_port = "16509" + migrate_desturi_type = "tcp" + virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system" + migrate_speed = "5" + action_during_mig = [{"func": "virsh.suspend", "after_event": "iteration: '1'", "func_param": {"name": "${main_vm}"}}, {"func": "check_resume", "func_param": "params"}] + variants: + - p2p: + virsh_migrate_options = '--live --p2p --verbose' + - non_p2p: + virsh_migrate_options = '--live --verbose' + variants: + - with_precopy: + expected_event_src = ["lifecycle.*: Suspended Migrated"] + resume_err_msg_src = "cannot acquire state change lock .*held by monitor=remoteDispatchDomainMigratePerform3Params" + resume_err_msg_target = "cannot acquire state change lock .*held by monitor=remoteDispatchDomainMigratePrepare3Params" + - with_postcopy: + postcopy_options = '--postcopy --timeout 5 --timeout-postcopy' + expected_event_src = ["lifecycle.*: Suspended Post-copy"] + resume_err_msg_src = "cannot acquire state change lock .*held by monitor=remoteDispatchDomainMigratePerform3Params" + resume_err_msg_target = "cannot acquire state change lock .*held by monitor=remoteDispatchDomainMigrateFinish3Params" diff --git a/libvirt/tests/src/migration/async_ops/pause_resume_vm_during_migration.py b/libvirt/tests/src/migration/async_ops/pause_resume_vm_during_migration.py new file mode 100644 index 0000000000..75311f3e2c --- /dev/null +++ b/libvirt/tests/src/migration/async_ops/pause_resume_vm_during_migration.py @@ -0,0 +1,31 @@ +from provider.migration import base_steps +from provider.migration import migration_base + + +def run(test, params, env): + """ + This case is to verify that during migration, vm: + can be paused by user on src host during PerformPhase of precopy + can't be resumed by user on src/target host during PerformPhase of precopy + can't be paused by user on target host during FinishPhase of postcopy + can't be resumed by user on src host during FinishPhase of postcopy + + :param test: test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + vm_name = params.get("migrate_main_vm") + + virsh_session = None + + vm = env.get_vm(vm_name) + migration_obj = base_steps.MigrationBase(test, vm, params) + + try: + migration_obj.setup_connection() + virsh_session, _ = migration_base.monitor_event(params) + migration_obj.run_migration() + migration_obj.verify_default() + migration_base.check_event_output(params, test, virsh_session) + finally: + migration_obj.cleanup_connection() diff --git a/provider/migration/migration_base.py b/provider/migration/migration_base.py index 2c1b08dd7c..b88762f243 100644 --- a/provider/migration/migration_base.py +++ b/provider/migration/migration_base.py @@ -735,3 +735,21 @@ def get_vm_serial_session_on_dest(params): vm_session = migration_obj.vm.wait_for_serial_login(timeout=120) params.update({"vm_session": vm_session}) migration_obj.vm.connect_uri = backup_uri + + +def check_resume(params): + """ + Check resume result + + :param params: dictionary with the test parameter, get vm name, dest uri + and error message. + """ + vm_name = params.get("main_vm") + desturi = params.get("virsh_migrate_desturi") + resume_err_msg_src = params.get("resume_err_msg_src") + resume_err_msg_target = params.get("resume_err_msg_target") + + ret = virsh.resume(vm_name, debug=True) + libvirt.check_result(ret, expected_fails=resume_err_msg_src, check_both_on_error=True) + ret = virsh.resume(vm_name, debug=True, uri=desturi) + libvirt.check_result(ret, expected_fails=resume_err_msg_target, check_both_on_error=True)