diff --git a/libvirt/tests/src/migration/migrate_options_shared.py b/libvirt/tests/src/migration/migrate_options_shared.py index 4cc5357bee..b5ebdd5294 100644 --- a/libvirt/tests/src/migration/migrate_options_shared.py +++ b/libvirt/tests/src/migration/migrate_options_shared.py @@ -3,7 +3,6 @@ import time import math import re -import threading import platform import tempfile import copy @@ -1324,17 +1323,8 @@ def cancel_bg_migration(): test.error("Failed to install tpm2-tools in vm") if stress_in_vm: - pkg_name = 'stress' - logging.debug("Check if stress tool is installed") - pkg_mgr = utils_package.package_manager(vm_session, pkg_name) - if not pkg_mgr.is_installed(pkg_name): - logging.debug("Stress tool will be installed") - if not pkg_mgr.install(): - test.error("Package '%s' installation fails" % pkg_name) - - stress_thread = threading.Thread(target=run_stress_in_vm, - args=()) - stress_thread.start() + params.update({"stress_package": "stress"}) + migration_test.run_stress_in_vm(vm, params) # Check maxdowntime before migration if check_default_maxdowntime: diff --git a/libvirt/tests/src/virsh_cmd/domain/virsh_migrate_option_mix.py b/libvirt/tests/src/virsh_cmd/domain/virsh_migrate_option_mix.py index f0857f7f36..2faab30e70 100644 --- a/libvirt/tests/src/virsh_cmd/domain/virsh_migrate_option_mix.py +++ b/libvirt/tests/src/virsh_cmd/domain/virsh_migrate_option_mix.py @@ -7,7 +7,6 @@ from virttest import utils_selinux from virttest import virsh -from virttest import utils_package from virttest import migration from virttest.utils_conn import TLSConnection from virttest.utils_test import libvirt @@ -227,26 +226,8 @@ def cleanup_vm(vm, vm_name='', uri=''): # Prepare for postcopy migration: install and run stress in VM if postcopy and src_vm_status == "running": logging.debug("Install and run stress in vm for postcopy migration") - pkg_name = 'stress' - - # Get a vm session - logging.debug("Get a vm session") - vm_session = vm.wait_for_login() - if not vm_session: - test.error("Can't get a vm session successfully") - - # Install package stress if it is not installed in vm - logging.debug("Check if stress tool is installed for postcopy migration") - pkg_mgr = utils_package.package_manager(vm_session, pkg_name) - if not pkg_mgr.is_installed(pkg_name): - logging.debug("Stress tool will be installed") - if not pkg_mgr.install(): - test.error("Package '%s' installation fails" % pkg_name) - - # Run stress in vm - logging.debug("Run stress in vm") - stress_args = params.get("stress_args") - vm_session.cmd('stress %s' % stress_args) + params.update({"stress_package": "stress"}) + obj_migration.run_stress_in_vm(vm, params) # Prepare for --xml . if xml_option: