From 4f5643b5c0a680fab482502b56ab0ddf207e74e7 Mon Sep 17 00:00:00 2001 From: lcheng Date: Mon, 30 Oct 2023 15:57:31 +0800 Subject: [PATCH] migration: Add listen address case VIRT-297874 - VM live migration with copy storage - network data transport - TCP - --listen-address Signed-off-by: lcheng --- .../tcp_listen_address.cfg | 60 +++++++++++++++++++ .../network_data_transport/tcp.py | 34 +++++++++++ provider/migration/migration_base.py | 11 ++++ 3 files changed, 105 insertions(+) create mode 100644 libvirt/tests/cfg/migration_with_copy_storage/network_data_transport/tcp_listen_address.cfg create mode 100644 libvirt/tests/src/migration_with_copy_storage/network_data_transport/tcp.py diff --git a/libvirt/tests/cfg/migration_with_copy_storage/network_data_transport/tcp_listen_address.cfg b/libvirt/tests/cfg/migration_with_copy_storage/network_data_transport/tcp_listen_address.cfg new file mode 100644 index 00000000000..d8a19b57e07 --- /dev/null +++ b/libvirt/tests/cfg/migration_with_copy_storage/network_data_transport/tcp_listen_address.cfg @@ -0,0 +1,60 @@ +- migration_with_copy_storage.network_data_transport.tcp_listen_address: + type = tcp + 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' + 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}" + client_ip = "${migrate_source_host}" + client_user = "root" + client_pwd = "${migrate_source_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" + action_during_mig = '[{"func": "check_listen_address", "func_param": "params", "need_sleep_time": "5"}]' + setup_nfs = "no" + nfs_mount_dir = + + variants: + - p2p: + virsh_migrate_options = '--live --p2p --verbose' + - non_p2p: + virsh_migrate_options = '--live --verbose' + variants: + - target_ipv4_address: + listen_address = "${migrate_dest_host}" + virsh_migrate_extra = "--listen-address ${migrate_dest_host}" + - target_ipv6_address: + ipv6_config = "yes" + ipv6_addr_des = "ENTER.YOUR.IPv6.TRAGET" + listen_address = "${ipv6_addr_des}" + virsh_migrate_extra = "--migrateuri tcp://[${ipv6_addr_des}] --listen-address ${ipv6_addr_des}" + - all_ipv4: + listen_address = "0.0.0.0" + virsh_migrate_extra = "--listen-address ${listen_address}" + - all_ipv6: + listen_address = "*" + virsh_migrate_extra = "--listen-address ::" + - invalid_address: + status_error = "yes" + err_msg = "nbd-server-start.*Cannot assign requested address" + listen_address = "10.10.10.10" + virsh_migrate_extra = "--listen-address ${listen_address}" + 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/network_data_transport/tcp.py b/libvirt/tests/src/migration_with_copy_storage/network_data_transport/tcp.py new file mode 100644 index 00000000000..41dfaf7fb03 --- /dev/null +++ b/libvirt/tests/src/migration_with_copy_storage/network_data_transport/tcp.py @@ -0,0 +1,34 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright Redhat +# +# SPDX-License-Identifier: GPL-2.0 + +# Author: Liping Cheng +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +from provider.migration import base_steps + + +def run(test, params, env): + """ + Test VM live migration with copy storage - network data transport - TCP. + + :param test: test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + vm_name = params.get("migrate_main_vm") + + vm = env.get_vm(vm_name) + migration_obj = base_steps.MigrationBase(test, vm, params) + + try: + migration_obj.setup_connection() + base_steps.prepare_disks_remote(params, vm) + migration_obj.run_migration() + migration_obj.verify_default() + finally: + migration_obj.cleanup_connection() + base_steps.cleanup_disks_remote(params, vm) diff --git a/provider/migration/migration_base.py b/provider/migration/migration_base.py index 8e3c473edba..9ef6d0358f7 100644 --- a/provider/migration/migration_base.py +++ b/provider/migration/migration_base.py @@ -726,3 +726,14 @@ 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_listen_address(params): + """ + Check listen address + + :param params: dictionary with the test parameter, get listen address + """ + listen_address = params.get("listen_address") + + process.run(f"ss -tnap|grep qemu-kvm| grep '{listen_address}'", shell=True, ignore_status=False)