From 7765ff73d366bd85dfa13c6f8862d1e72f8ff3ff Mon Sep 17 00:00:00 2001 From: lcheng Date: Tue, 10 Dec 2024 18:38:23 +0800 Subject: [PATCH] migration: Add non-live migration case XXX-298167 - [VM migration] non-live migration Signed-off-by: lcheng --- .../non_live_migration/non_live_migration.cfg | 40 +++++++++++++++++++ .../non_live_migration/non_live_migration.py | 30 ++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 libvirt/tests/cfg/migration/non_live_migration/non_live_migration.cfg create mode 100644 libvirt/tests/src/migration/non_live_migration/non_live_migration.py diff --git a/libvirt/tests/cfg/migration/non_live_migration/non_live_migration.cfg b/libvirt/tests/cfg/migration/non_live_migration/non_live_migration.cfg new file mode 100644 index 0000000000..f4324c651f --- /dev/null +++ b/libvirt/tests/cfg/migration/non_live_migration/non_live_migration.cfg @@ -0,0 +1,40 @@ +- migration.non_live_migration: + type = non_live_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" + image_convert = 'no' + server_ip = "${migrate_dest_host}" + server_user = "root" + server_pwd = "${migrate_dest_pwd}" + status_error = "no" + start_vm = "yes" + migrate_desturi_port = "16509" + migrate_desturi_type = "tcp" + virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system" + check_network_accessibility_after_mig = "yes" + variants: + - p2p: + virsh_migrate_options = "--p2p --verbose" + - non_p2p: + virsh_migrate_options = "--verbose" + variants: + - with_precopy: + expected_event_src = ["lifecycle.*Suspended Migrated", "migration-iteration.*iteration"] + - with_postcopy: + postcopy_options = "--postcopy" + status_error = "yes" + err_msg = "post-copy migration is not supported with non-live or paused migration" diff --git a/libvirt/tests/src/migration/non_live_migration/non_live_migration.py b/libvirt/tests/src/migration/non_live_migration/non_live_migration.py new file mode 100644 index 0000000000..d650cbb7aa --- /dev/null +++ b/libvirt/tests/src/migration/non_live_migration/non_live_migration.py @@ -0,0 +1,30 @@ +from provider.migration import base_steps +from provider.migration import migration_base + + +def run(test, params, env): + """ + This case is to verify that non-live vm migration can succeed. + "non-live migration" means vm is paused before its memory is migrated. + To start a non-live migration, don't add "--live" in virsh migrate option. + + :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 + remote_virsh_session = None + + vm = env.get_vm(vm_name) + migration_obj = base_steps.MigrationBase(test, vm, params) + + try: + migration_obj.setup_connection() + virsh_session, remote_virsh_session = migration_base.monitor_event(params) + migration_obj.run_migration() + migration_obj.verify_default() + migration_base.check_event_output(params, test, virsh_session, remote_virsh_session) + finally: + migration_obj.cleanup_connection()