From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucas Meneghel Rodrigues Subject: [PATCH 4/7] KVM test: Adapt the test code to use the new virt namespace Date: Wed, 9 Mar 2011 06:21:07 -0300 Message-ID: <1299662470-3017-5-git-send-email-lmr@redhat.com> References: <1299662470-3017-1-git-send-email-lmr@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: autotest@test.kernel.org Return-path: In-Reply-To: <1299662470-3017-1-git-send-email-lmr@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/control | 18 ++++----- client/tests/kvm/control.parallel | 8 ++-- client/tests/kvm/control.unittests | 14 +++---- client/tests/kvm/get_started.py | 5 ++- client/tests/kvm/kvm.py | 14 ++++---- client/tests/kvm/migration_control.srv | 12 +++--- client/tests/kvm/tests/autotest.py | 6 ++-- client/tests/kvm/tests/balloon_check.py | 2 +- client/tests/kvm/tests/boot_savevm.py | 2 +- client/tests/kvm/tests/build.py | 6 ++-- client/tests/kvm/tests/enospc.py | 2 +- client/tests/kvm/tests/ethtool.py | 12 +++--- client/tests/kvm/tests/file_transfer.py | 7 ++-- client/tests/kvm/tests/guest_s4.py | 4 +- client/tests/kvm/tests/guest_test.py | 4 +- client/tests/kvm/tests/image_copy.py | 4 +- client/tests/kvm/tests/iofuzz.py | 8 ++-- client/tests/kvm/tests/jumbo.py | 24 ++++++------ client/tests/kvm/tests/kdump.py | 4 +- client/tests/kvm/tests/ksm_overcommit.py | 37 ++++++++++--------- client/tests/kvm/tests/mac_change.py | 8 ++-- client/tests/kvm/tests/migration.py | 6 ++-- .../kvm/tests/migration_with_file_transfer.py | 8 ++-- client/tests/kvm/tests/migration_with_reboot.py | 4 +- client/tests/kvm/tests/module_probe.py | 4 +- client/tests/kvm/tests/multicast.py | 10 +++--- client/tests/kvm/tests/netperf.py | 5 +-- client/tests/kvm/tests/nic_bonding.py | 6 ++-- client/tests/kvm/tests/nic_hotplug.py | 24 ++++++------ client/tests/kvm/tests/nic_promisc.py | 6 ++-- client/tests/kvm/tests/nicdriver_unload.py | 8 ++-- client/tests/kvm/tests/pci_hotplug.py | 18 +++++----- client/tests/kvm/tests/physical_resources_check.py | 2 +- client/tests/kvm/tests/ping.py | 12 +++--- client/tests/kvm/tests/pxe.py | 5 +-- client/tests/kvm/tests/qemu_img.py | 22 ++++++------ client/tests/kvm/tests/qmp_basic.py | 2 +- client/tests/kvm/tests/qmp_basic_rhel6.py | 2 +- client/tests/kvm/tests/set_link.py | 14 ++++---- client/tests/kvm/tests/shutdown.py | 4 +- client/tests/kvm/tests/stepmaker.py | 11 +++--- client/tests/kvm/tests/steps.py | 5 ++- client/tests/kvm/tests/stress_boot.py | 4 +- client/tests/kvm/tests/timedrift.py | 16 ++++---- client/tests/kvm/tests/timedrift_with_migration.py | 10 +++--- client/tests/kvm/tests/timedrift_with_reboot.py | 10 +++--- client/tests/kvm/tests/timedrift_with_stop.py | 10 +++--- client/tests/kvm/tests/unattended_install.py | 4 +- client/tests/kvm/tests/unittest.py | 6 ++-- client/tests/kvm/tests/virtio_console.py | 22 ++++++------ client/tests/kvm/tests/vlan.py | 14 ++++---- client/tests/kvm/tests/vmstop.py | 6 ++-- client/tests/kvm/tests/whql_client_install.py | 12 +++--- client/tests/kvm/tests/whql_submission.py | 24 ++++++------ 54 files changed, 258 insertions(+), 259 deletions(-) diff --git a/client/tests/kvm/control b/client/tests/kvm/control index d9ff70c..6437d88 100644 --- a/client/tests/kvm/control +++ b/client/tests/kvm/control @@ -21,11 +21,8 @@ For online docs, please refer to http://www.linux-kvm.org/page/KVM-Autotest """ import sys, os, logging -# Add the KVM tests dir to the python path -kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm') -sys.path.append(kvm_test_dir) -# Now we can import modules inside the KVM tests dir -import kvm_utils, kvm_config +from autotest_lib.client.common_lib import cartesian_config +from autotest_lib.client.virt import virt_utils # set English environment (command output might be localized, need to be safe) os.environ['LANG'] = 'en_US.UTF-8' @@ -36,10 +33,11 @@ str = """ #release_tag = 84 """ -parser = kvm_config.Parser() +parser = cartesian_config.Parser() +kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm') parser.parse_file(os.path.join(kvm_test_dir, "build.cfg")) parser.parse_string(str) -if not kvm_utils.run_tests(parser, job): +if not virt_utils.run_tests(parser, job): logging.error("KVM build step failed, exiting.") sys.exit(1) @@ -50,7 +48,7 @@ str = """ #install, setup: timeout_multiplier = 3 """ -parser = kvm_config.Parser() +parser = cartesian_config.Parser() parser.parse_file(os.path.join(kvm_test_dir, "tests.cfg")) if args: @@ -68,7 +66,7 @@ if args: pass parser.parse_string(str) -kvm_utils.run_tests(parser, job) +virt_utils.run_tests(parser, job) # Generate a nice HTML report inside the job's results dir -kvm_utils.create_report(kvm_test_dir, job.resultdir) +virt_utils.create_report(kvm_test_dir, job.resultdir) diff --git a/client/tests/kvm/control.parallel b/client/tests/kvm/control.parallel index 640ccf5..966d8bc 100644 --- a/client/tests/kvm/control.parallel +++ b/client/tests/kvm/control.parallel @@ -158,7 +158,7 @@ if not params.get("mode") == "noinstall": # ---------------------------------------------------------- # Get test set (dictionary list) from the configuration file # ---------------------------------------------------------- -import kvm_config +from autotest_lib.client.common_lib import cartesian_config str = """ # This string will be parsed after tests.cfg. Make any desired changes to the @@ -167,7 +167,7 @@ str = """ #display = sdl """ -parser = kvm_config.Parser() +parser = cartesian_config.Parser() parser.parse_file(os.path.join(pwd, "tests.cfg")) parser.parse_string(str) @@ -176,7 +176,7 @@ tests = list(parser.get_dicts()) # ------------- # Run the tests # ------------- -import kvm_scheduler +from autotest_lib.client.virt import virt_scheduler from autotest_lib.client.bin import utils # total_cpus defaults to the number of CPUs reported by /proc/cpuinfo @@ -187,7 +187,7 @@ total_mem = int(commands.getoutput("free -m").splitlines()[1].split()[1]) * 3/4 num_workers = total_cpus # Start the scheduler and workers -s = kvm_scheduler.scheduler(tests, num_workers, total_cpus, total_mem, pwd) +s = virt_scheduler.scheduler(tests, num_workers, total_cpus, total_mem, pwd) job.parallel([s.scheduler], *[(s.worker, i, job.run_test) for i in range(num_workers)]) diff --git a/client/tests/kvm/control.unittests b/client/tests/kvm/control.unittests index 170c3f8..8f3fc62 100644 --- a/client/tests/kvm/control.unittests +++ b/client/tests/kvm/control.unittests @@ -14,15 +14,13 @@ Runs the unittests available for a given KVM build. """ import sys, os, logging -# Add the KVM tests dir to the python path -kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm') -sys.path.append(kvm_test_dir) -# Now we can import modules inside the KVM tests dir -import kvm_utils, kvm_config +from autotest_lib.client.common_lib import cartesian_config +from autotest_lib.client.virt import virt_utils -tests_cfg = kvm_config.config() +parser = cartesian_config.Parser() +kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm') tests_cfg_path = os.path.join(kvm_test_dir, "unittests.cfg") -tests_cfg.fork_and_parse(tests_cfg_path) +parser.parse_file(tests_cfg_path) # Run the tests -kvm_utils.run_tests(tests_cfg.get_generator(), job) +virt_utils.run_tests(parser, job) diff --git a/client/tests/kvm/get_started.py b/client/tests/kvm/get_started.py index 5ce7349..c83fac4 100755 --- a/client/tests/kvm/get_started.py +++ b/client/tests/kvm/get_started.py @@ -6,9 +6,10 @@ Program to help setup kvm test environment """ import os, sys, logging, shutil -import common, kvm_utils +import common from autotest_lib.client.common_lib import logging_manager from autotest_lib.client.bin import utils +from autotest_lib.client.virt import virt_utils def check_iso(url, destination, hash): @@ -40,7 +41,7 @@ def check_iso(url, destination, hash): if __name__ == "__main__": - logging_manager.configure_logging(kvm_utils.KvmLoggingConfig(), + logging_manager.configure_logging(virt_utils.KvmLoggingConfig(), verbose=True) logging.info("KVM test config helper") diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py index b88fd51..6981b1b 100644 --- a/client/tests/kvm/kvm.py +++ b/client/tests/kvm/kvm.py @@ -1,7 +1,7 @@ import os, logging, imp from autotest_lib.client.bin import test from autotest_lib.client.common_lib import error -import kvm_utils, kvm_preprocessing +from autotest_lib.client.virt import virt_utils, virt_env_process class kvm(test.test): @@ -25,7 +25,7 @@ class kvm(test.test): def run_once(self, params): # Convert params to a Params object - params = kvm_utils.Params(params) + params = virt_utils.Params(params) # Report the parameters we've received and write them as keyvals logging.debug("Test parameters:") @@ -37,13 +37,13 @@ class kvm(test.test): # Set the log file dir for the logging mechanism used by kvm_subprocess # (this must be done before unpickling env) - kvm_utils.set_log_file_dir(self.debugdir) + virt_utils.set_log_file_dir(self.debugdir) # Open the environment file logging.info("Unpickling env. You may see some harmless error " "messages.") env_filename = os.path.join(self.bindir, params.get("env", "env")) - env = kvm_utils.Env(env_filename, self.env_version) + env = virt_utils.Env(env_filename, self.env_version) test_passed = False @@ -66,7 +66,7 @@ class kvm(test.test): # Preprocess try: - kvm_preprocessing.preprocess(self, params, env) + virt_env_process.preprocess(self, params, env) finally: env.save() # Run the test function @@ -81,7 +81,7 @@ class kvm(test.test): logging.error("Test failed: %s: %s", e.__class__.__name__, e) try: - kvm_preprocessing.postprocess_on_error( + virt_env_process.postprocess_on_error( self, params, env) finally: env.save() @@ -91,7 +91,7 @@ class kvm(test.test): # Postprocess try: try: - kvm_preprocessing.postprocess(self, params, env) + virt_env_process.postprocess(self, params, env) except Exception, e: if test_passed: raise diff --git a/client/tests/kvm/migration_control.srv b/client/tests/kvm/migration_control.srv index 6b17a26..7c63317 100644 --- a/client/tests/kvm/migration_control.srv +++ b/client/tests/kvm/migration_control.srv @@ -12,6 +12,7 @@ so there's a distinction between the migration roles ('dest' or 'source'). import sys, os, commands, glob, shutil, logging, random from autotest_lib.server import utils +from autotest_lib.client.common_lib import cartesian_config # Specify the directory of autotest before you start this test AUTOTEST_DIR = '/usr/local/autotest' @@ -19,11 +20,8 @@ AUTOTEST_DIR = '/usr/local/autotest' # Specify the root directory that on client machines rootdir = '/tmp/kvm_autotest_root' -# Make possible to import the KVM test APIs KVM_DIR = os.path.join(AUTOTEST_DIR, 'client/tests/kvm') -sys.path.append(KVM_DIR) -import common, kvm_config def generate_mac_address(): r = random.SystemRandom() @@ -50,7 +48,7 @@ def run(pair): raise error.JobError("Config file %s was not found", cfg_file) # Get test set (dictionary list) from the configuration file - parser = kvm_config.Parser() + parser = cartesian_config.Parser() test_variants = """ image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/ cdrom(_.*)? ?<= /tmp/kvm_autotest_root/ @@ -99,8 +97,10 @@ sys.path.append(kvm_test_dir)\n for key in keys: logging.debug(" %s = %s", key, params[key]) - source_control_file += "job.run_test('kvm', tag='%s', params=%s)" % (source_params['shortname'], source_params) - dest_control_file += "job.run_test('kvm', tag='%s', params=%s)" % (dest_params['shortname'], dest_params) + source_control_file += ("job.run_test('kvm', tag='%s', params=%s)" % + (source_params['shortname'], source_params)) + dest_control_file += ("job.run_test('kvm', tag='%s', params=%s)" % + (dest_params['shortname'], dest_params)) logging.info('Source control file:\n%s', source_control_file) logging.info('Destination control file:\n%s', dest_control_file) diff --git a/client/tests/kvm/tests/autotest.py b/client/tests/kvm/tests/autotest.py index afc2e3b..cdea31a 100644 --- a/client/tests/kvm/tests/autotest.py +++ b/client/tests/kvm/tests/autotest.py @@ -1,5 +1,5 @@ import os -import kvm_test_utils +from autotest_lib.client.virt import virt_test_utils def run_autotest(test, params, env): @@ -21,5 +21,5 @@ def run_autotest(test, params, env): params.get("test_control_file")) outputdir = test.outputdir - kvm_test_utils.run_autotest(vm, session, control_path, timeout, outputdir, - params) + virt_test_utils.run_autotest(vm, session, control_path, timeout, outputdir, + params) diff --git a/client/tests/kvm/tests/balloon_check.py b/client/tests/kvm/tests/balloon_check.py index 0c2a367..0b7f0f4 100644 --- a/client/tests/kvm/tests/balloon_check.py +++ b/client/tests/kvm/tests/balloon_check.py @@ -1,6 +1,6 @@ import re, logging, random, time from autotest_lib.client.common_lib import error -import kvm_monitor +from autotest_lib.client.virt import kvm_monitor def run_balloon_check(test, params, env): diff --git a/client/tests/kvm/tests/boot_savevm.py b/client/tests/kvm/tests/boot_savevm.py index 6af4132..b5da338 100644 --- a/client/tests/kvm/tests/boot_savevm.py +++ b/client/tests/kvm/tests/boot_savevm.py @@ -1,6 +1,6 @@ import logging, time from autotest_lib.client.common_lib import error -import kvm_monitor +from autotest_lib.client.virt import kvm_monitor def run_boot_savevm(test, params, env): diff --git a/client/tests/kvm/tests/build.py b/client/tests/kvm/tests/build.py index cbf4aed..cfebcd6 100644 --- a/client/tests/kvm/tests/build.py +++ b/client/tests/kvm/tests/build.py @@ -1,4 +1,4 @@ -import installer +from autotest_lib.client.virt import kvm_installer def run_build(test, params, env): @@ -14,7 +14,7 @@ def run_build(test, params, env): params["srcdir"] = srcdir try: - installer_object = installer.make_installer(params) + installer_object = kvm_installer.make_installer(params) installer_object.set_install_params(test, params) installer_object.install() env.register_installer(installer_object) @@ -22,5 +22,5 @@ def run_build(test, params, env): # if the build/install fails, don't allow other tests # to get a installer. msg = "KVM install failed: %s" % (e) - env.register_installer(installer.FailedInstaller(msg)) + env.register_installer(kvm_installer.FailedInstaller(msg)) raise diff --git a/client/tests/kvm/tests/enospc.py b/client/tests/kvm/tests/enospc.py index 3c53b64..caa6100 100644 --- a/client/tests/kvm/tests/enospc.py +++ b/client/tests/kvm/tests/enospc.py @@ -1,7 +1,7 @@ import logging, time, re from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_vm +from autotest_lib.client.virt import kvm_vm def run_enospc(test, params, env): diff --git a/client/tests/kvm/tests/ethtool.py b/client/tests/kvm/tests/ethtool.py index d7c6b57..1152f00 100644 --- a/client/tests/kvm/tests/ethtool.py +++ b/client/tests/kvm/tests/ethtool.py @@ -1,7 +1,7 @@ import logging, re from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_test_utils, kvm_utils, kvm_subprocess +from autotest_lib.client.virt import virt_test_utils, virt_utils, aexpect def run_ethtool(test, params, env): @@ -107,7 +107,7 @@ def run_ethtool(test, params, env): copy_files_from = vm.copy_files_from try: session.cmd_output(dd_cmd, timeout=360) - except kvm_subprocess.ShellCmdError, e: + except aexpect.ShellCmdError, e: return failure else: tcpdump_cmd += " and dst %s" % guest_ip @@ -124,20 +124,20 @@ def run_ethtool(test, params, env): tcpdump_cmd += " and not port %s" % i logging.debug("Listen using command: %s", tcpdump_cmd) session2.sendline(tcpdump_cmd) - if not kvm_utils.wait_for( + if not virt_utils.wait_for( lambda:session.cmd_status("pgrep tcpdump") == 0, 30): return (False, "Tcpdump process wasn't launched") logging.info("Start to transfer file") try: copy_files_from(filename, filename) - except kvm_utils.SCPError, e: + except virt_utils.SCPError, e: return (False, "File transfer failed (%s)" % e) logging.info("Transfer file completed") session.cmd("killall tcpdump") try: tcpdump_string = session2.read_up_to_prompt(timeout=60) - except kvm_subprocess.ExpectError: + except aexpect.ExpectError: return (False, "Fail to read tcpdump's output") if not compare_md5sum(filename): @@ -190,7 +190,7 @@ def run_ethtool(test, params, env): feature_status = {} filename = "/tmp/ethtool.dd" guest_ip = vm.get_address() - ethname = kvm_test_utils.get_linux_ifname(session, vm.get_mac_address(0)) + ethname = virt_test_utils.get_linux_ifname(session, vm.get_mac_address(0)) supported_features = params.get("supported_features") if supported_features: supported_features = supported_features.split() diff --git a/client/tests/kvm/tests/file_transfer.py b/client/tests/kvm/tests/file_transfer.py index 61982a6..5f6672d 100644 --- a/client/tests/kvm/tests/file_transfer.py +++ b/client/tests/kvm/tests/file_transfer.py @@ -1,7 +1,8 @@ import logging, time, os from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_utils +from autotest_lib.client.virt import virt_utils + def run_file_transfer(test, params, env): """ @@ -34,11 +35,11 @@ def run_file_transfer(test, params, env): count = 1 host_path = os.path.join(dir_name, "tmp-%s" % - kvm_utils.generate_random_string(8)) + virt_utils.generate_random_string(8)) host_path2 = host_path + ".2" cmd = "dd if=/dev/zero of=%s bs=10M count=%d" % (host_path, count) guest_path = (tmp_dir + "file_transfer-%s" % - kvm_utils.generate_random_string(8)) + virt_utils.generate_random_string(8)) try: logging.info("Creating %dMB file on host", filesize) diff --git a/client/tests/kvm/tests/guest_s4.py b/client/tests/kvm/tests/guest_s4.py index efd8e3b..5b5708d 100644 --- a/client/tests/kvm/tests/guest_s4.py +++ b/client/tests/kvm/tests/guest_s4.py @@ -1,6 +1,6 @@ import logging, time from autotest_lib.client.common_lib import error -import kvm_utils +from autotest_lib.client.virt import virt_utils @error.context_aware @@ -49,7 +49,7 @@ def run_guest_s4(test, params, env): # Make sure the VM goes down error.base_context("after S4") suspend_timeout = 240 + int(params.get("smp")) * 60 - if not kvm_utils.wait_for(vm.is_dead, suspend_timeout, 2, 2): + if not virt_utils.wait_for(vm.is_dead, suspend_timeout, 2, 2): raise error.TestFail("VM refuses to go down. Suspend failed.") logging.info("VM suspended successfully. Sleeping for a while before " "resuming it.") diff --git a/client/tests/kvm/tests/guest_test.py b/client/tests/kvm/tests/guest_test.py index 95c6f7f..3bc7da7 100644 --- a/client/tests/kvm/tests/guest_test.py +++ b/client/tests/kvm/tests/guest_test.py @@ -1,5 +1,5 @@ import os, logging -import kvm_utils +from autotest_lib.client.virt import virt_utils def run_guest_test(test, params, env): @@ -60,7 +60,7 @@ def run_guest_test(test, params, env): logging.info("Download resource finished.") else: session.cmd_output("del %s" % dst_rsc_path, internal_timeout=0) - script_path = kvm_utils.get_path(test.bindir, script) + script_path = virt_utils.get_path(test.bindir, script) vm.copy_files_to(script_path, dst_rsc_path, timeout=60) cmd = "%s %s %s" % (interpreter, dst_rsc_path, script_params) diff --git a/client/tests/kvm/tests/image_copy.py b/client/tests/kvm/tests/image_copy.py index 8a4d74c..cc921ab 100644 --- a/client/tests/kvm/tests/image_copy.py +++ b/client/tests/kvm/tests/image_copy.py @@ -1,7 +1,7 @@ import os, logging from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_utils +from autotest_lib.client.virt import virt_utils def run_image_copy(test, params, env): @@ -33,7 +33,7 @@ def run_image_copy(test, params, env): dst_path = '%s.%s' % (params['image_name'], params['image_format']) cmd = 'cp %s %s' % (src_path, dst_path) - if not kvm_utils.mount(src, mount_dest_dir, 'nfs', 'ro'): + if not virt_utils.mount(src, mount_dest_dir, 'nfs', 'ro'): raise error.TestError('Could not mount NFS share %s to %s' % (src, mount_dest_dir)) diff --git a/client/tests/kvm/tests/iofuzz.py b/client/tests/kvm/tests/iofuzz.py index 7189f91..d244012 100644 --- a/client/tests/kvm/tests/iofuzz.py +++ b/client/tests/kvm/tests/iofuzz.py @@ -1,6 +1,6 @@ import logging, re, random -from autotest_lib.client.common_lib import error -import kvm_subprocess +from autotest_lib.client.common_lib import error, aexpect +from autotest_lib.client.virt import aexpect def run_iofuzz(test, params, env): @@ -35,7 +35,7 @@ def run_iofuzz(test, params, env): (oct(data), port)) try: session.cmd(outb_cmd) - except kvm_subprocess.ShellError, e: + except aexpect.ShellError, e: logging.debug(e) @@ -50,7 +50,7 @@ def run_iofuzz(test, params, env): inb_cmd = "dd if=/dev/port seek=%d of=/dev/null bs=1 count=1" % port try: session.cmd(inb_cmd) - except kvm_subprocess.ShellError, e: + except aexpect.ShellError, e: logging.debug(e) diff --git a/client/tests/kvm/tests/jumbo.py b/client/tests/kvm/tests/jumbo.py index b7f88ae..5108227 100644 --- a/client/tests/kvm/tests/jumbo.py +++ b/client/tests/kvm/tests/jumbo.py @@ -1,7 +1,7 @@ import logging, commands, random from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_test_utils, kvm_utils +from autotest_lib.client.virt import virt_utils, virt_test_utils def run_jumbo(test, params, env): @@ -37,7 +37,7 @@ def run_jumbo(test, params, env): try: # Environment preparation - ethname = kvm_test_utils.get_linux_ifname(session, vm.get_mac_address(0)) + ethname = virt_test_utils.get_linux_ifname(session, vm.get_mac_address(0)) logging.info("Changing the MTU of guest ...") guest_mtu_cmd = "ifconfig %s mtu %s" % (ethname , mtu) @@ -52,36 +52,36 @@ def run_jumbo(test, params, env): utils.run(arp_add_cmd) def is_mtu_ok(): - s, o = kvm_test_utils.ping(ip, 1, interface=ifname, + s, o = virt_test_utils.ping(ip, 1, interface=ifname, packetsize=max_icmp_pkt_size, hint="do", timeout=2) return s == 0 def verify_mtu(): logging.info("Verify the path MTU") - s, o = kvm_test_utils.ping(ip, 10, interface=ifname, + s, o = virt_test_utils.ping(ip, 10, interface=ifname, packetsize=max_icmp_pkt_size, hint="do", timeout=15) if s != 0 : logging.error(o) raise error.TestFail("Path MTU is not as expected") - if kvm_test_utils.get_loss_ratio(o) != 0: + if virt_test_utils.get_loss_ratio(o) != 0: logging.error(o) raise error.TestFail("Packet loss ratio during MTU " "verification is not zero") def flood_ping(): logging.info("Flood with large frames") - kvm_test_utils.ping(ip, interface=ifname, + virt_test_utils.ping(ip, interface=ifname, packetsize=max_icmp_pkt_size, flood=True, timeout=float(flood_time)) def large_frame_ping(count=100): logging.info("Large frame ping") - s, o = kvm_test_utils.ping(ip, count, interface=ifname, + s, o = virt_test_utils.ping(ip, count, interface=ifname, packetsize=max_icmp_pkt_size, timeout=float(count) * 2) - ratio = kvm_test_utils.get_loss_ratio(o) + ratio = virt_test_utils.get_loss_ratio(o) if ratio != 0: raise error.TestFail("Loss ratio of large frame ping is %s" % ratio) @@ -90,23 +90,23 @@ def run_jumbo(test, params, env): logging.info("Size increase ping") for size in range(0, max_icmp_pkt_size + 1, step): logging.info("Ping %s with size %s", ip, size) - s, o = kvm_test_utils.ping(ip, 1, interface=ifname, + s, o = virt_test_utils.ping(ip, 1, interface=ifname, packetsize=size, hint="do", timeout=1) if s != 0: - s, o = kvm_test_utils.ping(ip, 10, interface=ifname, + s, o = virt_test_utils.ping(ip, 10, interface=ifname, packetsize=size, adaptive=True, hint="do", timeout=20) - if kvm_test_utils.get_loss_ratio(o) > int(params.get( + if virt_test_utils.get_loss_ratio(o) > int(params.get( "fail_ratio", 50)): raise error.TestFail("Ping loss ratio is greater " "than 50% for size %s" % size) logging.info("Waiting for the MTU to be OK") wait_mtu_ok = 10 - if not kvm_utils.wait_for(is_mtu_ok, wait_mtu_ok, 0, 1): + if not virt_utils.wait_for(is_mtu_ok, wait_mtu_ok, 0, 1): logging.debug(commands.getoutput("ifconfig -a")) raise error.TestError("MTU is not as expected even after %s " "seconds" % wait_mtu_ok) diff --git a/client/tests/kvm/tests/kdump.py b/client/tests/kvm/tests/kdump.py index c847131..90c004b 100644 --- a/client/tests/kvm/tests/kdump.py +++ b/client/tests/kvm/tests/kdump.py @@ -1,6 +1,6 @@ import logging from autotest_lib.client.common_lib import error -import kvm_utils +from autotest_lib.client.virt import virt_utils def run_kdump(test, params, env): @@ -41,7 +41,7 @@ def run_kdump(test, params, env): crash_cmd = "taskset -c %d echo c > /proc/sysrq-trigger" % vcpu session.sendline(crash_cmd) - if not kvm_utils.wait_for(lambda: not session.is_responsive(), 240, 0, + if not virt_utils.wait_for(lambda: not session.is_responsive(), 240, 0, 1): raise error.TestFail("Could not trigger crash on vcpu %d" % vcpu) diff --git a/client/tests/kvm/tests/ksm_overcommit.py b/client/tests/kvm/tests/ksm_overcommit.py index 5aba25a..c3b4cad 100644 --- a/client/tests/kvm/tests/ksm_overcommit.py +++ b/client/tests/kvm/tests/ksm_overcommit.py @@ -1,7 +1,8 @@ import logging, time, random, math, os from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_subprocess, kvm_test_utils, kvm_utils, kvm_preprocessing +from autotest_lib.client.virt import virt_utils, virt_test_utils, aexpect +from autotest_lib.client.virt import virt_env_process def run_ksm_overcommit(test, params, env): @@ -29,7 +30,7 @@ def run_ksm_overcommit(test, params, env): session.sendline("python /tmp/ksm_overcommit_guest.py") try: session.read_until_last_line_matches(["PASS:", "FAIL:"], timeout) - except kvm_subprocess.ExpectProcessTerminatedError, e: + except aexpect.ExpectProcessTerminatedError, e: e_msg = ("Command ksm_overcommit_guest.py on vm '%s' failed: %s" % (vm.name, str(e))) raise error.TestFail(e_msg) @@ -54,7 +55,7 @@ def run_ksm_overcommit(test, params, env): (match, data) = session.read_until_last_line_matches( ["PASS:","FAIL:"], timeout) - except kvm_subprocess.ExpectProcessTerminatedError, e: + except aexpect.ExpectProcessTerminatedError, e: e_msg = ("Failed to execute command '%s' on " "ksm_overcommit_guest.py, vm '%s': %s" % (command, vm.name, str(e))) @@ -107,7 +108,7 @@ def run_ksm_overcommit(test, params, env): while ((new_ksm and (shm < (ksm_size*(i+1)))) or (not new_ksm and (shm < (ksm_size)))): if j > 64: - logging.debug(kvm_test_utils.get_memory_info(lvms)) + logging.debug(virt_test_utils.get_memory_info(lvms)) raise error.TestError("SHM didn't merge the memory until " "the DL on guest: %s" % vm.name) st = ksm_size / 200 * perf_ratio @@ -126,7 +127,7 @@ def run_ksm_overcommit(test, params, env): logging.debug("Waiting %ds before proceeding...", rt) time.sleep(rt) - logging.debug(kvm_test_utils.get_memory_info(lvms)) + logging.debug(virt_test_utils.get_memory_info(lvms)) logging.info("Phase 1: PASS") @@ -145,7 +146,7 @@ def run_ksm_overcommit(test, params, env): out = int(r_msg.split()[4]) logging.debug("Performance: %dMB * 1000 / %dms = %dMB/s", ksm_size, out, (ksm_size * 1000 / out)) - logging.debug(kvm_test_utils.get_memory_info(lvms)) + logging.debug(virt_test_utils.get_memory_info(lvms)) logging.debug("Phase 2: PASS") @@ -223,7 +224,7 @@ def run_ksm_overcommit(test, params, env): for i in range(last_vm + 1, vmsc): lsessions[i].close() if i == (vmsc - 1): - logging.debug(kvm_test_utils.get_memory_info([lvms[i]])) + logging.debug(virt_test_utils.get_memory_info([lvms[i]])) logging.debug("Destroying guest %s", lvms[i].name) lvms[i].destroy(gracefully = False) @@ -231,7 +232,7 @@ def run_ksm_overcommit(test, params, env): a_cmd = "mem.static_random_verify()" _execute_allocator(a_cmd, lvms[last_vm], lsessions[last_vm], (mem / 200 * 50 * perf_ratio)) - logging.debug(kvm_test_utils.get_memory_info([lvms[last_vm]])) + logging.debug(virt_test_utils.get_memory_info([lvms[last_vm]])) lsessions[i].cmd_output("die()", 20) lvms[last_vm].destroy(gracefully = False) @@ -277,7 +278,7 @@ def run_ksm_overcommit(test, params, env): logging.debug("Target shared memory size: %s", ksm_size) while (shm < ksm_size): if i > 64: - logging.debug(kvm_test_utils.get_memory_info(lvms)) + logging.debug(virt_test_utils.get_memory_info(lvms)) raise error.TestError("SHM didn't merge the memory until DL") wt = ksm_size / 200 * perf_ratio logging.debug("Waiting %ds before proceed...", wt) @@ -289,7 +290,7 @@ def run_ksm_overcommit(test, params, env): logging.debug("Shared meminfo after attempt %s: %s", i, shm) i += 1 - logging.debug(kvm_test_utils.get_memory_info([vm])) + logging.debug(virt_test_utils.get_memory_info([vm])) logging.info("Phase 2a: PASS") logging.info("Phase 2b: Simultaneous spliting") @@ -305,7 +306,7 @@ def run_ksm_overcommit(test, params, env): logging.debug("Performance: %dMB * 1000 / %dms = %dMB/s", (ksm_size / max_alloc), out, (ksm_size * 1000 / out / max_alloc)) - logging.debug(kvm_test_utils.get_memory_info([vm])) + logging.debug(virt_test_utils.get_memory_info([vm])) logging.info("Phase 2b: PASS") logging.info("Phase 2c: Simultaneous verification") @@ -321,7 +322,7 @@ def run_ksm_overcommit(test, params, env): a_cmd = "mem.value_fill(%d)" % skeys[0] data = _execute_allocator(a_cmd, vm, lsessions[i], 120 * perf_ratio)[1] - logging.debug(kvm_test_utils.get_memory_info([vm])) + logging.debug(virt_test_utils.get_memory_info([vm])) logging.info("Phase 2d: PASS") logging.info("Phase 2e: Simultaneous verification") @@ -343,7 +344,7 @@ def run_ksm_overcommit(test, params, env): ksm_size/max_alloc, out, (ksm_size * 1000 / out / max_alloc)) - logging.debug(kvm_test_utils.get_memory_info([vm])) + logging.debug(virt_test_utils.get_memory_info([vm])) logging.info("Phase 2f: PASS") logging.info("Phase 2g: Simultaneous verification last 96B") @@ -351,7 +352,7 @@ def run_ksm_overcommit(test, params, env): a_cmd = "mem.static_random_verify(96)" (match, data) = _execute_allocator(a_cmd, vm, lsessions[i], (mem / 200 * 50 * perf_ratio)) - logging.debug(kvm_test_utils.get_memory_info([vm])) + logging.debug(virt_test_utils.get_memory_info([vm])) logging.info("Phase 2g: PASS") logging.debug("Cleaning up...") @@ -528,7 +529,7 @@ def run_ksm_overcommit(test, params, env): params['mem'] = mem params['vms'] = vm_name # Associate pidfile name - params['pid_' + vm_name] = kvm_utils.generate_tmp_file_name(vm_name, + params['pid_' + vm_name] = virt_utils.generate_tmp_file_name(vm_name, 'pid') if not params.get('extra_params'): params['extra_params'] = ' ' @@ -542,7 +543,7 @@ def run_ksm_overcommit(test, params, env): logging.debug("Memory used by allocator on guests = %dM", ksm_size) # Creating the first guest - kvm_preprocessing.preprocess_vm(test, params, env, vm_name) + virt_env_process.preprocess_vm(test, params, env, vm_name) lvms.append(env.get_vm(vm_name)) if not lvms[0]: raise error.TestError("VM object not found in environment") @@ -563,7 +564,7 @@ def run_ksm_overcommit(test, params, env): # Creating other guest systems for i in range(1, vmsc): vm_name = "vm" + str(i + 1) - params['pid_' + vm_name] = kvm_utils.generate_tmp_file_name(vm_name, + params['pid_' + vm_name] = virt_utils.generate_tmp_file_name(vm_name, 'pid') params['extra_params_' + vm_name] = params.get('extra_params') params['extra_params_' + vm_name] += (" -pidfile %s" % @@ -592,7 +593,7 @@ def run_ksm_overcommit(test, params, env): st = vmsc * 2 * perf_ratio logging.debug("Waiting %ds before proceed", st) time.sleep(vmsc * 2 * perf_ratio) - logging.debug(kvm_test_utils.get_memory_info(lvms)) + logging.debug(virt_test_utils.get_memory_info(lvms)) # Copy ksm_overcommit_guest.py into guests pwd = os.path.join(os.environ['AUTODIR'],'tests/kvm') diff --git a/client/tests/kvm/tests/mac_change.py b/client/tests/kvm/tests/mac_change.py index 3fd196f..d2eaf01 100644 --- a/client/tests/kvm/tests/mac_change.py +++ b/client/tests/kvm/tests/mac_change.py @@ -1,6 +1,6 @@ import logging from autotest_lib.client.common_lib import error -import kvm_utils, kvm_test_utils +from autotest_lib.client.virt import virt_utils, virt_test_utils def run_mac_change(test, params, env): @@ -24,11 +24,11 @@ def run_mac_change(test, params, env): old_mac = vm.get_mac_address(0) while True: vm.free_mac_address(0) - new_mac = kvm_utils.generate_mac_address(vm.instance, 0) + new_mac = virt_utils.generate_mac_address(vm.instance, 0) if old_mac != new_mac: break logging.info("The initial MAC address is %s", old_mac) - interface = kvm_test_utils.get_linux_ifname(session_serial, old_mac) + interface = virt_test_utils.get_linux_ifname(session_serial, old_mac) # Start change MAC address logging.info("Changing MAC address to %s", new_mac) change_cmd = ("ifconfig %s down && ifconfig %s hw ether %s && " @@ -45,7 +45,7 @@ def run_mac_change(test, params, env): session_serial.sendline(dhclient_cmd) # Re-log into the guest after changing mac address - if kvm_utils.wait_for(session.is_responsive, 120, 20, 3): + if virt_utils.wait_for(session.is_responsive, 120, 20, 3): # Just warning when failed to see the session become dead, # because there is a little chance the ip does not change. logging.warn("The session is still responsive, settings may fail.") diff --git a/client/tests/kvm/tests/migration.py b/client/tests/kvm/tests/migration.py index b462e66..2426f3f 100644 --- a/client/tests/kvm/tests/migration.py +++ b/client/tests/kvm/tests/migration.py @@ -1,6 +1,6 @@ import logging, time from autotest_lib.client.common_lib import error -import kvm_utils +from autotest_lib.client.virt import virt_utils def run_migration(test, params, env): @@ -68,9 +68,9 @@ def run_migration(test, params, env): "command output after migration") logging.info("Command: %s", test_command) logging.info("Output before:" + - kvm_utils.format_str_for_message(reference_output)) + virt_utils.format_str_for_message(reference_output)) logging.info("Output after:" + - kvm_utils.format_str_for_message(output)) + virt_utils.format_str_for_message(output)) raise error.TestFail("Command '%s' produced different output " "before and after migration" % test_command) diff --git a/client/tests/kvm/tests/migration_with_file_transfer.py b/client/tests/kvm/tests/migration_with_file_transfer.py index b38defd..25ada82 100644 --- a/client/tests/kvm/tests/migration_with_file_transfer.py +++ b/client/tests/kvm/tests/migration_with_file_transfer.py @@ -1,7 +1,7 @@ import logging, time, os from autotest_lib.client.common_lib import utils, error from autotest_lib.client.bin import utils as client_utils -import kvm_utils +from autotest_lib.client.virt import virt_utils @error.context_aware @@ -29,7 +29,7 @@ def run_migration_with_file_transfer(test, params, env): mig_protocol = params.get("migration_protocol", "tcp") mig_cancel_delay = int(params.get("mig_cancel") == "yes") * 2 - host_path = "/tmp/file-%s" % kvm_utils.generate_random_string(6) + host_path = "/tmp/file-%s" % virt_utils.generate_random_string(6) host_path_returned = "%s-returned" % host_path guest_path = params.get("guest_path", "/tmp/file") file_size = params.get("file_size", "500") @@ -56,13 +56,13 @@ def run_migration_with_file_transfer(test, params, env): error.context("transferring file to guest while migrating", logging.info) - bg = kvm_utils.Thread(vm.copy_files_to, (host_path, guest_path), + bg = virt_utils.Thread(vm.copy_files_to, (host_path, guest_path), dict(verbose=True, timeout=transfer_timeout)) run_and_migrate(bg) error.context("transferring file back to host while migrating", logging.info) - bg = kvm_utils.Thread(vm.copy_files_from, + bg = virt_utils.Thread(vm.copy_files_from, (guest_path, host_path_returned), dict(verbose=True, timeout=transfer_timeout)) run_and_migrate(bg) diff --git a/client/tests/kvm/tests/migration_with_reboot.py b/client/tests/kvm/tests/migration_with_reboot.py index a15f983..5dddb12 100644 --- a/client/tests/kvm/tests/migration_with_reboot.py +++ b/client/tests/kvm/tests/migration_with_reboot.py @@ -1,4 +1,4 @@ -import kvm_utils +from autotest_lib.client.virt import virt_utils def run_migration_with_reboot(test, params, env): @@ -27,7 +27,7 @@ def run_migration_with_reboot(test, params, env): try: # Reboot the VM in the background - bg = kvm_utils.Thread(vm.reboot, (session,)) + bg = virt_utils.Thread(vm.reboot, (session,)) bg.start() try: while bg.isAlive(): diff --git a/client/tests/kvm/tests/module_probe.py b/client/tests/kvm/tests/module_probe.py index 72f239b..b192b6d 100644 --- a/client/tests/kvm/tests/module_probe.py +++ b/client/tests/kvm/tests/module_probe.py @@ -1,6 +1,6 @@ import re, commands, logging, os from autotest_lib.client.common_lib import error, utils -import kvm_subprocess, kvm_test_utils, kvm_utils, installer +from autotest_lib.client.virt import kvm_installer def run_module_probe(test, params, env): @@ -19,7 +19,7 @@ def run_module_probe(test, params, env): installer_object = env.previous_installer() if installer_object is None: - installer_object = installer.PreInstalledKvm() + installer_object = kvm_installer.PreInstalledKvm() installer_object.set_install_params(test, params) logging.debug('installer object: %r', installer_object) diff --git a/client/tests/kvm/tests/multicast.py b/client/tests/kvm/tests/multicast.py index 5dfecbc..13e3f0d 100644 --- a/client/tests/kvm/tests/multicast.py +++ b/client/tests/kvm/tests/multicast.py @@ -1,7 +1,7 @@ import logging, os, re from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_test_utils, kvm_subprocess +from autotest_lib.client.virt import virt_test_utils, aexpect def run_multicast(test, params, env): @@ -25,7 +25,7 @@ def run_multicast(test, params, env): def run_guest(cmd): try: session.cmd(cmd) - except kvm_subprocess.ShellError, e: + except aexpect.ShellError, e: logging.warn(e) def run_host_guest(cmd): @@ -70,16 +70,16 @@ def run_multicast(test, params, env): mcast = "%s.%d" % (prefix, new_suffix) logging.info("Initial ping test, mcast: %s", mcast) - s, o = kvm_test_utils.ping(mcast, 10, interface=ifname, timeout=20) + s, o = virt_test_utils.ping(mcast, 10, interface=ifname, timeout=20) if s != 0: raise error.TestFail(" Ping return non-zero value %s" % o) logging.info("Flood ping test, mcast: %s", mcast) - kvm_test_utils.ping(mcast, None, interface=ifname, flood=True, + virt_test_utils.ping(mcast, None, interface=ifname, flood=True, output_func=None, timeout=flood_minutes*60) logging.info("Final ping test, mcast: %s", mcast) - s, o = kvm_test_utils.ping(mcast, 10, interface=ifname, timeout=20) + s, o = virt_test_utils.ping(mcast, 10, interface=ifname, timeout=20) if s != 0: raise error.TestFail("Ping failed, status: %s, output: %s" % (s, o)) diff --git a/client/tests/kvm/tests/netperf.py b/client/tests/kvm/tests/netperf.py index df2c839..72d9cde 100644 --- a/client/tests/kvm/tests/netperf.py +++ b/client/tests/kvm/tests/netperf.py @@ -1,8 +1,7 @@ import logging, os, signal from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_subprocess - +from autotest_lib.client.virt import aexpect def run_netperf(test, params, env): """ @@ -39,7 +38,7 @@ def run_netperf(test, params, env): try: session_serial.cmd(firewall_flush) - except kvm_subprocess.ShellError: + except aexpect.ShellError: logging.warning("Could not flush firewall rules on guest") session_serial.cmd(setup_cmd % "/tmp", timeout=200) diff --git a/client/tests/kvm/tests/nic_bonding.py b/client/tests/kvm/tests/nic_bonding.py index 1d53e0e..e998820 100644 --- a/client/tests/kvm/tests/nic_bonding.py +++ b/client/tests/kvm/tests/nic_bonding.py @@ -1,6 +1,6 @@ import logging, time, threading from autotest_lib.client.tests.kvm.tests import file_transfer -import kvm_utils, kvm_test_utils +from autotest_lib.client.virt import virt_test_utils, virt_utils def run_nic_bonding(test, params, env): @@ -30,7 +30,7 @@ def run_nic_bonding(test, params, env): session_serial.cmd(modprobe_cmd) session_serial.cmd("ifconfig bond0 up") - ifnames = [kvm_test_utils.get_linux_ifname(session_serial, + ifnames = [virt_test_utils.get_linux_ifname(session_serial, vm.get_mac_address(vlan)) for vlan, nic in enumerate(params.get("nics").split())] setup_cmd = "ifenslave bond0 " + " ".join(ifnames) @@ -42,7 +42,7 @@ def run_nic_bonding(test, params, env): file_transfer.run_file_transfer(test, params, env) logging.info("Failover test with file transfer") - transfer_thread = kvm_utils.Thread(file_transfer.run_file_transfer, + transfer_thread = virt_utils.Thread(file_transfer.run_file_transfer, (test, params, env)) try: transfer_thread.start() diff --git a/client/tests/kvm/tests/nic_hotplug.py b/client/tests/kvm/tests/nic_hotplug.py index d44276a..059277e 100644 --- a/client/tests/kvm/tests/nic_hotplug.py +++ b/client/tests/kvm/tests/nic_hotplug.py @@ -1,6 +1,6 @@ import logging from autotest_lib.client.common_lib import error -import kvm_test_utils, kvm_utils +from autotest_lib.client.virt import virt_test_utils, virt_utils def run_nic_hotplug(test, params, env): @@ -20,10 +20,10 @@ def run_nic_hotplug(test, params, env): @param params: Dictionary with the test parameters. @param env: Dictionary with test environment. """ - vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) + vm = virt_test_utils.get_living_vm(env, params.get("main_vm")) timeout = int(params.get("login_timeout", 360)) guest_delay = int(params.get("guest_delay", 20)) - session = kvm_test_utils.wait_for_login(vm, timeout=timeout) + session = virt_test_utils.wait_for_login(vm, timeout=timeout) romfile = params.get("romfile") # Modprobe the module if specified in config file @@ -32,11 +32,11 @@ def run_nic_hotplug(test, params, env): session.get_command_output("modprobe %s" % module) def netdev_add(vm): - netdev_id = kvm_utils.generate_random_id() + netdev_id = virt_utils.generate_random_id() attach_cmd = ("netdev_add tap,id=%s" % netdev_id) nic_script = params.get("nic_script") if nic_script: - attach_cmd += ",script=%s" % kvm_utils.get_path(vm.root_dir, + attach_cmd += ",script=%s" % virt_utils.get_path(vm.root_dir, nic_script) netdev_extra_params = params.get("netdev_extra_params") if netdev_extra_params: @@ -69,7 +69,7 @@ def run_nic_hotplug(test, params, env): @mac: Mac address of new nic @rom: Rom file """ - nic_id = kvm_utils.generate_random_id() + nic_id = virt_utils.generate_random_id() if model == "virtio": model = "virtio-net-pci" device_add_cmd = "device_add %s,netdev=%s,mac=%s,id=%s" % (model, @@ -100,7 +100,7 @@ def run_nic_hotplug(test, params, env): vm.monitor.cmd(nic_del_cmd) if wait: logging.info("waiting for the guest to finish the unplug") - if not kvm_utils.wait_for(lambda: nic_id not in + if not virt_utils.wait_for(lambda: nic_id not in vm.monitor.info("qtree"), guest_delay, 5 ,1): logging.error(vm.monitor.info("qtree")) @@ -109,7 +109,7 @@ def run_nic_hotplug(test, params, env): "hotplug module was loaded in guest") logging.info("Attach a virtio nic to vm") - mac = kvm_utils.generate_mac_address(vm.instance, 1) + mac = virt_utils.generate_mac_address(vm.instance, 1) if not mac: mac = "00:00:02:00:00:02" netdev_id = netdev_add(vm) @@ -117,24 +117,24 @@ def run_nic_hotplug(test, params, env): if "Win" not in params.get("guest_name", ""): session.sendline("dhclient %s &" % - kvm_test_utils.get_linux_ifname(session, mac)) + virt_test_utils.get_linux_ifname(session, mac)) logging.info("Shutting down the primary link") vm.monitor.cmd("set_link %s down" % vm.netdev_id[0]) try: logging.info("Waiting for new nic's ip address acquisition...") - if not kvm_utils.wait_for(lambda: (vm.address_cache.get(mac) is + if not virt_utils.wait_for(lambda: (vm.address_cache.get(mac) is not None), 10, 1): raise error.TestFail("Could not get ip address of new nic") ip = vm.address_cache.get(mac) - if not kvm_utils.verify_ip_address_ownership(ip, mac): + if not virt_utils.verify_ip_address_ownership(ip, mac): raise error.TestFail("Could not verify the ip address of new nic") else: logging.info("Got the ip address of new nic: %s", ip) logging.info("Ping test the new nic ...") - s, o = kvm_test_utils.ping(ip, 100) + s, o = virt_test_utils.ping(ip, 100) if s != 0: logging.error(o) raise error.TestFail("New nic failed ping test") diff --git a/client/tests/kvm/tests/nic_promisc.py b/client/tests/kvm/tests/nic_promisc.py index ac6f983..0ff07b8 100644 --- a/client/tests/kvm/tests/nic_promisc.py +++ b/client/tests/kvm/tests/nic_promisc.py @@ -2,7 +2,7 @@ import logging, threading from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils from autotest_lib.client.tests.kvm.tests import file_transfer -import kvm_utils, kvm_test_utils +from autotest_lib.client.virt import virt_test_utils, virt_utils def run_nic_promisc(test, params, env): @@ -22,11 +22,11 @@ def run_nic_promisc(test, params, env): timeout = int(params.get("login_timeout", 360)) session_serial = vm.wait_for_serial_login(timeout=timeout) - ethname = kvm_test_utils.get_linux_ifname(session_serial, + ethname = virt_test_utils.get_linux_ifname(session_serial, vm.get_mac_address(0)) try: - transfer_thread = kvm_utils.Thread(file_transfer.run_file_transfer, + transfer_thread = virt_utils.Thread(file_transfer.run_file_transfer, (test, params, env)) transfer_thread.start() while transfer_thread.isAlive(): diff --git a/client/tests/kvm/tests/nicdriver_unload.py b/client/tests/kvm/tests/nicdriver_unload.py index 15a73ce..6d3d4da 100644 --- a/client/tests/kvm/tests/nicdriver_unload.py +++ b/client/tests/kvm/tests/nicdriver_unload.py @@ -2,7 +2,7 @@ import logging, threading, os, time from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils from autotest_lib.client.tests.kvm.tests import file_transfer -import kvm_test_utils, kvm_utils +from autotest_lib.client.virt import virt_test_utils, virt_utils def run_nicdriver_unload(test, params, env): @@ -24,8 +24,8 @@ def run_nicdriver_unload(test, params, env): vm.verify_alive() session_serial = vm.wait_for_serial_login(timeout=timeout) - ethname = kvm_test_utils.get_linux_ifname(session_serial, - vm.get_mac_address(0)) + ethname = virt_test_utils.get_linux_ifname(session_serial, + vm.get_mac_address(0)) sys_path = "/sys/class/net/%s/device/driver" % (ethname) driver = os.path.basename(session_serial.cmd("readlink -e %s" % sys_path).strip()) @@ -34,7 +34,7 @@ def run_nicdriver_unload(test, params, env): try: threads = [] for t in range(int(params.get("sessions_num", "10"))): - thread = kvm_utils.Thread(file_transfer.run_file_transfer, + thread = virt_utils.Thread(file_transfer.run_file_transfer, (test, params, env)) thread.start() threads.append(thread) diff --git a/client/tests/kvm/tests/pci_hotplug.py b/client/tests/kvm/tests/pci_hotplug.py index 0806120..5800fc5 100644 --- a/client/tests/kvm/tests/pci_hotplug.py +++ b/client/tests/kvm/tests/pci_hotplug.py @@ -1,6 +1,6 @@ import re from autotest_lib.client.common_lib import error -import kvm_subprocess, kvm_utils, kvm_vm +from autotest_lib.client.virt import virt_utils, virt_vm, aexpect def run_pci_hotplug(test, params, env): @@ -66,7 +66,7 @@ def run_pci_hotplug(test, params, env): pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model elif test_type == "block": image_params = params.object_params("stg") - image_filename = kvm_vm.get_image_filename(image_params, + image_filename = virt_vm.get_image_filename(image_params, test.bindir) pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" % (image_filename, tested_model)) @@ -79,8 +79,8 @@ def run_pci_hotplug(test, params, env): after_add = vm.monitor.info("pci") elif cmd_type == "device_add": - driver_id = test_type + "-" + kvm_utils.generate_random_id() - device_id = test_type + "-" + kvm_utils.generate_random_id() + driver_id = test_type + "-" + virt_utils.generate_random_id() + device_id = test_type + "-" + virt_utils.generate_random_id() if test_type == "nic": if tested_model == "virtio": tested_model = "virtio-net-pci" @@ -89,7 +89,7 @@ def run_pci_hotplug(test, params, env): elif test_type == "block": image_params = params.object_params("stg") - image_filename = kvm_vm.get_image_filename(image_params, + image_filename = virt_vm.get_image_filename(image_params, test.bindir) controller_model = None if tested_model == "virtio": @@ -152,7 +152,7 @@ def run_pci_hotplug(test, params, env): after_del = vm.monitor.info("pci") return after_del != after_add - if (not kvm_utils.wait_for(device_removed, 10, 0, 1) + if (not virt_utils.wait_for(device_removed, 10, 0, 1) and not ignore_failure): raise error.TestFail("Failed to hot remove PCI device: %s. " "Monitor command: %s" % @@ -170,7 +170,7 @@ def run_pci_hotplug(test, params, env): return o != reference secs = int(params.get("wait_secs_for_hook_up")) - if not kvm_utils.wait_for(new_shown, 30, secs, 3): + if not virt_utils.wait_for(new_shown, 30, secs, 3): raise error.TestFail("No new device shown in output of command " "executed inside the guest: %s" % params.get("reference_cmd")) @@ -180,7 +180,7 @@ def run_pci_hotplug(test, params, env): o = session.cmd_output(params.get("find_pci_cmd")) return params.get("match_string") in o - if not kvm_utils.wait_for(find_pci, 30, 3, 3): + if not virt_utils.wait_for(find_pci, 30, 3, 3): raise error.TestFail("PCI %s %s device not found in guest. " "Command was: %s" % (tested_model, test_type, @@ -189,7 +189,7 @@ def run_pci_hotplug(test, params, env): # Test the newly added device try: session.cmd(params.get("pci_test_cmd")) - except kvm_subprocess.ShellError, e: + except aexpect.ShellError, e: raise error.TestFail("Check for %s device failed after PCI " "hotplug. Output: %r" % (test_type, e.output)) diff --git a/client/tests/kvm/tests/physical_resources_check.py b/client/tests/kvm/tests/physical_resources_check.py index f9e603c..1ef906f 100644 --- a/client/tests/kvm/tests/physical_resources_check.py +++ b/client/tests/kvm/tests/physical_resources_check.py @@ -1,6 +1,6 @@ import re, string, logging from autotest_lib.client.common_lib import error -import kvm_monitor +from autotest_lib.client.virt import kvm_monitor def run_physical_resources_check(test, params, env): diff --git a/client/tests/kvm/tests/ping.py b/client/tests/kvm/tests/ping.py index 8dc4b9e..08791fb 100644 --- a/client/tests/kvm/tests/ping.py +++ b/client/tests/kvm/tests/ping.py @@ -1,6 +1,6 @@ import logging from autotest_lib.client.common_lib import error -import kvm_test_utils +from autotest_lib.client.virt import virt_test_utils def run_ping(test, params, env): @@ -40,11 +40,11 @@ def run_ping(test, params, env): for size in packet_size: logging.info("Ping with packet size %s", size) - status, output = kvm_test_utils.ping(ip, 10, + status, output = virt_test_utils.ping(ip, 10, packetsize=size, timeout=20) if strict_check: - ratio = kvm_test_utils.get_loss_ratio(output) + ratio = virt_test_utils.get_loss_ratio(output) if ratio != 0: raise error.TestFail("Loss ratio is %s for packet size" " %s" % (ratio, size)) @@ -54,14 +54,14 @@ def run_ping(test, params, env): " output: %s" % (status, output)) logging.info("Flood ping test") - kvm_test_utils.ping(ip, None, flood=True, output_func=None, + virt_test_utils.ping(ip, None, flood=True, output_func=None, timeout=flood_minutes * 60) logging.info("Final ping test") - status, output = kvm_test_utils.ping(ip, counts, + status, output = virt_test_utils.ping(ip, counts, timeout=float(counts) * 1.5) if strict_check: - ratio = kvm_test_utils.get_loss_ratio(output) + ratio = virt_test_utils.get_loss_ratio(output) if ratio != 0: raise error.TestFail("Ping failed, status: %s," " output: %s" % (status, output)) diff --git a/client/tests/kvm/tests/pxe.py b/client/tests/kvm/tests/pxe.py index 7c294c1..325e353 100644 --- a/client/tests/kvm/tests/pxe.py +++ b/client/tests/kvm/tests/pxe.py @@ -1,7 +1,6 @@ import logging from autotest_lib.client.common_lib import error -import kvm_subprocess - +from autotest_lib.client.virt import aexpect def run_pxe(test, params, env): """ @@ -20,7 +19,7 @@ def run_pxe(test, params, env): timeout = int(params.get("pxe_timeout", 60)) logging.info("Try to boot from PXE") - output = kvm_subprocess.run_fg("tcpdump -nli %s" % vm.get_ifname(), + output = aexpect.run_fg("tcpdump -nli %s" % vm.get_ifname(), logging.debug, "(pxe capture) ", timeout)[1] logging.info("Analyzing the tcpdump result...") diff --git a/client/tests/kvm/tests/qemu_img.py b/client/tests/kvm/tests/qemu_img.py index c3449f4..a4f63a4 100644 --- a/client/tests/kvm/tests/qemu_img.py +++ b/client/tests/kvm/tests/qemu_img.py @@ -1,6 +1,6 @@ import re, os, logging, commands from autotest_lib.client.common_lib import utils, error -import kvm_vm, kvm_utils, kvm_preprocessing +from autotest_lib.client.virt import virt_vm, virt_utils, virt_env_process def run_qemu_img(test, params, env): @@ -13,12 +13,12 @@ def run_qemu_img(test, params, env): @param params: Dictionary with the test parameters @param env: Dictionary with test environment. """ - cmd = kvm_utils.get_path(test.bindir, params.get("qemu_img_binary")) + cmd = virt_utils.get_path(test.bindir, params.get("qemu_img_binary")) if not os.path.exists(cmd): raise error.TestError("Binary of 'qemu-img' not found") image_format = params.get("image_format") image_size = params.get("image_size", "10G") - image_name = kvm_vm.get_image_filename(params, test.bindir) + image_name = virt_vm.get_image_filename(params, test.bindir) def _check(cmd, img): @@ -49,7 +49,7 @@ def run_qemu_img(test, params, env): @param cmd: qemu-img base command. """ - test_image = kvm_utils.get_path(test.bindir, + test_image = virt_utils.get_path(test.bindir, params.get("image_name_dd")) print "test_image = %s" % test_image create_image_cmd = params.get("create_image_cmd") @@ -105,7 +105,7 @@ def run_qemu_img(test, params, env): @param cmd: qemu-img base command. """ image_large = params.get("image_name_large") - img = kvm_utils.get_path(test.bindir, image_large) + img = virt_utils.get_path(test.bindir, image_large) img += '.' + image_format _create(cmd, img_name=img, fmt=image_format, img_size=params.get("image_size_large")) @@ -288,7 +288,7 @@ def run_qemu_img(test, params, env): # Start a new VM, using backing file as its harddisk vm_name = params.get('main_vm') - kvm_preprocessing.preprocess_vm(test, params, env, vm_name) + virt_env_process.preprocess_vm(test, params, env, vm_name) vm = env.get_vm(vm_name) vm.create() timeout = int(params.get("login_timeout", 360)) @@ -316,7 +316,7 @@ def run_qemu_img(test, params, env): # Second, Start a new VM, using image_name as its harddisk # Here, the commit_testfile should not exist vm_name = params.get('main_vm') - kvm_preprocessing.preprocess_vm(test, params, env, vm_name) + virt_env_process.preprocess_vm(test, params, env, vm_name) vm = env.get_vm(vm_name) vm.create() timeout = int(params.get("login_timeout", 360)) @@ -342,7 +342,7 @@ def run_qemu_img(test, params, env): # Start a new VM, using image_name as its harddisk vm_name = params.get('main_vm') - kvm_preprocessing.preprocess_vm(test, params, env, vm_name) + virt_env_process.preprocess_vm(test, params, env, vm_name) vm = env.get_vm(vm_name) vm.create() timeout = int(params.get("login_timeout", 360)) @@ -401,13 +401,13 @@ def run_qemu_img(test, params, env): " support 'rebase' subcommand") sn_fmt = params.get("snapshot_format", "qcow2") sn1 = params.get("image_name_snapshot1") - sn1 = kvm_utils.get_path(test.bindir, sn1) + ".%s" % sn_fmt - base_img = kvm_vm.get_image_filename(params, test.bindir) + sn1 = virt_utils.get_path(test.bindir, sn1) + ".%s" % sn_fmt + base_img = virt_vm.get_image_filename(params, test.bindir) _create(cmd, sn1, sn_fmt, base_img=base_img, base_img_fmt=image_format) # Create snapshot2 based on snapshot1 sn2 = params.get("image_name_snapshot2") - sn2 = kvm_utils.get_path(test.bindir, sn2) + ".%s" % sn_fmt + sn2 = virt_utils.get_path(test.bindir, sn2) + ".%s" % sn_fmt _create(cmd, sn2, sn_fmt, base_img=sn1, base_img_fmt=sn_fmt) rebase_mode = params.get("rebase_mode") diff --git a/client/tests/kvm/tests/qmp_basic.py b/client/tests/kvm/tests/qmp_basic.py index 9328c61..8e94fe9 100644 --- a/client/tests/kvm/tests/qmp_basic.py +++ b/client/tests/kvm/tests/qmp_basic.py @@ -1,5 +1,5 @@ from autotest_lib.client.common_lib import error -import kvm_test_utils, kvm_monitor +from autotest_lib.client.virt import kvm_monitor def run_qmp_basic(test, params, env): diff --git a/client/tests/kvm/tests/qmp_basic_rhel6.py b/client/tests/kvm/tests/qmp_basic_rhel6.py index 24298b8..2ecad39 100644 --- a/client/tests/kvm/tests/qmp_basic_rhel6.py +++ b/client/tests/kvm/tests/qmp_basic_rhel6.py @@ -1,6 +1,6 @@ import logging from autotest_lib.client.common_lib import error -import kvm_monitor +from autotest_lib.client.virt import kvm_monitor def run_qmp_basic_rhel6(test, params, env): diff --git a/client/tests/kvm/tests/set_link.py b/client/tests/kvm/tests/set_link.py index a4a78ea..94ca30a 100644 --- a/client/tests/kvm/tests/set_link.py +++ b/client/tests/kvm/tests/set_link.py @@ -1,7 +1,7 @@ import logging from autotest_lib.client.common_lib import error from autotest_lib.client.tests.kvm.tests import file_transfer -import kvm_test_utils +from autotest_lib.client.virt import virt_test_utils def run_set_link(test, params, env): @@ -17,9 +17,9 @@ def run_set_link(test, params, env): @param params: Dictionary with the test parameters @param env: Dictionary with test environment. """ - vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) + vm = virt_test_utils.get_living_vm(env, params.get("main_vm")) timeout = float(params.get("login_timeout", 360)) - session = kvm_test_utils.wait_for_login(vm, 0, timeout, 0, 2) + session = virt_test_utils.wait_for_login(vm, 0, timeout, 0, 2) def set_link_test(linkid): """ @@ -30,16 +30,16 @@ def run_set_link(test, params, env): ip = vm.get_address(0) vm.monitor.cmd("set_link %s down" % linkid) - s, o = kvm_test_utils.ping(ip, count=10, timeout=20) - if kvm_test_utils.get_loss_ratio(o) != 100: + s, o = virt_test_utils.ping(ip, count=10, timeout=20) + if virt_test_utils.get_loss_ratio(o) != 100: raise error.TestFail("Still can ping the %s after down %s" % (ip, linkid)) vm.monitor.cmd("set_link %s up" % linkid) - s, o = kvm_test_utils.ping(ip, count=10, timeout=20) + s, o = virt_test_utils.ping(ip, count=10, timeout=20) # we use 100% here as the notification of link status changed may be # delayed in guest driver - if kvm_test_utils.get_loss_ratio(o) == 100: + if virt_test_utils.get_loss_ratio(o) == 100: raise error.TestFail("Packet loss during ping %s after up %s" % (ip, linkid)) diff --git a/client/tests/kvm/tests/shutdown.py b/client/tests/kvm/tests/shutdown.py index fc0407f..ac41a4a 100644 --- a/client/tests/kvm/tests/shutdown.py +++ b/client/tests/kvm/tests/shutdown.py @@ -1,6 +1,6 @@ import logging, time from autotest_lib.client.common_lib import error -import kvm_subprocess, kvm_test_utils, kvm_utils +from autotest_lib.client.virt import virt_utils def run_shutdown(test, params, env): @@ -34,7 +34,7 @@ def run_shutdown(test, params, env): logging.info("system_powerdown monitor command sent; waiting for " "guest to go down...") - if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1): + if not virt_utils.wait_for(vm.is_dead, 240, 0, 1): raise error.TestFail("Guest refuses to go down") logging.info("Guest is down") diff --git a/client/tests/kvm/tests/stepmaker.py b/client/tests/kvm/tests/stepmaker.py index 5a9acdc..0d70c51 100755 --- a/client/tests/kvm/tests/stepmaker.py +++ b/client/tests/kvm/tests/stepmaker.py @@ -10,11 +10,12 @@ Step file creator/editor. import pygtk, gtk, gobject, time, os, commands, logging import common from autotest_lib.client.common_lib import error -import kvm_utils, ppm_utils, stepeditor, kvm_monitor +from autotest_lib.client.virt import virt_utils, ppm_utils, virt_step_editor +from autotest_lib.client.virt import kvm_monitor pygtk.require('2.0') -class StepMaker(stepeditor.StepMakerWindow): +class StepMaker(virt_step_editor.StepMakerWindow): """ Application used to create a step file. It will grab your input to the virtual machine and record it on a 'step file', that can be played @@ -22,7 +23,7 @@ class StepMaker(stepeditor.StepMakerWindow): """ # Constructor def __init__(self, vm, steps_filename, tempdir, params): - stepeditor.StepMakerWindow.__init__(self) + virt_step_editor.StepMakerWindow.__init__(self) self.vm = vm self.steps_filename = steps_filename @@ -87,7 +88,7 @@ class StepMaker(stepeditor.StepMakerWindow): self.vm.monitor.cmd("cont") self.steps_file.close() self.vars_file.close() - stepeditor.StepMakerWindow.destroy(self, widget) + virt_step_editor.StepMakerWindow.destroy(self, widget) # Utilities @@ -347,7 +348,7 @@ def run_stepmaker(test, params, env): steps_filename = params.get("steps") if not steps_filename: raise error.TestError("Steps filename not specified") - steps_filename = kvm_utils.get_path(test.bindir, steps_filename) + steps_filename = virt_utils.get_path(test.bindir, steps_filename) if os.path.exists(steps_filename): raise error.TestError("Steps file %s already exists" % steps_filename) diff --git a/client/tests/kvm/tests/steps.py b/client/tests/kvm/tests/steps.py index 91b864d..cc833fc 100644 --- a/client/tests/kvm/tests/steps.py +++ b/client/tests/kvm/tests/steps.py @@ -6,7 +6,8 @@ Utilities to perform automatic guest installation using step files. import os, time, shutil, logging from autotest_lib.client.common_lib import error -import kvm_utils, ppm_utils, kvm_monitor +from autotest_lib.client.virt import virt_utils, ppm_utils, kvm_monitor + try: import PIL.Image except ImportError: @@ -191,7 +192,7 @@ def run_steps(test, params, env): steps_filename = params.get("steps") if not steps_filename: raise error.TestError("Steps filename not specified") - steps_filename = kvm_utils.get_path(test.bindir, steps_filename) + steps_filename = virt_utils.get_path(test.bindir, steps_filename) if not os.path.exists(steps_filename): raise error.TestError("Steps file not found: %s" % steps_filename) diff --git a/client/tests/kvm/tests/stress_boot.py b/client/tests/kvm/tests/stress_boot.py index 0c422c0..e3ac14d 100644 --- a/client/tests/kvm/tests/stress_boot.py +++ b/client/tests/kvm/tests/stress_boot.py @@ -1,6 +1,6 @@ import logging from autotest_lib.client.common_lib import error -import kvm_preprocessing +from autotest_lib.client.virt import virt_env_process @error.context_aware @@ -35,7 +35,7 @@ def run_stress_boot(test, params, env): vm_params = vm.params.copy() curr_vm = vm.clone(vm_name, vm_params) env.register_vm(vm_name, curr_vm) - kvm_preprocessing.preprocess_vm(test, vm_params, env, vm_name) + virt_env_process.preprocess_vm(test, vm_params, env, vm_name) params["vms"] += " " + vm_name sessions.append(curr_vm.wait_for_login(timeout=login_timeout)) diff --git a/client/tests/kvm/tests/timedrift.py b/client/tests/kvm/tests/timedrift.py index 9f62b4a..123a111 100644 --- a/client/tests/kvm/tests/timedrift.py +++ b/client/tests/kvm/tests/timedrift.py @@ -1,6 +1,6 @@ import logging, time, commands from autotest_lib.client.common_lib import error -import kvm_subprocess, kvm_test_utils +from autotest_lib.client.virt import virt_test_utils, aexpect def run_timedrift(test, params, env): @@ -100,7 +100,7 @@ def run_timedrift(test, params, env): # Get time before load # (ht stands for host time, gt stands for guest time) - (ht0, gt0) = kvm_test_utils.get_time(session, + (ht0, gt0) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) @@ -113,10 +113,10 @@ def run_timedrift(test, params, env): logging.info("Starting load on host...") for i in range(host_load_instances): host_load_sessions.append( - kvm_subprocess.run_bg(host_load_command, - output_func=logging.debug, - output_prefix="(host load %d) " % i, - timeout=0.5)) + aexpect.run_bg(host_load_command, + output_func=logging.debug, + output_prefix="(host load %d) " % i, + timeout=0.5)) # Set the CPU affinity of the load process pid = host_load_sessions[-1].get_pid() set_cpu_affinity(pid, cpu_mask) @@ -126,7 +126,7 @@ def run_timedrift(test, params, env): time.sleep(load_duration) # Get time delta after load - (ht1, gt1) = kvm_test_utils.get_time(session, + (ht1, gt1) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) @@ -157,7 +157,7 @@ def run_timedrift(test, params, env): time.sleep(rest_duration) # Get time after rest - (ht2, gt2) = kvm_test_utils.get_time(session, + (ht2, gt2) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) diff --git a/client/tests/kvm/tests/timedrift_with_migration.py b/client/tests/kvm/tests/timedrift_with_migration.py index b1d4f3e..eb4cb4a 100644 --- a/client/tests/kvm/tests/timedrift_with_migration.py +++ b/client/tests/kvm/tests/timedrift_with_migration.py @@ -1,6 +1,6 @@ import logging from autotest_lib.client.common_lib import error -import kvm_test_utils +from autotest_lib.client.virt import virt_test_utils def run_timedrift_with_migration(test, params, env): @@ -36,13 +36,13 @@ def run_timedrift_with_migration(test, params, env): try: # Get initial time # (ht stands for host time, gt stands for guest time) - (ht0, gt0) = kvm_test_utils.get_time(session, time_command, + (ht0, gt0) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) # Migrate for i in range(migration_iterations): # Get time before current iteration - (ht0_, gt0_) = kvm_test_utils.get_time(session, time_command, + (ht0_, gt0_) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) session.close() # Run current iteration @@ -54,7 +54,7 @@ def run_timedrift_with_migration(test, params, env): session = vm.wait_for_login(timeout=30) logging.info("Logged in after migration") # Get time after current iteration - (ht1_, gt1_) = kvm_test_utils.get_time(session, time_command, + (ht1_, gt1_) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) # Report iteration results host_delta = ht1_ - ht0_ @@ -72,7 +72,7 @@ def run_timedrift_with_migration(test, params, env): "%.2f seconds" % (i + 1, drift)) # Get final time - (ht1, gt1) = kvm_test_utils.get_time(session, time_command, + (ht1, gt1) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) finally: diff --git a/client/tests/kvm/tests/timedrift_with_reboot.py b/client/tests/kvm/tests/timedrift_with_reboot.py index 05ef21f..2562163 100644 --- a/client/tests/kvm/tests/timedrift_with_reboot.py +++ b/client/tests/kvm/tests/timedrift_with_reboot.py @@ -1,6 +1,6 @@ import logging from autotest_lib.client.common_lib import error -import kvm_test_utils +from autotest_lib.client.virt import virt_test_utils def run_timedrift_with_reboot(test, params, env): @@ -36,20 +36,20 @@ def run_timedrift_with_reboot(test, params, env): try: # Get initial time # (ht stands for host time, gt stands for guest time) - (ht0, gt0) = kvm_test_utils.get_time(session, time_command, + (ht0, gt0) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) # Reboot for i in range(reboot_iterations): # Get time before current iteration - (ht0_, gt0_) = kvm_test_utils.get_time(session, time_command, + (ht0_, gt0_) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) # Run current iteration logging.info("Rebooting: iteration %d of %d...", (i + 1), reboot_iterations) session = vm.reboot(session) # Get time after current iteration - (ht1_, gt1_) = kvm_test_utils.get_time(session, time_command, + (ht1_, gt1_) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) # Report iteration results host_delta = ht1_ - ht0_ @@ -67,7 +67,7 @@ def run_timedrift_with_reboot(test, params, env): "%.2f seconds" % (i + 1, drift)) # Get final time - (ht1, gt1) = kvm_test_utils.get_time(session, time_command, + (ht1, gt1) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) finally: diff --git a/client/tests/kvm/tests/timedrift_with_stop.py b/client/tests/kvm/tests/timedrift_with_stop.py index 9f51ff9..c2b0402 100644 --- a/client/tests/kvm/tests/timedrift_with_stop.py +++ b/client/tests/kvm/tests/timedrift_with_stop.py @@ -1,6 +1,6 @@ import logging, time from autotest_lib.client.common_lib import error -import kvm_test_utils +from autotest_lib.client.virt import virt_test_utils def run_timedrift_with_stop(test, params, env): @@ -40,13 +40,13 @@ def run_timedrift_with_stop(test, params, env): try: # Get initial time # (ht stands for host time, gt stands for guest time) - (ht0, gt0) = kvm_test_utils.get_time(session, time_command, + (ht0, gt0) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) # Stop the guest for i in range(stop_iterations): # Get time before current iteration - (ht0_, gt0_) = kvm_test_utils.get_time(session, time_command, + (ht0_, gt0_) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) # Run current iteration logging.info("Stop %s second: iteration %d of %d...", @@ -61,7 +61,7 @@ def run_timedrift_with_stop(test, params, env): time.sleep(sleep_time) # Get time after current iteration - (ht1_, gt1_) = kvm_test_utils.get_time(session, time_command, + (ht1_, gt1_) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) # Report iteration results host_delta = ht1_ - ht0_ @@ -79,7 +79,7 @@ def run_timedrift_with_stop(test, params, env): "%.2f seconds" % (i + 1, drift)) # Get final time - (ht1, gt1) = kvm_test_utils.get_time(session, time_command, + (ht1, gt1) = virt_test_utils.get_time(session, time_command, time_filter_re, time_format) finally: diff --git a/client/tests/kvm/tests/unattended_install.py b/client/tests/kvm/tests/unattended_install.py index 7c6d845..66c123f 100644 --- a/client/tests/kvm/tests/unattended_install.py +++ b/client/tests/kvm/tests/unattended_install.py @@ -1,6 +1,6 @@ import logging, time, socket, re from autotest_lib.client.common_lib import error -import kvm_vm +from autotest_lib.client.virt import virt_vm @error.context_aware @@ -38,7 +38,7 @@ def run_unattended_install(test, params, env): client.connect((vm.get_address(), port)) if client.recv(1024) == "done": break - except (socket.error, kvm_vm.VMAddressError): + except (socket.error, virt_vm.VMAddressError): pass if migrate_background: # Drop the params which may break the migration diff --git a/client/tests/kvm/tests/unittest.py b/client/tests/kvm/tests/unittest.py index 9a126a5..16168fe 100644 --- a/client/tests/kvm/tests/unittest.py +++ b/client/tests/kvm/tests/unittest.py @@ -1,6 +1,6 @@ import logging, os, shutil, glob, ConfigParser from autotest_lib.client.common_lib import error -import kvm_utils, kvm_preprocessing +from autotest_lib.client.virt import virt_utils, virt_env_process def run_unittest(test, params, env): @@ -87,14 +87,14 @@ def run_unittest(test, params, env): try: try: vm_name = params.get('main_vm') - kvm_preprocessing.preprocess_vm(test, params, env, vm_name) + virt_env_process.preprocess_vm(test, params, env, vm_name) vm = env.get_vm(vm_name) vm.create() vm.monitor.cmd("cont") logging.info("Waiting for unittest %s to complete, timeout %s, " "output in %s", t, timeout, vm.get_testlog_filename()) - if not kvm_utils.wait_for(vm.is_dead, timeout): + if not virt_utils.wait_for(vm.is_dead, timeout): raise error.TestFail("Timeout elapsed (%ss)" % timeout) # Check qemu's exit status status = vm.process.get_status() diff --git a/client/tests/kvm/tests/virtio_console.py b/client/tests/kvm/tests/virtio_console.py index bc40837..ee8facf 100644 --- a/client/tests/kvm/tests/virtio_console.py +++ b/client/tests/kvm/tests/virtio_console.py @@ -10,8 +10,8 @@ from threading import Thread from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_subprocess, kvm_test_utils, kvm_utils -import kvm_preprocessing, kvm_monitor +from autotest_lib.client.virt import virt_utils, virt_test_utils, kvm_monitor +from autotest_lib.client.virt import virt_env_process, aexpect def run_virtio_console(test, params, env): @@ -536,7 +536,7 @@ def run_virtio_console(test, params, env): "FAIL:"], timeout) - except (kvm_subprocess.ExpectError): + except (aexpect.ExpectError): match = None data = "Timeout." @@ -674,14 +674,14 @@ def run_virtio_console(test, params, env): Restore old virtual machine when VM is destroyed. """ logging.debug("Booting guest %s", params.get("main_vm")) - kvm_preprocessing.preprocess_vm(test, params, env, + virt_env_process.preprocess_vm(test, params, env, params.get("main_vm")) vm = env.get_vm(params.get("main_vm")) kernel_bug = None try: - session = kvm_test_utils.wait_for_login(vm, 0, + session = virt_test_utils.wait_for_login(vm, 0, float(params.get("boot_timeout", 100)), 0, 2) except (error.TestFail): @@ -694,7 +694,7 @@ def run_virtio_console(test, params, env): if kernel_bug is not None: logging.error(kernel_bug) - sserial = kvm_test_utils.wait_for_login(vm, 0, + sserial = virt_test_utils.wait_for_login(vm, 0, float(params.get("boot_timeout", 20)), 0, 2, serial=True) return [vm, session, sserial] @@ -1183,8 +1183,8 @@ def run_virtio_console(test, params, env): """ # Migrate vm[1].close() - dest_vm = kvm_test_utils.migrate(vm[0], env, 3600, "exec", 0, 0) - vm[1] = kvm_utils.wait_for(dest_vm.remote_login, 30, 0, 2) + dest_vm = virt_test_utils.migrate(vm[0], env, 3600, "exec", 0, 0) + vm[1] = virt_utils.wait_for(dest_vm.remote_login, 30, 0, 2) if not vm[1]: raise error.TestFail("Could not log into guest after migration") logging.info("Logged in after migration") @@ -1451,7 +1451,7 @@ def run_virtio_console(test, params, env): match, tmp = _on_guest("guest_exit()", vm, 10) if (match is None) or (match == 0): vm[1].close() - vm[1] = kvm_test_utils.wait_for_login(vm[0], 0, + vm[1] = virt_test_utils.wait_for_login(vm[0], 0, float(params.get("boot_timeout", 5)), 0, 10) on_guest("killall -9 python " @@ -1462,14 +1462,14 @@ def run_virtio_console(test, params, env): init_guest(vm, consoles) _clean_ports(vm, consoles) - except (error.TestFail, kvm_subprocess.ExpectError, + except (error.TestFail, aexpect.ExpectError, Exception), inst: logging.error(inst) logging.error("Virtio-console driver is irreparably" " blocked. Every comd end with sig KILL." "Try reboot vm for continue in testing.") try: - vm[1] = kvm_test_utils.reboot(vm[0], vm[1], "system_reset") + vm[1] = virt_test_utils.reboot(vm[0], vm[1], "system_reset") except (kvm_monitor.MonitorProtocolError): logging.error("Qemu is blocked. Monitor" " no longer communicate.") diff --git a/client/tests/kvm/tests/vlan.py b/client/tests/kvm/tests/vlan.py index b1864c9..9fc1f64 100644 --- a/client/tests/kvm/tests/vlan.py +++ b/client/tests/kvm/tests/vlan.py @@ -1,6 +1,6 @@ import logging, time, re from autotest_lib.client.common_lib import error -import kvm_test_utils, kvm_utils, kvm_subprocess +from autotest_lib.client.virt import virt_utils, virt_test_utils, aexpect def run_vlan(test, params, env): @@ -53,7 +53,7 @@ def run_vlan(test, params, env): return session.cmd_status(rem_vlan_cmd % (iface, iface)) def nc_transfer(src, dst): - nc_port = kvm_utils.find_free_port(1025, 5334, vm_ip[dst]) + nc_port = virt_utils.find_free_port(1025, 5334, vm_ip[dst]) listen_cmd = params.get("listen_cmd") send_cmd = params.get("send_cmd") @@ -66,7 +66,7 @@ def run_vlan(test, params, env): session[src].cmd(send_cmd, timeout=60) try: session[dst].read_up_to_prompt(timeout=60) - except kvm_subprocess.ExpectError: + except aexpect.ExpectError: raise error.TestFail ("Fail to receive file" " from vm%s to vm%s" % (src+1, dst+1)) #check MD5 message digest of receive file in dst @@ -87,7 +87,7 @@ def run_vlan(test, params, env): raise error.TestError("Could not log into guest(vm%d)" % i) logging.info("Logged in") - ifname.append(kvm_test_utils.get_linux_ifname(session[i], + ifname.append(virt_test_utils.get_linux_ifname(session[i], vm[i].get_mac_address())) #get guest ip vm_ip.append(vm[i].get_address()) @@ -122,7 +122,7 @@ def run_vlan(test, params, env): for i in range(2): interface = ifname[i] + '.' + str(vlan) dest = subnet +'.'+ str(vlan2)+ '.' + ip_unit[(i+1)%2] - s, o = kvm_test_utils.ping(dest, count=2, + s, o = virt_test_utils.ping(dest, count=2, interface=interface, session=session[i], timeout=30) if ((vlan == vlan2) ^ (s == 0)): @@ -134,11 +134,11 @@ def run_vlan(test, params, env): logging.info("Flood ping") def flood_ping(src, dst): - # we must use a dedicated session becuase the kvm_subprocess + # we must use a dedicated session becuase the aexpect # does not have the other method to interrupt the process in # the guest rather than close the session. session_flood = vm[src].wait_for_login(timeout=60) - kvm_test_utils.ping(vlan_ip[dst], flood=True, + virt_test_utils.ping(vlan_ip[dst], flood=True, interface=ifname[src], session=session_flood, timeout=10) session_flood.close() diff --git a/client/tests/kvm/tests/vmstop.py b/client/tests/kvm/tests/vmstop.py index 74ecb23..441ddb9 100644 --- a/client/tests/kvm/tests/vmstop.py +++ b/client/tests/kvm/tests/vmstop.py @@ -1,7 +1,7 @@ import logging, time, os from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils -import kvm_utils +from autotest_lib.client.virt import virt_utils def run_vmstop(test, params, env): @@ -35,8 +35,8 @@ def run_vmstop(test, params, env): utils.run("dd if=/dev/zero of=/tmp/file bs=1M count=%s" % file_size) # Transfer file from host to guest, we didn't expect the finish of # transfer, we just let it to be a kind of stress in guest. - bg = kvm_utils.Thread(vm.copy_files_to, ("/tmp/file", guest_path), - dict(verbose=True, timeout=60)) + bg = virt_utils.Thread(vm.copy_files_to, ("/tmp/file", guest_path), + dict(verbose=True, timeout=60)) logging.info("Start the background transfer") bg.start() diff --git a/client/tests/kvm/tests/whql_client_install.py b/client/tests/kvm/tests/whql_client_install.py index f5d725d..2d72a5e 100644 --- a/client/tests/kvm/tests/whql_client_install.py +++ b/client/tests/kvm/tests/whql_client_install.py @@ -1,6 +1,6 @@ import logging, time, os from autotest_lib.client.common_lib import error -import kvm_test_utils, kvm_utils, rss_file_transfer +from autotest_lib.client.virt import virt_utils, virt_test_utils, rss_client def run_whql_client_install(test, params, env): @@ -37,7 +37,7 @@ def run_whql_client_install(test, params, env): client_password = params.get("client_password") dsso_delete_machine_binary = params.get("dsso_delete_machine_binary", "deps/whql_delete_machine_15.exe") - dsso_delete_machine_binary = kvm_utils.get_path(test.bindir, + dsso_delete_machine_binary = virt_utils.get_path(test.bindir, dsso_delete_machine_binary) install_timeout = float(params.get("install_timeout", 600)) install_cmd = params.get("install_cmd") @@ -45,15 +45,15 @@ def run_whql_client_install(test, params, env): # Stop WTT service(s) on client for svc in wtt_services.split(): - kvm_test_utils.stop_windows_service(session, svc) + virt_test_utils.stop_windows_service(session, svc) # Copy dsso_delete_machine_binary to server - rss_file_transfer.upload(server_address, server_file_transfer_port, + rss_client.upload(server_address, server_file_transfer_port, dsso_delete_machine_binary, server_studio_path, timeout=60) # Open a shell session with server - server_session = kvm_utils.remote_login("nc", server_address, + server_session = virt_utils.remote_login("nc", server_address, server_shell_port, "", "", session.prompt, session.linesep) server_session.set_status_test_command(session.status_test_command) @@ -81,7 +81,7 @@ def run_whql_client_install(test, params, env): server_session.close() # Rename the client machine - client_name = "autotest_%s" % kvm_utils.generate_random_string(4) + client_name = "autotest_%s" % virt_utils.generate_random_string(4) logging.info("Renaming client machine to '%s'", client_name) cmd = ('wmic computersystem where name="%%computername%%" rename name="%s"' % client_name) diff --git a/client/tests/kvm/tests/whql_submission.py b/client/tests/kvm/tests/whql_submission.py index c3621c4..bbeb836 100644 --- a/client/tests/kvm/tests/whql_submission.py +++ b/client/tests/kvm/tests/whql_submission.py @@ -1,6 +1,6 @@ import logging, os, re from autotest_lib.client.common_lib import error -import kvm_subprocess, kvm_utils, rss_file_transfer +from autotest_lib.client.virt import virt_utils, rss_client, aexpect def run_whql_submission(test, params, env): @@ -42,20 +42,20 @@ def run_whql_submission(test, params, env): "Microsoft Driver Test Manager\\Studio") dsso_test_binary = params.get("dsso_test_binary", "deps/whql_submission_15.exe") - dsso_test_binary = kvm_utils.get_path(test.bindir, dsso_test_binary) + dsso_test_binary = virt_utils.get_path(test.bindir, dsso_test_binary) dsso_delete_machine_binary = params.get("dsso_delete_machine_binary", "deps/whql_delete_machine_15.exe") - dsso_delete_machine_binary = kvm_utils.get_path(test.bindir, + dsso_delete_machine_binary = virt_utils.get_path(test.bindir, dsso_delete_machine_binary) test_timeout = float(params.get("test_timeout", 600)) # Copy dsso binaries to the server for filename in dsso_test_binary, dsso_delete_machine_binary: - rss_file_transfer.upload(server_address, server_file_transfer_port, + rss_client.upload(server_address, server_file_transfer_port, filename, server_studio_path, timeout=60) # Open a shell session with the server - server_session = kvm_utils.remote_login("nc", server_address, + server_session = virt_utils.remote_login("nc", server_address, server_shell_port, "", "", sessions[0].prompt, sessions[0].linesep) @@ -74,7 +74,7 @@ def run_whql_submission(test, params, env): server_session.cmd(cmd, print_func=logging.debug) # Reboot the client machines - sessions = kvm_utils.parallel((vm.reboot, (session,)) + sessions = virt_utils.parallel((vm.reboot, (session,)) for vm, session in zip(vms, sessions)) # Check the NICs again @@ -171,7 +171,7 @@ def run_whql_submission(test, params, env): # (test_timeout + 300 is used here because the automation program is # supposed to terminate cleanly on its own when test_timeout expires) done = True - except kvm_subprocess.ExpectError, e: + except aexpect.ExpectError, e: o = e.output done = False server_session.close() @@ -188,17 +188,17 @@ def run_whql_submission(test, params, env): for i, r in enumerate(results): if "report" in r: try: - rss_file_transfer.download(server_address, + rss_client.download(server_address, server_file_transfer_port, r["report"], test.debugdir) - except rss_file_transfer.FileTransferNotFoundError: + except rss_client.FileTransferNotFoundError: pass if "logs" in r: try: - rss_file_transfer.download(server_address, + rss_client.download(server_address, server_file_transfer_port, r["logs"], test.debugdir) - except rss_file_transfer.FileTransferNotFoundError: + except rss_client.FileTransferNotFoundError: pass else: try: @@ -254,7 +254,7 @@ def run_whql_submission(test, params, env): # Kill the client VMs and fail if the automation program did not terminate # on time if not done: - kvm_utils.parallel(vm.destroy for vm in vms) + virt_utils.parallel(vm.destroy for vm in vms) raise error.TestFail("The automation program did not terminate " "on time") -- 1.7.4