Skip to contentSkip to conversation

KVM autotest refactor v2

PATCH New Lucas Meneghel Rodrigues 1 participant 8 messages Mar 30, 2011 KVM

lore
Share & tools
lore
#0 lore raw

cover KVM autotest refactor v2

In order to maximize code reuse among different virtualization technologies, refactor the KVM test code in a way that will allow new implementations of virtualization testing, such as xen testing.

What was done
• Create autotest_lib.client.virt and move the libraries in there, with some renaming and abstracting the KVM specific functions
• Create a dispatcher that can instantiate the appropriate vm class, controlled by a new parameter 'vm_type'
(can be kvm, xen, futurely libvirt...)
• Make all the code use the new libraries
• Remove the 'old' libraries
• Make the KVM test loader to try finding the tests on a common location, and if the test can't be found there, look for it on the kvm subtest dir. This way other virt tests can benefit from thm
• Move the tests that have virt tech agnostic code to the common location

This version incorporates bugfixes and suggestions from reviewers, and hopefully will be very close to what will get upstream. My plan is to shortly freeze the tree until we can get this in.

My private repo was updated to reflect the v2 of the patchset. In order to get what you need, issue:

$ git clone git://github.com/lmr/autotest.git
$ cd autotest
$ git branch refactor

The last command is needed to track the remote branch 'refactor', which contains the actual work.

Lucas Meneghel Rodrigues (7):
KVM test: Create autotest_lib.client.virt namespace KVM test: Move test utilities to client/tools
KVM test: tests_base.cfg: Introduce parameter 'vm_type' KVM test: Adapt the test code to use the new virt namespace KVM test: Removing the old libraries and programs KVM test: Try to load subtests on a shared tests location KVM test: Moving generic tests to common tests area

 client/common_lib/cartesian_config.py              |  698 ++++++++
 client/tests/kvm/build.cfg.sample                  |    1 +
 client/tests/kvm/cd_hash.py                        |   48 -
 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/html_report.py                    | 1727 ------------------
 client/tests/kvm/installer.py                      |  797 ---------
 client/tests/kvm/kvm.py                            |   32 +-
 client/tests/kvm/kvm_config.py                     |  698 --------
 client/tests/kvm/kvm_monitor.py                    |  744 --------
 client/tests/kvm/kvm_preprocessing.py              |  467 -----
 client/tests/kvm/kvm_scheduler.py                  |  229 ---
 client/tests/kvm/kvm_subprocess.py                 | 1351 --------------
 client/tests/kvm/kvm_test_utils.py                 |  753 --------
 client/tests/kvm/kvm_utils.py                      | 1770 -------------------
 client/tests/kvm/kvm_vm.py                         | 1838 --------------------
 client/tests/kvm/migration_control.srv             |   12 +-
 client/tests/kvm/ppm_utils.py                      |  237 ---
 client/tests/kvm/rss_file_transfer.py              |  519 ------
 client/tests/kvm/scan_results.py                   |   97 -
 client/tests/kvm/stepeditor.py                     | 1401 ---------------
 client/tests/kvm/test_setup.py                     |  700 --------
 client/tests/kvm/tests/autotest.py                 |   25 -
 client/tests/kvm/tests/balloon_check.py            |    2 +-
 client/tests/kvm/tests/boot.py                     |   26 -
 client/tests/kvm/tests/boot_savevm.py              |    2 +-
 client/tests/kvm/tests/build.py                    |    6 +-
 client/tests/kvm/tests/clock_getres.py             |   32 -
 client/tests/kvm/tests/enospc.py                   |    4 +-
 client/tests/kvm/tests/ethtool.py                  |  235 ---
 client/tests/kvm/tests/file_transfer.py            |   83 -
 client/tests/kvm/tests/guest_s4.py                 |   76 -
 client/tests/kvm/tests/guest_test.py               |   80 -
 client/tests/kvm/tests/image_copy.py               |   45 -
 client/tests/kvm/tests/iofuzz.py                   |  136 --
 client/tests/kvm/tests/ioquit.py                   |   31 -
 client/tests/kvm/tests/iozone_windows.py           |   40 -
 client/tests/kvm/tests/jumbo.py                    |  127 --
 client/tests/kvm/tests/kdump.py                    |   75 -
 client/tests/kvm/tests/ksm_overcommit.py           |   37 +-
 client/tests/kvm/tests/linux_s3.py                 |   41 -
 client/tests/kvm/tests/mac_change.py               |   60 -
 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                |   90 -
 client/tests/kvm/tests/netperf.py                  |  112 --
 client/tests/kvm/tests/nic_bonding.py              |    8 +-
 client/tests/kvm/tests/nic_hotplug.py              |   24 +-
 client/tests/kvm/tests/nic_promisc.py              |   39 -
 client/tests/kvm/tests/nicdriver_unload.py         |   62 -
 client/tests/kvm/tests/pci_hotplug.py              |   18 +-
 client/tests/kvm/tests/physical_resources_check.py |    2 +-
 client/tests/kvm/tests/ping.py                     |   73 -
 client/tests/kvm/tests/pxe.py                      |   30 -
 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                 |   16 +-
 client/tests/kvm/tests/shutdown.py                 |   43 -
 client/tests/kvm/tests/stepmaker.py                |   11 +-
 client/tests/kvm/tests/steps.py                    |    5 +-
 client/tests/kvm/tests/stress_boot.py              |   53 -
 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           |   16 +-
 client/tests/kvm/tests/vlan.py                     |  175 --
 client/tests/kvm/tests/vmstop.py                   |    6 +-
 client/tests/kvm/tests/whql_client_install.py      |  136 --
 client/tests/kvm/tests/whql_submission.py          |  275 ---
 client/tests/kvm/tests/yum_update.py               |   49 -
 client/tests/kvm/tests_base.cfg.sample             |    1 +
 client/tests/kvm/unittests.cfg.sample              |    1 +
 client/tools/cd_hash.py                            |   48 +
 client/tools/common.py                             |    8 +
 client/tools/html_report.py                        | 1727 ++++++++++++++++++
 client/tools/scan_results.py                       |   97 +
 client/virt/aexpect.py                             | 1352 ++++++++++++++
 client/virt/kvm_installer.py                       |  797 +++++++++
 client/virt/kvm_monitor.py                         |  745 ++++++++
 client/virt/kvm_vm.py                              | 1552 +++++++++++++++++
 client/virt/ppm_utils.py                           |  237 +++
 client/virt/rss_client.py                          |  519 ++++++
 client/virt/tests/autotest.py                      |   25 +
 client/virt/tests/boot.py                          |   26 +
 client/virt/tests/clock_getres.py                  |   32 +
 client/virt/tests/ethtool.py                       |  235 +++
 client/virt/tests/file_transfer.py                 |   84 +
 client/virt/tests/guest_s4.py                      |   76 +
 client/virt/tests/guest_test.py                    |   80 +
 client/virt/tests/image_copy.py                    |   45 +
 client/virt/tests/iofuzz.py                        |  136 ++
 client/virt/tests/ioquit.py                        |   31 +
 client/virt/tests/iozone_windows.py                |   40 +
 client/virt/tests/jumbo.py                         |  127 ++
 client/virt/tests/kdump.py                         |   75 +
 client/virt/tests/linux_s3.py                      |   41 +
 client/virt/tests/mac_change.py                    |   60 +
 client/virt/tests/multicast.py                     |   90 +
 client/virt/tests/netperf.py                       |  111 ++
 client/virt/tests/nic_promisc.py                   |   39 +
 client/virt/tests/nicdriver_unload.py              |   63 +
 client/virt/tests/ping.py                          |   73 +
 client/virt/tests/pxe.py                           |   29 +
 client/virt/tests/shutdown.py                      |   43 +
 client/virt/tests/stress_boot.py                   |   53 +
 client/virt/tests/vlan.py                          |  175 ++
 client/virt/tests/whql_client_install.py           |  136 ++
 client/virt/tests/whql_submission.py               |  275 +++
 client/virt/tests/yum_update.py                    |   49 +
 client/virt/virt_env_process.py                    |  438 +++++
 client/virt/virt_scheduler.py                      |  229 +++
 client/virt/virt_step_editor.py                    | 1401 +++++++++++++++
 client/virt/virt_test_setup.py                     |  700 ++++++++
 client/virt/virt_test_utils.py                     |  754 ++++++++
 client/virt/virt_utils.py                          | 1803 +++++++++++++++++++
 client/virt/virt_vm.py                             |  307 ++++
 124 files changed, 15843 insertions(+), 15796 deletions(-)
 create mode 100755 client/common_lib/cartesian_config.py
 delete mode 100755 client/tests/kvm/cd_hash.py
 delete mode 100755 client/tests/kvm/html_report.py
 delete mode 100644 client/tests/kvm/installer.py
 delete mode 100755 client/tests/kvm/kvm_config.py
 delete mode 100644 client/tests/kvm/kvm_monitor.py
 delete mode 100644 client/tests/kvm/kvm_preprocessing.py
 delete mode 100644 client/tests/kvm/kvm_scheduler.py
 delete mode 100755 client/tests/kvm/kvm_subprocess.py
 delete mode 100644 client/tests/kvm/kvm_test_utils.py
 delete mode 100644 client/tests/kvm/kvm_utils.py
 delete mode 100755 client/tests/kvm/kvm_vm.py
 delete mode 100644 client/tests/kvm/ppm_utils.py
 delete mode 100755 client/tests/kvm/rss_file_transfer.py
 delete mode 100755 client/tests/kvm/scan_results.py
 delete mode 100755 client/tests/kvm/stepeditor.py
 delete mode 100644 client/tests/kvm/test_setup.py
 delete mode 100644 client/tests/kvm/tests/autotest.py
 delete mode 100644 client/tests/kvm/tests/boot.py
 delete mode 100644 client/tests/kvm/tests/clock_getres.py
 delete mode 100644 client/tests/kvm/tests/ethtool.py
 delete mode 100644 client/tests/kvm/tests/file_transfer.py
 delete mode 100644 client/tests/kvm/tests/guest_s4.py
 delete mode 100644 client/tests/kvm/tests/guest_test.py
 delete mode 100644 client/tests/kvm/tests/image_copy.py
 delete mode 100644 client/tests/kvm/tests/iofuzz.py
 delete mode 100644 client/tests/kvm/tests/ioquit.py
 delete mode 100644 client/tests/kvm/tests/iozone_windows.py
 delete mode 100644 client/tests/kvm/tests/jumbo.py
 delete mode 100644 client/tests/kvm/tests/kdump.py
 delete mode 100644 client/tests/kvm/tests/linux_s3.py
 delete mode 100644 client/tests/kvm/tests/mac_change.py
 delete mode 100644 client/tests/kvm/tests/multicast.py
 delete mode 100644 client/tests/kvm/tests/netperf.py
 delete mode 100644 client/tests/kvm/tests/nic_promisc.py
 delete mode 100644 client/tests/kvm/tests/nicdriver_unload.py
 delete mode 100644 client/tests/kvm/tests/ping.py
 delete mode 100644 client/tests/kvm/tests/pxe.py
 delete mode 100644 client/tests/kvm/tests/shutdown.py
 delete mode 100644 client/tests/kvm/tests/stress_boot.py
 delete mode 100644 client/tests/kvm/tests/vlan.py
 delete mode 100644 client/tests/kvm/tests/whql_client_install.py
 delete mode 100644 client/tests/kvm/tests/whql_submission.py
 delete mode 100644 client/tests/kvm/tests/yum_update.py
 create mode 100644 client/tools/__init__.py
 create mode 100755 client/tools/cd_hash.py
 create mode 100644 client/tools/common.py
 create mode 100755 client/tools/html_report.py
 create mode 100755 client/tools/scan_results.py
 create mode 100644 client/virt/__init__.py
 create mode 100755 client/virt/aexpect.py
 create mode 100644 client/virt/kvm_installer.py
 create mode 100644 client/virt/kvm_monitor.py
 create mode 100755 client/virt/kvm_vm.py
 create mode 100644 client/virt/ppm_utils.py
 create mode 100755 client/virt/rss_client.py
 create mode 100644 client/virt/tests/autotest.py
 create mode 100644 client/virt/tests/boot.py
 create mode 100644 client/virt/tests/clock_getres.py
 create mode 100644 client/virt/tests/ethtool.py
 create mode 100644 client/virt/tests/file_transfer.py
 create mode 100644 client/virt/tests/guest_s4.py
 create mode 100644 client/virt/tests/guest_test.py
 create mode 100644 client/virt/tests/image_copy.py
 create mode 100644 client/virt/tests/iofuzz.py
 create mode 100644 client/virt/tests/ioquit.py
 create mode 100644 client/virt/tests/iozone_windows.py
 create mode 100644 client/virt/tests/jumbo.py
 create mode 100644 client/virt/tests/kdump.py
 create mode 100644 client/virt/tests/linux_s3.py
 create mode 100644 client/virt/tests/mac_change.py
 create mode 100644 client/virt/tests/multicast.py
 create mode 100644 client/virt/tests/netperf.py
 create mode 100644 client/virt/tests/nic_promisc.py
 create mode 100644 client/virt/tests/nicdriver_unload.py
 create mode 100644 client/virt/tests/ping.py
 create mode 100644 client/virt/tests/pxe.py
 create mode 100644 client/virt/tests/shutdown.py
 create mode 100644 client/virt/tests/stress_boot.py
 create mode 100644 client/virt/tests/vlan.py
 create mode 100644 client/virt/tests/whql_client_install.py
 create mode 100644 client/virt/tests/whql_submission.py
 create mode 100644 client/virt/tests/yum_update.py
 create mode 100644 client/virt/virt_env_process.py
 create mode 100644 client/virt/virt_scheduler.py
 create mode 100755 client/virt/virt_step_editor.py
 create mode 100644 client/virt/virt_test_setup.py
 create mode 100644 client/virt/virt_test_utils.py
 create mode 100644 client/virt/virt_utils.py
 create mode 100644 client/virt/virt_vm.py
Signature · 6 lines
1.7.4

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
#1 lore raw

PATCH 1/7 KVM test: Create autotest_lib.client.virt namespace

This patch moves all libraries from the KVM test to autotest_lib.client.virt, and makes the needed adaptations and abstracts the KVM implementation from the generic infrastructure. The patch contains bugfixes pointed by Ray Chauvin

---
 client/common_lib/cartesian_config.py |  698 +++++++++++++
 client/virt/aexpect.py                | 1352 ++++++++++++++++++++++++
 client/virt/kvm_installer.py          |  797 +++++++++++++++
 client/virt/kvm_monitor.py            |  745 ++++++++++++++
 client/virt/kvm_vm.py                 | 1552 ++++++++++++++++++++++++++++
 client/virt/ppm_utils.py              |  237 +++++
 client/virt/rss_client.py             |  519 ++++++++++
 client/virt/virt_env_process.py       |  438 ++++++++
 client/virt/virt_scheduler.py         |  229 +++++
 client/virt/virt_step_editor.py       | 1401 +++++++++++++++++++++++++
 client/virt/virt_test_setup.py        |  700 +++++++++++++
 client/virt/virt_test_utils.py        |  754 ++++++++++++++
 client/virt/virt_utils.py             | 1803 +++++++++++++++++++++++++++++++++
 client/virt/virt_vm.py                |  307 ++++++
 14 files changed, 11532 insertions(+), 0 deletions(-)
 create mode 100755 client/common_lib/cartesian_config.py
 create mode 100644 client/virt/__init__.py
 create mode 100755 client/virt/aexpect.py
 create mode 100644 client/virt/kvm_installer.py
 create mode 100644 client/virt/kvm_monitor.py
 create mode 100755 client/virt/kvm_vm.py
 create mode 100644 client/virt/ppm_utils.py
 create mode 100755 client/virt/rss_client.py
 create mode 100644 client/virt/virt_env_process.py
 create mode 100644 client/virt/virt_scheduler.py
 create mode 100755 client/virt/virt_step_editor.py
 create mode 100644 client/virt/virt_test_setup.py
 create mode 100644 client/virt/virt_test_utils.py
 create mode 100644 client/virt/virt_utils.py
 create mode 100644 client/virt/virt_vm.py
client/common_lib/cartesian_config.py new file +698 -0
new file mode 100755
index 0000000..daf45d1
@@ -0,0 +1,698 @@
+#!/usr/bin/python
+"""
+Cartesian configuration format file parser
+
+@copyright: Red Hat 2008-2011
+"""
+
+import re, os, sys, optparse, collections
+
+
+# Filter syntax:
+# , means OR
+# .. means AND
+# . means IMMEDIATELY-FOLLOWED-BY
+
+# Example:
+# qcow2..Fedora.14, RHEL.6..raw..boot, smp2..qcow2..migrate..ide
+# means match all dicts whose names have:
+# (qcow2 AND (Fedora IMMEDIATELY-FOLLOWED-BY 14)) OR
+# ((RHEL IMMEDIATELY-FOLLOWED-BY 6) AND raw AND boot) OR
+# (smp2 AND qcow2 AND migrate AND ide)
+
+# Note:
+# 'qcow2..Fedora.14' is equivalent to 'Fedora.14..qcow2'.
+# 'qcow2..Fedora.14' is not equivalent to 'qcow2..14.Fedora'.
+# 'ide, scsi' is equivalent to 'scsi, ide'.
+
+# Filters can be used in 3 ways:
+# only <filter>
+# no <filter>
+# <filter>:
+# The last one starts a conditional block.
+
+
+class ParserError:
+    def __init__(self, msg, line=None, filename=None, linenum=None):
+        self.msg = msg
+        self.line = line
+        self.filename = filename
+        self.linenum = linenum
+
+    def __str__(self):
+        if self.line:
+            return "%s: %r (%s:%s)" % (self.msg, self.line,
+                                       self.filename, self.linenum)
+        else:
+            return "%s (%s:%s)" % (self.msg, self.filename, self.linenum)
+
+
+num_failed_cases = 5
+
+
+class Node(object):
+    def __init__(self):
+        self.name = []
+        self.dep = []
+        self.content = []
+        self.children = []
+        self.labels = set()
+        self.append_to_shortname = False
+        self.failed_cases = collections.deque()
+
+
+def _match_adjacent(block, ctx, ctx_set):
+    # TODO: explain what this function does
+    if block[0] not in ctx_set:
+        return 0
+    if len(block) == 1:
+        return 1
+    if block[1] not in ctx_set:
+        return int(ctx[-1] == block[0])
+    k = 0
+    i = ctx.index(block[0])
+    while i < len(ctx):
+        if k > 0 and ctx[i] != block[k]:
+            i -= k - 1
+            k = 0
+        if ctx[i] == block[k]:
+            k += 1
+            if k >= len(block):
+                break
+            if block[k] not in ctx_set:
+                break
+        i += 1
+    return k
+
+
+def _might_match_adjacent(block, ctx, ctx_set, descendant_labels):
+    matched = _match_adjacent(block, ctx, ctx_set)
+    for elem in block[matched:]:
+        if elem not in descendant_labels:
+            return False
+    return True
+
+
+# Filter must inherit from object (otherwise type() won't work)
+class Filter(object):
+    def __init__(self, s):
+        self.filter = []
+        for char in s:
+            if not (char.isalnum() or char.isspace() or char in ".,_-"):
+                raise ParserError("Illegal characters in filter")
+        for word in s.replace(",", " ").split():
+            word = [block.split(".") for block in word.split("..")]
+            for block in word:
+                for elem in block:
+                    if not elem:
+                        raise ParserError("Syntax error")
+            self.filter += [word]
+
+
+    def match(self, ctx, ctx_set):
+        for word in self.filter:
+            for block in word:
+                if _match_adjacent(block, ctx, ctx_set) != len(block):
+                    break
+            else:
+                return True
+        return False
+
+
+    def might_match(self, ctx, ctx_set, descendant_labels):
+        for word in self.filter:
+            for block in word:
+                if not _might_match_adjacent(block, ctx, ctx_set,
+                                             descendant_labels):
+                    break
+            else:
+                return True
+        return False
+
+
+class NoOnlyFilter(Filter):
+    def __init__(self, line):
+        Filter.__init__(self, line.split(None, 1)[1])
+        self.line = line
+
+
+class OnlyFilter(NoOnlyFilter):
+    def is_irrelevant(self, ctx, ctx_set, descendant_labels):
+        return self.match(ctx, ctx_set)
+
+
+    def requires_action(self, ctx, ctx_set, descendant_labels):
+        return not self.might_match(ctx, ctx_set, descendant_labels)
+
+
+    def might_pass(self, failed_ctx, failed_ctx_set, ctx, ctx_set,
+                   descendant_labels):
+        for word in self.filter:
+            for block in word:
+                if (_match_adjacent(block, ctx, ctx_set) >
+                    _match_adjacent(block, failed_ctx, failed_ctx_set)):
+                    return self.might_match(ctx, ctx_set, descendant_labels)
+        return False
+
+
+class NoFilter(NoOnlyFilter):
+    def is_irrelevant(self, ctx, ctx_set, descendant_labels):
+        return not self.might_match(ctx, ctx_set, descendant_labels)
+
+
+    def requires_action(self, ctx, ctx_set, descendant_labels):
+        return self.match(ctx, ctx_set)
+
+
+    def might_pass(self, failed_ctx, failed_ctx_set, ctx, ctx_set,
+                   descendant_labels):
+        for word in self.filter:
+            for block in word:
+                if (_match_adjacent(block, ctx, ctx_set) <
+                    _match_adjacent(block, failed_ctx, failed_ctx_set)):
+                    return not self.match(ctx, ctx_set)
+        return False
+
+
+class Condition(NoFilter):
+    def __init__(self, line):
+        Filter.__init__(self, line.rstrip(":"))
+        self.line = line
+        self.content = []
+
+
+class NegativeCondition(OnlyFilter):
+    def __init__(self, line):
+        Filter.__init__(self, line.lstrip("!").rstrip(":"))
+        self.line = line
+        self.content = []
+
+
+class Parser(object):
+    """
+    Parse an input file or string that follows the KVM Test Config File format
+    and generate a list of dicts that will be later used as configuration
+    parameters by the KVM tests.
+
+    @see: http://www.linux-kvm.org/page/KVM-Autotest/Test_Config_File
+    """
+
+    def __init__(self, filename=None, debug=False):
+        """
+        Initialize the parser and optionally parse a file.
+
+        @param filename: Path of the file to parse.
+        @param debug: Whether to turn on debugging output.
+        """
+        self.node = Node()
+        self.debug = debug
+        if filename:
+            self.parse_file(filename)
+
+
+    def parse_file(self, filename):
+        """
+        Parse a file.
+
+        @param filename: Path of the configuration file.
+        """
+        self.node = self._parse(FileReader(filename), self.node)
+
+
+    def parse_string(self, s):
+        """
+        Parse a string.
+
+        @param s: String to parse.
+        """
+        self.node = self._parse(StrReader(s), self.node)
+
+
+    def get_dicts(self, node=None, ctx=[], content=[], shortname=[], dep=[]):
+        """
+        Generate dictionaries from the code parsed so far.  This should
+        be called after parsing something.
+
+        @return: A dict generator.
+        """
+        def process_content(content, failed_filters):
+            # 1. Check that the filters in content are OK with the current
+            #    context (ctx).
+            # 2. Move the parts of content that are still relevant into
+            #    new_content and unpack conditional blocks if appropriate.
+            #    For example, if an 'only' statement fully matches ctx, it
+            #    becomes irrelevant and is not appended to new_content.
+            #    If a conditional block fully matches, its contents are
+            #    unpacked into new_content.
+            # 3. Move failed filters into failed_filters, so that next time we
+            #    reach this node or one of its ancestors, we'll check those
+            #    filters first.
+            for t in content:
+                filename, linenum, obj = t
+                if type(obj) is Op:
+                    new_content.append(t)
+                    continue
+                # obj is an OnlyFilter/NoFilter/Condition/NegativeCondition
+                if obj.requires_action(ctx, ctx_set, labels):
+                    # This filter requires action now
+                    if type(obj) is OnlyFilter or type(obj) is NoFilter:
+                        self._debug("    filter did not pass: %r (%s:%s)",
+                                    obj.line, filename, linenum)
+                        failed_filters.append(t)
+                        return False
+                    else:
+                        self._debug("    conditional block matches: %r (%s:%s)",
+                                    obj.line, filename, linenum)
+                        # Check and unpack the content inside this Condition
+                        # object (note: the failed filters should go into
+                        # new_internal_filters because we don't expect them to
+                        # come from outside this node, even if the Condition
+                        # itself was external)
+                        if not process_content(obj.content,
+                                               new_internal_filters):
+                            failed_filters.append(t)
+                            return False
+                        continue
+                elif obj.is_irrelevant(ctx, ctx_set, labels):
+                    # This filter is no longer relevant and can be removed
+                    continue
+                else:
+                    # Keep the filter and check it again later
+                    new_content.append(t)
+            return True
+
+        def might_pass(failed_ctx,
+                       failed_ctx_set,
+                       failed_external_filters,
+                       failed_internal_filters):
+            for t in failed_external_filters:
+                if t not in content:
+                    return True
+                filename, linenum, filter = t
+                if filter.might_pass(failed_ctx, failed_ctx_set, ctx, ctx_set,
+                                     labels):
+                    return True
+            for t in failed_internal_filters:
+                filename, linenum, filter = t
+                if filter.might_pass(failed_ctx, failed_ctx_set, ctx, ctx_set,
+                                     labels):
+                    return True
+            return False
+
+        def add_failed_case():
+            node.failed_cases.appendleft((ctx, ctx_set,
+                                          new_external_filters,
+                                          new_internal_filters))
+            if len(node.failed_cases) > num_failed_cases:
+                node.failed_cases.pop()
+
+        node = node or self.node
+        # Update dep
+        for d in node.dep:
+            dep = dep + [".".join(ctx + [d])]
+        # Update ctx
+        ctx = ctx + node.name
+        ctx_set = set(ctx)
+        labels = node.labels
+        # Get the current name
+        name = ".".join(ctx)
+        if node.name:
+            self._debug("checking out %r", name)
+        # Check previously failed filters
+        for i, failed_case in enumerate(node.failed_cases):
+            if not might_pass(*failed_case):
+                self._debug("    this subtree has failed before")
+                del node.failed_cases[i]
+                node.failed_cases.appendleft(failed_case)
+                return
+        # Check content and unpack it into new_content
+        new_content = []
+        new_external_filters = []
+        new_internal_filters = []
+        if (not process_content(node.content, new_internal_filters) or
+            not process_content(content, new_external_filters)):
+            add_failed_case()
+            return
+        # Update shortname
+        if node.append_to_shortname:
+            shortname = shortname + node.name
+        # Recurse into children
+        count = 0
+        for n in node.children:
+            for d in self.get_dicts(n, ctx, new_content, shortname, dep):
+                count += 1
+                yield d
+        # Reached leaf?
+        if not node.children:
+            self._debug("    reached leaf, returning it")
+            d = {"name": name, "dep": dep, "shortname": ".".join(shortname)}
+            for filename, linenum, op in new_content:
+                op.apply_to_dict(d)
+            yield d
+        # If this node did not produce any dicts, remember the failed filters
+        # of its descendants
+        elif not count:
+            new_external_filters = []
+            new_internal_filters = []
+            for n in node.children:
+                (failed_ctx,
+                 failed_ctx_set,
+                 failed_external_filters,
+                 failed_internal_filters) = n.failed_cases[0]
+                for obj in failed_internal_filters:
+                    if obj not in new_internal_filters:
+                        new_internal_filters.append(obj)
+                for obj in failed_external_filters:
+                    if obj in content:
+                        if obj not in new_external_filters:
+                            new_external_filters.append(obj)
+                    else:
+                        if obj not in new_internal_filters:
+                            new_internal_filters.append(obj)
+            add_failed_case()
+
+
+    def _debug(self, s, *args):
+        if self.debug:
+            s = "DEBUG: %s" % s
+            print s % args
+
+
+    def _warn(self, s, *args):
+        s = "WARNING: %s" % s
+        print s % args
+
+
+    def _parse_variants(self, cr, node, prev_indent=-1):
+        """
+        Read and parse lines from a FileReader object until a line with an
+        indent level lower than or equal to prev_indent is encountered.
+
+        @param cr: A FileReader/StrReader object.
+        @param node: A node to operate on.
+        @param prev_indent: The indent level of the "parent" block.
+        @return: A node object.
+        """
+        node4 = Node()
+
+        while True:
+            line, indent, linenum = cr.get_next_line(prev_indent)
+            if not line:
+                break
+
+            name, dep = map(str.strip, line.lstrip("- ").split(":", 1))
+            for char in name:
+                if not (char.isalnum() or char in "@._-"):
+                    raise ParserError("Illegal characters in variant name",
+                                      line, cr.filename, linenum)
+            for char in dep:
+                if not (char.isalnum() or char.isspace() or char in ".,_-"):
+                    raise ParserError("Illegal characters in dependencies",
+                                      line, cr.filename, linenum)
+
+            node2 = Node()
+            node2.children = [node]
+            node2.labels = node.labels
+
+            node3 = self._parse(cr, node2, prev_indent=indent)
+            node3.name = name.lstrip("@").split(".")
+            node3.dep = dep.replace(",", " ").split()
+            node3.append_to_shortname = not name.startswith("@")
+
+            node4.children += [node3]
+            node4.labels.update(node3.labels)
+            node4.labels.update(node3.name)
+
+        return node4
+
+
+    def _parse(self, cr, node, prev_indent=-1):
+        """
+        Read and parse lines from a StrReader object until a line with an
+        indent level lower than or equal to prev_indent is encountered.
+
+        @param cr: A FileReader/StrReader object.
+        @param node: A Node or a Condition object to operate on.
+        @param prev_indent: The indent level of the "parent" block.
+        @return: A node object.
+        """
+        while True:
+            line, indent, linenum = cr.get_next_line(prev_indent)
+            if not line:
+                break
+
+            words = line.split(None, 1)
+
+            # Parse 'variants'
+            if line == "variants:":
+                # 'variants' is not allowed inside a conditional block
+                if (isinstance(node, Condition) or
+                    isinstance(node, NegativeCondition)):
+                    raise ParserError("'variants' is not allowed inside a "
+                                      "conditional block",
+                                      None, cr.filename, linenum)
+                node = self._parse_variants(cr, node, prev_indent=indent)
+                continue
+
+            # Parse 'include' statements
+            if words[0] == "include":
+                if len(words) < 2:
+                    raise ParserError("Syntax error: missing parameter",
+                                      line, cr.filename, linenum)
+                filename = os.path.expanduser(words[1])
+                if isinstance(cr, FileReader) and not os.path.isabs(filename):
+                    filename = os.path.join(os.path.dirname(cr.filename),
+                                            filename)
+                if not os.path.isfile(filename):
+                    self._warn("%r (%s:%s): file doesn't exist or is not a "
+                               "regular file", line, cr.filename, linenum)
+                    continue
+                node = self._parse(FileReader(filename), node)
+                continue
+
+            # Parse 'only' and 'no' filters
+            if words[0] in ("only", "no"):
+                if len(words) < 2:
+                    raise ParserError("Syntax error: missing parameter",
+                                      line, cr.filename, linenum)
+                try:
+                    if words[0] == "only":
+                        f = OnlyFilter(line)
+                    elif words[0] == "no":
+                        f = NoFilter(line)
+                except ParserError, e:
+                    e.line = line
+                    e.filename = cr.filename
+                    e.linenum = linenum
+                    raise
+                node.content += [(cr.filename, linenum, f)]
+                continue
+
+            # Look for operators
+            op_match = _ops_exp.search(line)
+
+            # Parse conditional blocks
+            if ":" in line:
+                index = line.index(":")
+                if not op_match or index < op_match.start():
+                    index += 1
+                    cr.set_next_line(line[index:], indent, linenum)
+                    line = line[:index]
+                    try:
+                        if line.startswith("!"):
+                            cond = NegativeCondition(line)
+                        else:
+                            cond = Condition(line)
+                    except ParserError, e:
+                        e.line = line
+                        e.filename = cr.filename
+                        e.linenum = linenum
+                        raise
+                    self._parse(cr, cond, prev_indent=indent)
+                    node.content += [(cr.filename, linenum, cond)]
+                    continue
+
+            # Parse regular operators
+            if not op_match:
+                raise ParserError("Syntax error", line, cr.filename, linenum)
+            node.content += [(cr.filename, linenum, Op(line, op_match))]
+
+        return node
+
+
+# Assignment operators
+
+_reserved_keys = set(("name", "shortname", "dep"))
+
+
+def _op_set(d, key, value):
+    if key not in _reserved_keys:
+        d[key] = value
+
+
+def _op_append(d, key, value):
+    if key not in _reserved_keys:
+        d[key] = d.get(key, "") + value
+
+
+def _op_prepend(d, key, value):
+    if key not in _reserved_keys:
+        d[key] = value + d.get(key, "")
+
+
+def _op_regex_set(d, exp, value):
+    exp = re.compile("%s$" % exp)
+    for key in d:
+        if key not in _reserved_keys and exp.match(key):
+            d[key] = value
+
+
+def _op_regex_append(d, exp, value):
+    exp = re.compile("%s$" % exp)
+    for key in d:
+        if key not in _reserved_keys and exp.match(key):
+            d[key] += value
+
+
+def _op_regex_prepend(d, exp, value):
+    exp = re.compile("%s$" % exp)
+    for key in d:
+        if key not in _reserved_keys and exp.match(key):
+            d[key] = value + d[key]
+
+
+def _op_regex_del(d, empty, exp):
+    exp = re.compile("%s$" % exp)
+    for key in d.keys():
+        if key not in _reserved_keys and exp.match(key):
+            del d[key]
+
+
+_ops = {"=": (r"\=", _op_set),
+        "+=": (r"\+\=", _op_append),
+        "<=": (r"\<\=", _op_prepend),
+        "?=": (r"\?\=", _op_regex_set),
+        "?+=": (r"\?\+\=", _op_regex_append),
+        "?<=": (r"\?\<\=", _op_regex_prepend),
+        "del": (r"^del\b", _op_regex_del)}
+
+_ops_exp = re.compile("|".join([op[0] for op in _ops.values()]))
+
+
+class Op(object):
+    def __init__(self, line, m):
+        self.func = _ops[m.group()][1]
+        self.key = line[:m.start()].strip()
+        value = line[m.end():].strip()
+        if value and (value[0] == value[-1] == '"' or
+                      value[0] == value[-1] == "'"):
+            value = value[1:-1]
+        self.value = value
+
+
+    def apply_to_dict(self, d):
+        self.func(d, self.key, self.value)
+
+
+# StrReader and FileReader
+
+class StrReader(object):
+    """
+    Preprocess an input string for easy reading.
+    """
+    def __init__(self, s):
+        """
+        Initialize the reader.
+
+        @param s: The string to parse.
+        """
+        self.filename = "<string>"
+        self._lines = []
+        self._line_index = 0
+        self._stored_line = None
+        for linenum, line in enumerate(s.splitlines()):
+            line = line.rstrip().expandtabs()
+            stripped_line = line.lstrip()
+            indent = len(line) - len(stripped_line)
+            if (not stripped_line
+                or stripped_line.startswith("#")
+                or stripped_line.startswith("//")):
+                continue
+            self._lines.append((stripped_line, indent, linenum + 1))
+
+
+    def get_next_line(self, prev_indent):
+        """
+        Get the next line in the current block.
+
+        @param prev_indent: The indentation level of the previous block.
+        @return: (line, indent, linenum), where indent is the line's
+            indentation level.  If no line is available, (None, -1, -1) is
+            returned.
+        """
+        if self._stored_line:
+            ret = self._stored_line
+            self._stored_line = None
+            return ret
+        if self._line_index >= len(self._lines):
+            return None, -1, -1
+        line, indent, linenum = self._lines[self._line_index]
+        if indent <= prev_indent:
+            return None, -1, -1
+        self._line_index += 1
+        return line, indent, linenum
+
+
+    def set_next_line(self, line, indent, linenum):
+        """
+        Make the next call to get_next_line() return the given line instead of
+        the real next line.
+        """
+        line = line.strip()
+        if line:
+            self._stored_line = line, indent, linenum
+
+
+class FileReader(StrReader):
+    """
+    Preprocess an input file for easy reading.
+    """
+    def __init__(self, filename):
+        """
+        Initialize the reader.
+
+        @parse filename: The name of the input file.
+        """
+        StrReader.__init__(self, open(filename).read())
+        self.filename = filename
+
+
+if __name__ == "__main__":
+    parser = optparse.OptionParser('usage: %prog [options] filename '
+                                   '[extra code] ...\n\nExample:\n\n    '
+                                   '%prog tests.cfg "only my_set" "no qcow2"')
+    parser.add_option("-v", "--verbose", dest="debug", action="store_true",
+                      help="include debug messages in console output")
+    parser.add_option("-f", "--fullname", dest="fullname", action="store_true",
+                      help="show full dict names instead of short names")
+    parser.add_option("-c", "--contents", dest="contents", action="store_true",
+                      help="show dict contents")
+
+    options, args = parser.parse_args()
+    if not args:
+        parser.error("filename required")
+
+    c = Parser(args[0], debug=options.debug)
+    for s in args[1:]:
+        c.parse_string(s)
+
+    for i, d in enumerate(c.get_dicts()):
+        if options.fullname:
+            print "dict %4d:  %s" % (i + 1, d["name"])
+        else:
+            print "dict %4d:  %s" % (i + 1, d["shortname"])
+        if options.contents:
+            keys = d.keys()
+            keys.sort()
+            for key in keys:
+                print "    %s = %s" % (key, d[key])
client/virt/__init__.py new file +0 -0
new file mode 100644
index 0000000..e69de29
client/virt/aexpect.py new file +1352 -0

1,352 lines not on this page · raw message

client/virt/kvm_installer.py new file +797 -0

797 lines not on this page · raw message

client/virt/kvm_monitor.py new file +745 -0

153 lines not on this page · raw message

client/virt/kvm_vm.py new file +1552 -0

1,552 lines not on this page · raw message

client/virt/ppm_utils.py new file +237 -0

237 lines not on this page · raw message

client/virt/rss_client.py new file +519 -0

519 lines not on this page · raw message

client/virt/virt_env_process.py new file +438 -0

438 lines not on this page · raw message

client/virt/virt_scheduler.py new file +229 -0

229 lines not on this page · raw message

client/virt/virt_step_editor.py new file +1401 -0

1,401 lines not on this page · raw message

client/virt/virt_test_setup.py new file +700 -0

700 lines not on this page · raw message

client/virt/virt_test_utils.py new file +754 -0

754 lines not on this page · raw message

client/virt/virt_utils.py new file +1803 -0

1,803 lines not on this page · raw message

client/virt/virt_vm.py new file +307 -0

307 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.4

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 2/7 KVM test: Move test utilities to client/tools

In reply to Lucas Meneghel Rodrigues

The programs cd_hash, html_report, scan_results can be used by other users of autotest, so move them to the tools directory inside the client directory.

This patch contains bugfixes suggested by Amos Kong.

---
 client/tools/cd_hash.py      |   48 ++
 client/tools/common.py       |    8 +
 client/tools/html_report.py  | 1727 ++++++++++++++++++++++++++++++++++++++++++
 client/tools/scan_results.py |   97 +++
 4 files changed, 1880 insertions(+), 0 deletions(-)
 create mode 100644 client/tools/__init__.py
 create mode 100755 client/tools/cd_hash.py
 create mode 100644 client/tools/common.py
 create mode 100755 client/tools/html_report.py
 create mode 100755 client/tools/scan_results.py
client/tools/__init__.py new file +0 -0
new file mode 100644
index 0000000..e69de29
client/tools/cd_hash.py new file +48 -0

48 lines not on this page · raw message

client/tools/common.py new file +8 -0
new file mode 100644
index 0000000..6881386
@@ -0,0 +1,8 @@
+import os, sys
+dirname = os.path.dirname(sys.modules[__name__].__file__)
+client_dir = os.path.abspath(os.path.join(dirname, ".."))
+sys.path.insert(0, client_dir)
+import setup_modules
+sys.path.pop(0)
+setup_modules.setup(base_path=client_dir,
+                    root_module_name="autotest_lib.client")
client/tools/html_report.py new file +1727 -0

1,727 lines not on this page · raw message

client/tools/scan_results.py new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
1.7.4
#3 lore raw

PATCH 3/7 KVM test: tests_base.cfg: Introduce parameter 'vm_type'

In reply to Lucas Meneghel Rodrigues

In order to allow the shared infrastructure to select the correct vm class to instantiate a VM, introduce the parameter vm_type, which for kvm based VMs is, not surprisingly, 'kvm'.

---
 client/tests/kvm/build.cfg.sample      |    1 +
 client/tests/kvm/tests_base.cfg.sample |    1 +
 client/tests/kvm/unittests.cfg.sample  |    1 +
 3 files changed, 3 insertions(+), 0 deletions(-)
client/tests/kvm/build.cfg.sample +1 -0
index a689ed4..38812f0 100644
@@ -7,6 +7,7 @@
 #    KVM test dir.
 # 2) The appropriate KVM modules are already loaded on your machine.
 
+vm_type = kvm
 variants:
     - build:
         type = build
client/tests/kvm/tests_base.cfg.sample +1 -0
index c3aac44..0543b5e 100644
@@ -2,6 +2,7 @@
 #
 # Define the objects we'll be using
 vms = vm1
+vm_type = kvm
 images = image1
 cdroms = cd1
 nics = nic1
client/tests/kvm/unittests.cfg.sample +1 -0
index 3d32cb2..44f0eee 100644
@@ -2,6 +2,7 @@
 #
 # Define the objects we'll be using
 vms = vm1
+vm_type = kvm
 
 # Choose the main VM
 main_vm = vm1
Signature · 1 line
1.7.4
#4 lore raw

PATCH 4/7 KVM test: Adapt the test code to use the new virt namespace

In reply to 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                   |    4 +-
 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                   |    6 ++--
 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                  |    7 ++--
 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         |    9 +++--
 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           |   16 ++++----
 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, 257 insertions(+), 257 deletions(-)
client/tests/kvm/control +8 -10
index d9ff70c..6437d88 100644
@@ -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)
client/tests/kvm/control.parallel +4 -4
index 640ccf5..966d8bc 100644
@@ -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)])
 
client/tests/kvm/control.unittests +6 -8
index 170c3f8..8f3fc62 100644
@@ -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)
client/tests/kvm/get_started.py +3 -2
index 5ce7349..c0cbdb7 100755
@@ -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.VirtLoggingConfig(),
                                       verbose=True)
     logging.info("KVM test config helper")
 
client/tests/kvm/kvm.py +7 -7
index b88fd51..6981b1b 100644
@@ -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
client/tests/kvm/migration_control.srv +6 -6
index 6b17a26..7c63317 100644
@@ -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)
client/tests/kvm/tests/autotest.py +3 -3
index afc2e3b..cdea31a 100644
@@ -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)
client/tests/kvm/tests/balloon_check.py +1 -1
index 0c2a367..0b7f0f4 100644
@@ -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):
client/tests/kvm/tests/boot_savevm.py +1 -1
index 6af4132..b5da338 100644
@@ -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):
client/tests/kvm/tests/build.py +3 -3
index cbf4aed..cfebcd6 100644
@@ -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
client/tests/kvm/tests/enospc.py +2 -2
index 3c53b64..5f33e4d 100644
@@ -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):
@@ -54,7 +54,7 @@ def run_enospc(test, params, env):
                 image_params = vm.params.object_params(image_name)
                 try:
                     kvm_vm.check_image(image_params, test.bindir)
-                except kvm_vm.VMError, e:
+                except virt_vm.VMError, e:
                     logging.error(e)
             logging.info("Guest paused, extending Logical Volume size")
             try:
client/tests/kvm/tests/ethtool.py +6 -6
index d7c6b57..1152f00 100644
@@ -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()
client/tests/kvm/tests/file_transfer.py +4 -3
index 61982a6..5f6672d 100644
@@ -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)
client/tests/kvm/tests/guest_s4.py +2 -2
index efd8e3b..5b5708d 100644
@@ -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.")
client/tests/kvm/tests/guest_test.py +2 -2
index 95c6f7f..3bc7da7 100644
@@ -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)
client/tests/kvm/tests/image_copy.py +2 -2
index 8a4d74c..cc921ab 100644
@@ -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))
 
client/tests/kvm/tests/iofuzz.py +3 -3
index 7189f91..3d3f4e7 100644
@@ -1,6 +1,6 @@
 import logging, re, random
 from autotest_lib.client.common_lib import error
-import kvm_subprocess
+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)
 
 
client/tests/kvm/tests/jumbo.py +12 -12
index b7f88ae..5108227 100644
@@ -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)
client/tests/kvm/tests/kdump.py +2 -2
index c847131..90c004b 100644
@@ -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)
 
client/tests/kvm/tests/ksm_overcommit.py +19 -18
index 5aba25a..c3b4cad 100644
@@ -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')
client/tests/kvm/tests/mac_change.py +4 -4
index 3fd196f..d2eaf01 100644
@@ -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.")
client/tests/kvm/tests/migration.py +3 -3
index b462e66..2426f3f 100644
@@ -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)
 
client/tests/kvm/tests/migration_with_file_transfer.py +4 -4
index b38defd..25ada82 100644
@@ -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)
client/tests/kvm/tests/migration_with_reboot.py +2 -2
index a15f983..5dddb12 100644
@@ -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():
client/tests/kvm/tests/module_probe.py +2 -2
index 72f239b..b192b6d 100644
@@ -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)
client/tests/kvm/tests/multicast.py +5 -5
index 5dfecbc..13e3f0d 100644
@@ -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))
client/tests/kvm/tests/netperf.py +3 -4
index 5fdd481..5fd1b25 100644
@@ -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, kvm_utils
-
+from autotest_lib.client.virt import aexpect, virt_utils
 
 def run_netperf(test, params, env):
     """
@@ -40,7 +39,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)
@@ -92,7 +91,7 @@ def run_netperf(test, params, env):
         bg = []
         nic_num = len(params.get("nics").split())
         for i in range(nic_num):
-            bg.append(kvm_utils.Thread(netperf, (i,)))
+            bg.append(virt_utils.Thread(netperf, (i,)))
             bg[i].start()
 
         completed = False
client/tests/kvm/tests/nic_bonding.py +3 -3
index 1d53e0e..e998820 100644
@@ -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()
client/tests/kvm/tests/nic_hotplug.py +12 -12
index d44276a..059277e 100644
@@ -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")
client/tests/kvm/tests/nic_promisc.py +3 -3
index ac6f983..0ff07b8 100644
@@ -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():
client/tests/kvm/tests/nicdriver_unload.py +5 -4
index de5fa8b..8296523 100644
@@ -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))
 
     # get ethernet driver from '/sys' directory.
     # ethtool can do the same thing and doesn't care about os type.
@@ -36,12 +36,13 @@ def run_nicdriver_unload(test, params, env):
     readlink_cmd = params.get("readlink_command", "readlink -e")
     driver = os.path.basename(session_serial.cmd("%s %s" % (readlink_cmd,
                                                  sys_path)).strip())
+
     logging.info("driver is %s", driver)
 
     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)
client/tests/kvm/tests/pci_hotplug.py +9 -9
index 0806120..5800fc5 100644
@@ -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))
 
client/tests/kvm/tests/physical_resources_check.py +1 -1
index f9e603c..1ef906f 100644
@@ -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):
client/tests/kvm/tests/ping.py +6 -6
index 8dc4b9e..08791fb 100644
@@ -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))
client/tests/kvm/tests/pxe.py +2 -3
index 7c294c1..325e353 100644
@@ -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...")
client/tests/kvm/tests/qemu_img.py +11 -11
index c3449f4..a4f63a4 100644
@@ -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")
client/tests/kvm/tests/qmp_basic.py +1 -1
index 9328c61..8e94fe9 100644
@@ -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):
client/tests/kvm/tests/qmp_basic_rhel6.py +1 -1
index 24298b8..2ecad39 100644
@@ -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):
client/tests/kvm/tests/set_link.py +7 -7
index a4a78ea..94ca30a 100644
@@ -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))
 
client/tests/kvm/tests/shutdown.py +2 -2
index fc0407f..ac41a4a 100644
@@ -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")
client/tests/kvm/tests/stepmaker.py +6 -5
index 5a9acdc..0d70c51 100755
@@ -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)
 
client/tests/kvm/tests/steps.py +3 -2
index 91b864d..cc833fc 100644
@@ -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)
 
client/tests/kvm/tests/stress_boot.py +2 -2
index 0c422c0..e3ac14d 100644
@@ -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))
client/tests/kvm/tests/timedrift.py +8 -8
index 9f62b4a..123a111 100644
@@ -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)
client/tests/kvm/tests/timedrift_with_migration.py +5 -5
index b1d4f3e..eb4cb4a 100644
@@ -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:
client/tests/kvm/tests/timedrift_with_reboot.py +5 -5
index 05ef21f..2562163 100644
@@ -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:
client/tests/kvm/tests/timedrift_with_stop.py +5 -5
index 9f51ff9..c2b0402 100644
@@ -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:
client/tests/kvm/tests/unattended_install.py +2 -2
index 4868053..73c9aa9 100644
@@ -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
@@ -39,7 +39,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
client/tests/kvm/tests/unittest.py +3 -3
index 9a126a5..16168fe 100644
@@ -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()
client/tests/kvm/tests/virtio_console.py +8 -8
index 9d499bf..c6d2092 100644
@@ -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):
@@ -634,7 +634,7 @@ def run_virtio_console(test, params, env):
                                                                 "FAIL:"],
                                                                timeout)
 
-        except (kvm_subprocess.ExpectError), e:
+        except aexpect.ExpectError, e:
             match = None
             data = "Cmd process timeout. Data in console: " + e.output
 
@@ -772,14 +772,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):
@@ -792,7 +792,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]
@@ -1903,7 +1903,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 "
@@ -1914,7 +1914,7 @@ 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"
client/tests/kvm/tests/vlan.py +7 -7
index b1864c9..9fc1f64 100644
@@ -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()
client/tests/kvm/tests/vmstop.py +3 -3
index 74ecb23..441ddb9 100644
@@ -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()
 
client/tests/kvm/tests/whql_client_install.py +6 -6
index f5d725d..2d72a5e 100644
@@ -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)
client/tests/kvm/tests/whql_submission.py +12 -12
index c3621c4..bbeb836 100644
@@ -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")
 
Signature · 1 line
1.7.4
#5 lore raw

PATCH 5/7 KVM test: Removing the old libraries and programs

In reply to Lucas Meneghel Rodrigues

As they've been replaced by the new virt_namespace, as well as the new program versions moved to tools.

---
 client/tests/kvm/cd_hash.py           |   48 -
 client/tests/kvm/html_report.py       | 1727 -------------------------------
 client/tests/kvm/installer.py         |  797 --------------
 client/tests/kvm/kvm_config.py        |  698 -------------
 client/tests/kvm/kvm_monitor.py       |  744 -------------
 client/tests/kvm/kvm_preprocessing.py |  467 ---------
 client/tests/kvm/kvm_scheduler.py     |  229 ----
 client/tests/kvm/kvm_subprocess.py    | 1351 ------------------------
 client/tests/kvm/kvm_test_utils.py    |  753 --------------
 client/tests/kvm/kvm_utils.py         | 1770 -------------------------------
 client/tests/kvm/kvm_vm.py            | 1838 ---------------------------------
 client/tests/kvm/ppm_utils.py         |  237 -----
 client/tests/kvm/rss_file_transfer.py |  519 ----------
 client/tests/kvm/scan_results.py      |   97 --
 client/tests/kvm/stepeditor.py        | 1401 -------------------------
 client/tests/kvm/test_setup.py        |  700 -------------
 16 files changed, 0 insertions(+), 13376 deletions(-)
 delete mode 100755 client/tests/kvm/cd_hash.py
 delete mode 100755 client/tests/kvm/html_report.py
 delete mode 100644 client/tests/kvm/installer.py
 delete mode 100755 client/tests/kvm/kvm_config.py
 delete mode 100644 client/tests/kvm/kvm_monitor.py
 delete mode 100644 client/tests/kvm/kvm_preprocessing.py
 delete mode 100644 client/tests/kvm/kvm_scheduler.py
 delete mode 100755 client/tests/kvm/kvm_subprocess.py
 delete mode 100644 client/tests/kvm/kvm_test_utils.py
 delete mode 100644 client/tests/kvm/kvm_utils.py
 delete mode 100755 client/tests/kvm/kvm_vm.py
 delete mode 100644 client/tests/kvm/ppm_utils.py
 delete mode 100755 client/tests/kvm/rss_file_transfer.py
 delete mode 100755 client/tests/kvm/scan_results.py
 delete mode 100755 client/tests/kvm/stepeditor.py
 delete mode 100644 client/tests/kvm/test_setup.py
client/tests/kvm/cd_hash.py deleted +0 -48
deleted file mode 100755
index 04f8cbe..0000000
@@ -1,48 +0,0 @@
-#!/usr/bin/python
-"""
-Program that calculates several hashes for a given CD image.
-
-@copyright: Red Hat 2008-2009
-"""
-
-import os, sys, optparse, logging
-import common
-import kvm_utils
-from autotest_lib.client.common_lib import logging_manager
-from autotest_lib.client.bin import utils
-
-
-if __name__ == "__main__":
-    parser = optparse.OptionParser("usage: %prog [options] [filenames]")
-    options, args = parser.parse_args()
-
-    logging_manager.configure_logging(kvm_utils.KvmLoggingConfig())
-
-    if args:
-        filenames = args
-    else:
-        parser.print_help()
-        sys.exit(1)
-
-    for filename in filenames:
-        filename = os.path.abspath(filename)
-
-        file_exists = os.path.isfile(filename)
-        can_read_file = os.access(filename, os.R_OK)
-        if not file_exists:
-            logging.critical("File %s does not exist!", filename)
-            continue
-        if not can_read_file:
-            logging.critical("File %s does not have read permissions!",
-                             filename)
-            continue
-
-        logging.info("Hash values for file %s", os.path.basename(filename))
-        logging.info("md5    (1m): %s", utils.hash_file(filename, 1024*1024,
-                                                        method="md5"))
-        logging.info("sha1   (1m): %s", utils.hash_file(filename, 1024*1024,
-                                                        method="sha1"))
-        logging.info("md5  (full): %s", utils.hash_file(filename, method="md5"))
-        logging.info("sha1 (full): %s", utils.hash_file(filename,
-                                                        method="sha1"))
-        logging.info("")
client/tests/kvm/html_report.py deleted +0 -1727

1,727 lines not on this page · raw message

client/tests/kvm/installer.py deleted +0 -797

797 lines not on this page · raw message

client/tests/kvm/kvm_config.py deleted +0 -698

428 lines not on this page · raw message

client/tests/kvm/kvm_monitor.py deleted +0 -744

744 lines not on this page · raw message

client/tests/kvm/kvm_preprocessing.py deleted +0 -467

467 lines not on this page · raw message

client/tests/kvm/kvm_scheduler.py deleted +0 -229

229 lines not on this page · raw message

client/tests/kvm/kvm_subprocess.py deleted +0 -1351

1,351 lines not on this page · raw message

client/tests/kvm/kvm_test_utils.py deleted +0 -753

753 lines not on this page · raw message

client/tests/kvm/kvm_utils.py deleted +0 -1770

1,770 lines not on this page · raw message

client/tests/kvm/kvm_vm.py deleted +0 -1838

1,838 lines not on this page · raw message

client/tests/kvm/ppm_utils.py deleted +0 -237

237 lines not on this page · raw message

client/tests/kvm/rss_file_transfer.py deleted +0 -519

519 lines not on this page · raw message

client/tests/kvm/scan_results.py deleted +0 -97

97 lines not on this page · raw message

client/tests/kvm/stepeditor.py deleted +0 -1401

1,401 lines not on this page · raw message

client/tests/kvm/test_setup.py deleted +0 -700

700 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.4

Part of the diff is not shown here. View the raw message.

#6 lore raw

PATCH 6/7 KVM test: Try to load subtests on a shared tests location

In reply to Lucas Meneghel Rodrigues

As we have several subtests that can be shared among different virtualization tests (kvm, xen), manipulate kvm.py to try loading subtests from the kvm area (client/tests/kvm/tests) first, then falling back to the specific test area (planned to be client/virt/tests).

Changes from v1:
* Martin Jenner has suggested inverting the lookup order.
Looking first on the specific kvm subtest area *then* common allows people to override the commom implementation of a test that might be better for that particular virt technology.

---
 client/tests/kvm/kvm.py |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
client/tests/kvm/kvm.py +13 -5
index 6981b1b..9717721 100644
@@ -54,11 +54,19 @@ class kvm(test.test):
                     # test type
                     t_type = params.get("type")
                     # Verify if we have the correspondent source file for it
-                    subtest_dir = os.path.join(self.bindir, "tests")
-                    module_path = os.path.join(subtest_dir, "%s.py" % t_type)
-                    if not os.path.isfile(module_path):
-                        raise error.TestError("No %s.py test file found" %
-                                              t_type)
+                    virt_dir = os.path.dirname(virt_utils.__file__)
+                    subtest_dir_virt = os.path.join(virt_dir, "tests")
+                    subtest_dir_kvm = os.path.join(self.bindir, "tests")
+                    subtest_dir = None
+                    for d in [subtest_dir_kvm, subtest_dir_virt]:
+                        module_path = os.path.join(d, "%s.py" % t_type)
+                        if os.path.isfile(module_path):
+                            subtest_dir = d
+                            break
+                    if subtest_dir is None:
+                        raise error.TestError("Could not find test file %s.py "
+                                              "on either %s or %s directory" %
+                                              subtest_dir_kvm, subtest_dir_virt)
                     # Load the test module
                     f, p, d = imp.find_module(t_type, [subtest_dir])
                     test_module = imp.load_module(t_type, f, p, d)
Signature · 1 line
1.7.4
#7 lore raw

PATCH 7/7 KVM test: Moving generic tests to common tests area

In reply to Lucas Meneghel Rodrigues

So other virt tests can benefit from them. The tests that don't depend on any KVM VM specific features (ie, monitors) were moved. As soon as we abstract some of the monitor functionality, the KVM specific tests can be rewritten on a virt tech agnostic way and then be moved.

---
 client/tests/kvm/tests/autotest.py            |   25 ---
 client/tests/kvm/tests/boot.py                |   26 ---
 client/tests/kvm/tests/clock_getres.py        |   32 ---
 client/tests/kvm/tests/ethtool.py             |  235 ---------------------
 client/tests/kvm/tests/file_transfer.py       |   84 --------
 client/tests/kvm/tests/guest_s4.py            |   76 -------
 client/tests/kvm/tests/guest_test.py          |   80 -------
 client/tests/kvm/tests/image_copy.py          |   45 ----
 client/tests/kvm/tests/iofuzz.py              |  136 ------------
 client/tests/kvm/tests/ioquit.py              |   31 ---
 client/tests/kvm/tests/iozone_windows.py      |   40 ----
 client/tests/kvm/tests/jumbo.py               |  127 ------------
 client/tests/kvm/tests/kdump.py               |   75 -------
 client/tests/kvm/tests/linux_s3.py            |   41 ----
 client/tests/kvm/tests/mac_change.py          |   60 ------
 client/tests/kvm/tests/multicast.py           |   90 --------
 client/tests/kvm/tests/netperf.py             |  111 ----------
 client/tests/kvm/tests/nic_bonding.py         |    2 +-
 client/tests/kvm/tests/nic_promisc.py         |   39 ----
 client/tests/kvm/tests/nicdriver_unload.py    |   63 ------
 client/tests/kvm/tests/ping.py                |   73 -------
 client/tests/kvm/tests/pxe.py                 |   29 ---
 client/tests/kvm/tests/set_link.py            |    2 +-
 client/tests/kvm/tests/shutdown.py            |   43 ----
 client/tests/kvm/tests/stress_boot.py         |   53 -----
 client/tests/kvm/tests/vlan.py                |  175 ----------------
 client/tests/kvm/tests/whql_client_install.py |  136 ------------
 client/tests/kvm/tests/whql_submission.py     |  275 -------------------------
 client/tests/kvm/tests/yum_update.py          |   49 -----
 client/virt/tests/autotest.py                 |   25 +++
 client/virt/tests/boot.py                     |   26 +++
 client/virt/tests/clock_getres.py             |   32 +++
 client/virt/tests/ethtool.py                  |  235 +++++++++++++++++++++
 client/virt/tests/file_transfer.py            |   84 ++++++++
 client/virt/tests/guest_s4.py                 |   76 +++++++
 client/virt/tests/guest_test.py               |   80 +++++++
 client/virt/tests/image_copy.py               |   45 ++++
 client/virt/tests/iofuzz.py                   |  136 ++++++++++++
 client/virt/tests/ioquit.py                   |   31 +++
 client/virt/tests/iozone_windows.py           |   40 ++++
 client/virt/tests/jumbo.py                    |  127 ++++++++++++
 client/virt/tests/kdump.py                    |   75 +++++++
 client/virt/tests/linux_s3.py                 |   41 ++++
 client/virt/tests/mac_change.py               |   60 ++++++
 client/virt/tests/multicast.py                |   90 ++++++++
 client/virt/tests/netperf.py                  |  111 ++++++++++
 client/virt/tests/nic_promisc.py              |   39 ++++
 client/virt/tests/nicdriver_unload.py         |   63 ++++++
 client/virt/tests/ping.py                     |   73 +++++++
 client/virt/tests/pxe.py                      |   29 +++
 client/virt/tests/shutdown.py                 |   43 ++++
 client/virt/tests/stress_boot.py              |   53 +++++
 client/virt/tests/vlan.py                     |  175 ++++++++++++++++
 client/virt/tests/whql_client_install.py      |  136 ++++++++++++
 client/virt/tests/whql_submission.py          |  275 +++++++++++++++++++++++++
 client/virt/tests/yum_update.py               |   49 +++++
 56 files changed, 2251 insertions(+), 2251 deletions(-)
 delete mode 100644 client/tests/kvm/tests/autotest.py
 delete mode 100644 client/tests/kvm/tests/boot.py
 delete mode 100644 client/tests/kvm/tests/clock_getres.py
 delete mode 100644 client/tests/kvm/tests/ethtool.py
 delete mode 100644 client/tests/kvm/tests/file_transfer.py
 delete mode 100644 client/tests/kvm/tests/guest_s4.py
 delete mode 100644 client/tests/kvm/tests/guest_test.py
 delete mode 100644 client/tests/kvm/tests/image_copy.py
 delete mode 100644 client/tests/kvm/tests/iofuzz.py
 delete mode 100644 client/tests/kvm/tests/ioquit.py
 delete mode 100644 client/tests/kvm/tests/iozone_windows.py
 delete mode 100644 client/tests/kvm/tests/jumbo.py
 delete mode 100644 client/tests/kvm/tests/kdump.py
 delete mode 100644 client/tests/kvm/tests/linux_s3.py
 delete mode 100644 client/tests/kvm/tests/mac_change.py
 delete mode 100644 client/tests/kvm/tests/multicast.py
 delete mode 100644 client/tests/kvm/tests/netperf.py
 delete mode 100644 client/tests/kvm/tests/nic_promisc.py
 delete mode 100644 client/tests/kvm/tests/nicdriver_unload.py
 delete mode 100644 client/tests/kvm/tests/ping.py
 delete mode 100644 client/tests/kvm/tests/pxe.py
 delete mode 100644 client/tests/kvm/tests/shutdown.py
 delete mode 100644 client/tests/kvm/tests/stress_boot.py
 delete mode 100644 client/tests/kvm/tests/vlan.py
 delete mode 100644 client/tests/kvm/tests/whql_client_install.py
 delete mode 100644 client/tests/kvm/tests/whql_submission.py
 delete mode 100644 client/tests/kvm/tests/yum_update.py
 create mode 100644 client/virt/tests/autotest.py
 create mode 100644 client/virt/tests/boot.py
 create mode 100644 client/virt/tests/clock_getres.py
 create mode 100644 client/virt/tests/ethtool.py
 create mode 100644 client/virt/tests/file_transfer.py
 create mode 100644 client/virt/tests/guest_s4.py
 create mode 100644 client/virt/tests/guest_test.py
 create mode 100644 client/virt/tests/image_copy.py
 create mode 100644 client/virt/tests/iofuzz.py
 create mode 100644 client/virt/tests/ioquit.py
 create mode 100644 client/virt/tests/iozone_windows.py
 create mode 100644 client/virt/tests/jumbo.py
 create mode 100644 client/virt/tests/kdump.py
 create mode 100644 client/virt/tests/linux_s3.py
 create mode 100644 client/virt/tests/mac_change.py
 create mode 100644 client/virt/tests/multicast.py
 create mode 100644 client/virt/tests/netperf.py
 create mode 100644 client/virt/tests/nic_promisc.py
 create mode 100644 client/virt/tests/nicdriver_unload.py
 create mode 100644 client/virt/tests/ping.py
 create mode 100644 client/virt/tests/pxe.py
 create mode 100644 client/virt/tests/shutdown.py
 create mode 100644 client/virt/tests/stress_boot.py
 create mode 100644 client/virt/tests/vlan.py
 create mode 100644 client/virt/tests/whql_client_install.py
 create mode 100644 client/virt/tests/whql_submission.py
 create mode 100644 client/virt/tests/yum_update.py
client/tests/kvm/tests/autotest.py deleted +0 -25
deleted file mode 100644
index cdea31a..0000000
@@ -1,25 +0,0 @@
-import os
-from autotest_lib.client.virt import virt_test_utils
-
-
-def run_autotest(test, params, env):
-    """
-    Run an autotest test inside a guest.
-
-    @param test: kvm test object.
-    @param params: Dictionary with test parameters.
-    @param env: Dictionary with the test environment.
-    """
-    vm = env.get_vm(params["main_vm"])
-    vm.verify_alive()
-    timeout = int(params.get("login_timeout", 360))
-    session = vm.wait_for_login(timeout=timeout)
-
-    # Collect test parameters
-    timeout = int(params.get("test_timeout", 300))
-    control_path = os.path.join(test.bindir, "autotest_control",
-                                params.get("test_control_file"))
-    outputdir = test.outputdir
-
-    virt_test_utils.run_autotest(vm, session, control_path, timeout, outputdir,
-                                 params)
client/tests/kvm/tests/boot.py deleted +0 -26
deleted file mode 100644
index 4fabcd5..0000000
@@ -1,26 +0,0 @@
-import time
-
-
-def run_boot(test, params, env):
-    """
-    KVM reboot test:
-    1) Log into a guest
-    2) Send a reboot command or a system_reset monitor command (optional)
-    3) Wait until the guest is up again
-    4) Log into the guest to verify it's up again
-
-    @param test: kvm test object
-    @param params: Dictionary with the test parameters
-    @param env: Dictionary with test environment.
-    """
-    vm = env.get_vm(params["main_vm"])
-    vm.verify_alive()
-    timeout = float(params.get("login_timeout", 240))
-    session = vm.wait_for_login(timeout=timeout)
-
-    if params.get("reboot_method"):
-        if params["reboot_method"] == "system_reset":
-            time.sleep(int(params.get("sleep_before_reset", 10)))
-        session = vm.reboot(session, params["reboot_method"], 0, timeout)
-
-    session.close()
client/tests/kvm/tests/clock_getres.py deleted +0 -32
deleted file mode 100644
index 9f57c6e..0000000
@@ -1,32 +0,0 @@
-import logging, os
-from autotest_lib.client.common_lib import error
-from autotest_lib.client.bin import utils
-
-
-def run_clock_getres(test, params, env):
-    """
-    Verify if guests using kvm-clock as the time source have a sane clock
-    resolution.
-
-    @param test: kvm test object.
-    @param params: Dictionary with test parameters.
-    @param env: Dictionary with the test environment.
-    """
-    source_name = "test_clock_getres/test_clock_getres.c"
-    source_name = os.path.join(test.bindir, "deps", source_name)
-    dest_name = "/tmp/test_clock_getres.c"
-    bin_name = "/tmp/test_clock_getres"
-
-    if not os.path.isfile(source_name):
-        raise error.TestError("Could not find %s" % source_name)
-
-    vm = env.get_vm(params["main_vm"])
-    vm.verify_alive()
-    timeout = int(params.get("login_timeout", 360))
-    session = vm.wait_for_login(timeout=timeout)
-
-    vm.copy_files_to(source_name, dest_name)
-    session.cmd("gcc -lrt -o %s %s" % (bin_name, dest_name))
-    session.cmd(bin_name)
-    logging.info("PASS: Guest reported appropriate clock resolution")
-    logging.info("Guest's dmesg:\n%s", session.cmd_output("dmesg").strip())
client/tests/kvm/tests/ethtool.py deleted +0 -235

235 lines not on this page · raw message

client/tests/kvm/tests/file_transfer.py deleted +0 -84

84 lines not on this page · raw message

client/tests/kvm/tests/guest_s4.py deleted +0 -76

76 lines not on this page · raw message

client/tests/kvm/tests/guest_test.py deleted +0 -80

80 lines not on this page · raw message

client/tests/kvm/tests/image_copy.py deleted +0 -45

45 lines not on this page · raw message

client/tests/kvm/tests/iofuzz.py deleted +0 -136

136 lines not on this page · raw message

client/tests/kvm/tests/ioquit.py deleted +0 -31
deleted file mode 100644
index 34b4fb5..0000000
@@ -1,31 +0,0 @@
-import logging, time, random
-
-
-def run_ioquit(test, params, env):
-    """
-    Emulate the poweroff under IO workload(dd so far) using kill -9.
-
-    @param test: Kvm test object
-    @param params: Dictionary with the test parameters.
-    @param env: Dictionary with test environment.
-    """
-    vm = env.get_vm(params["main_vm"])
-    vm.verify_alive()
-    login_timeout = int(params.get("login_timeout", 360))
-    session = vm.wait_for_login(timeout=login_timeout)
-    session2 = vm.wait_for_login(timeout=login_timeout)
-    try:
-        bg_cmd = params.get("background_cmd")
-        logging.info("Add IO workload for guest OS.")
-        session.cmd_output(bg_cmd, timeout=60)
-        check_cmd = params.get("check_cmd")
-        session2.cmd(check_cmd, timeout=60)
-
-        logging.info("Sleep for a while")
-        time.sleep(random.randrange(30, 100))
-        session2.cmd(check_cmd, timeout=60)
-        logging.info("Kill the virtual machine")
-        vm.process.close()
-    finally:
-        session.close()
-        session2.close()
client/tests/kvm/tests/iozone_windows.py deleted +0 -40
deleted file mode 100644
index 4046106..0000000
@@ -1,40 +0,0 @@
-import logging, os
-from autotest_lib.client.bin import utils
-from autotest_lib.client.tests.iozone import postprocessing
-
-
-def run_iozone_windows(test, params, env):
-    """
-    Run IOzone for windows on a windows guest:
-    1) Log into a guest
-    2) Execute the IOzone test contained in the winutils.iso
-    3) Get results
-    4) Postprocess it with the IOzone postprocessing module
-
-    @param test: kvm test object
-    @param params: Dictionary with the test parameters
-    @param env: Dictionary with test environment.
-    """
-    vm = env.get_vm(params["main_vm"])
-    vm.verify_alive()
-    timeout = int(params.get("login_timeout", 360))
-    session = vm.wait_for_login(timeout=timeout)
-    results_path = os.path.join(test.resultsdir,
-                                'raw_output_%s' % test.iteration)
-    analysisdir = os.path.join(test.resultsdir, 'analysis_%s' % test.iteration)
-
-    # Run IOzone and record its results
-    c = params.get("iozone_cmd")
-    t = int(params.get("iozone_timeout"))
-    logging.info("Running IOzone command on guest, timeout %ss", t)
-    results = session.cmd_output(cmd=c, timeout=t, print_func=logging.debug)
-    utils.open_write_close(results_path, results)
-
-    # Postprocess the results using the IOzone postprocessing module
-    logging.info("Iteration succeed, postprocessing")
-    a = postprocessing.IOzoneAnalyzer(list_files=[results_path],
-                                      output_dir=analysisdir)
-    a.analyze()
-    p = postprocessing.IOzonePlotter(results_file=results_path,
-                                     output_dir=analysisdir)
-    p.plot_all()
client/tests/kvm/tests/jumbo.py deleted +0 -127

127 lines not on this page · raw message

client/tests/kvm/tests/kdump.py deleted +0 -75

75 lines not on this page · raw message

client/tests/kvm/tests/linux_s3.py deleted +0 -41

41 lines not on this page · raw message

client/tests/kvm/tests/mac_change.py deleted +0 -60

60 lines not on this page · raw message

client/tests/kvm/tests/multicast.py deleted +0 -90

90 lines not on this page · raw message

client/tests/kvm/tests/netperf.py deleted +0 -111

111 lines not on this page · raw message

client/tests/kvm/tests/nic_bonding.py +1 -1
index e998820..d7a26b5 100644
@@ -1,5 +1,5 @@
 import logging, time, threading
-from autotest_lib.client.tests.kvm.tests import file_transfer
+from autotest_lib.client.virt.tests import file_transfer
 from autotest_lib.client.virt import virt_test_utils, virt_utils
 
 
client/tests/kvm/tests/nic_promisc.py deleted +0 -39
deleted file mode 100644
index 0ff07b8..0000000
@@ -1,39 +0,0 @@
-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
-from autotest_lib.client.virt import virt_test_utils, virt_utils
-
-
-def run_nic_promisc(test, params, env):
-    """
-    Test nic driver in promisc mode:
-
-    1) Boot up a VM.
-    2) Repeatedly enable/disable promiscuous mode in guest.
-    3) Transfer file from host to guest, and from guest to host in the same time
-
-    @param test: KVM test object.
-    @param params: Dictionary with the test parameters.
-    @param env: Dictionary with test environment.
-    """
-    vm = env.get_vm(params["main_vm"])
-    vm.verify_alive()
-    timeout = int(params.get("login_timeout", 360))
-    session_serial = vm.wait_for_serial_login(timeout=timeout)
-
-    ethname = virt_test_utils.get_linux_ifname(session_serial,
-                                              vm.get_mac_address(0))
-
-    try:
-        transfer_thread = virt_utils.Thread(file_transfer.run_file_transfer,
-                                           (test, params, env))
-        transfer_thread.start()
-        while transfer_thread.isAlive():
-            session_serial.cmd("ip link set %s promisc on" % ethname)
-            session_serial.cmd("ip link set %s promisc off" % ethname)
-    except:
-        transfer_thread.join(suppress_exception=True)
-        raise
-    else:
-        transfer_thread.join()
client/tests/kvm/tests/nicdriver_unload.py deleted +0 -63

63 lines not on this page · raw message

client/tests/kvm/tests/ping.py deleted +0 -73

73 lines not on this page · raw message

client/tests/kvm/tests/pxe.py deleted +0 -29
deleted file mode 100644
index 325e353..0000000
@@ -1,29 +0,0 @@
-import logging
-from autotest_lib.client.common_lib import error
-from autotest_lib.client.virt import aexpect
-
-def run_pxe(test, params, env):
-    """
-    PXE test:
-
-    1) Snoop the tftp packet in the tap device.
-    2) Wait for some seconds.
-    3) Check whether we could capture TFTP packets.
-
-    @param test: KVM test object.
-    @param params: Dictionary with the test parameters.
-    @param env: Dictionary with test environment.
-    """
-    vm = env.get_vm(params["main_vm"])
-    vm.verify_alive()
-    timeout = int(params.get("pxe_timeout", 60))
-
-    logging.info("Try to boot from PXE")
-    output = aexpect.run_fg("tcpdump -nli %s" % vm.get_ifname(),
-                                   logging.debug, "(pxe capture) ", timeout)[1]
-
-    logging.info("Analyzing the tcpdump result...")
-    if not "tftp" in output:
-        raise error.TestFail("Couldn't find any TFTP packets after %s seconds" %
-                             timeout)
-    logging.info("Found TFTP packet")
client/tests/kvm/tests/set_link.py +1 -1
index 94ca30a..ef34c71 100644
@@ -1,6 +1,6 @@
 import logging
 from autotest_lib.client.common_lib import error
-from autotest_lib.client.tests.kvm.tests import file_transfer
+from autotest_lib.client.virt.tests import file_transfer
 from autotest_lib.client.virt import virt_test_utils
 
 
client/tests/kvm/tests/shutdown.py deleted +0 -43

43 lines not on this page · raw message

client/tests/kvm/tests/stress_boot.py deleted +0 -53

53 lines not on this page · raw message

client/tests/kvm/tests/vlan.py deleted +0 -175

175 lines not on this page · raw message

client/tests/kvm/tests/whql_client_install.py deleted +0 -136

136 lines not on this page · raw message

client/tests/kvm/tests/whql_submission.py deleted +0 -275

275 lines not on this page · raw message

client/tests/kvm/tests/yum_update.py deleted +0 -49

49 lines not on this page · raw message

client/virt/tests/autotest.py new file +25 -0
new file mode 100644
index 0000000..cdea31a
@@ -0,0 +1,25 @@
+import os
+from autotest_lib.client.virt import virt_test_utils
+
+
+def run_autotest(test, params, env):
+    """
+    Run an autotest test inside a guest.
+
+    @param test: kvm test object.
+    @param params: Dictionary with test parameters.
+    @param env: Dictionary with the test environment.
+    """
+    vm = env.get_vm(params["main_vm"])
+    vm.verify_alive()
+    timeout = int(params.get("login_timeout", 360))
+    session = vm.wait_for_login(timeout=timeout)
+
+    # Collect test parameters
+    timeout = int(params.get("test_timeout", 300))
+    control_path = os.path.join(test.bindir, "autotest_control",
+                                params.get("test_control_file"))
+    outputdir = test.outputdir
+
+    virt_test_utils.run_autotest(vm, session, control_path, timeout, outputdir,
+                                 params)
client/virt/tests/boot.py new file +26 -0
new file mode 100644
index 0000000..4fabcd5
@@ -0,0 +1,26 @@
+import time
+
+
+def run_boot(test, params, env):
+    """
+    KVM reboot test:
+    1) Log into a guest
+    2) Send a reboot command or a system_reset monitor command (optional)
+    3) Wait until the guest is up again
+    4) Log into the guest to verify it's up again
+
+    @param test: kvm test object
+    @param params: Dictionary with the test parameters
+    @param env: Dictionary with test environment.
+    """
+    vm = env.get_vm(params["main_vm"])
+    vm.verify_alive()
+    timeout = float(params.get("login_timeout", 240))
+    session = vm.wait_for_login(timeout=timeout)
+
+    if params.get("reboot_method"):
+        if params["reboot_method"] == "system_reset":
+            time.sleep(int(params.get("sleep_before_reset", 10)))
+        session = vm.reboot(session, params["reboot_method"], 0, timeout)
+
+    session.close()
client/virt/tests/clock_getres.py new file +32 -0
new file mode 100644
index 0000000..9f57c6e
@@ -0,0 +1,32 @@
+import logging, os
+from autotest_lib.client.common_lib import error
+from autotest_lib.client.bin import utils
+
+
+def run_clock_getres(test, params, env):
+    """
+    Verify if guests using kvm-clock as the time source have a sane clock
+    resolution.
+
+    @param test: kvm test object.
+    @param params: Dictionary with test parameters.
+    @param env: Dictionary with the test environment.
+    """
+    source_name = "test_clock_getres/test_clock_getres.c"
+    source_name = os.path.join(test.bindir, "deps", source_name)
+    dest_name = "/tmp/test_clock_getres.c"
+    bin_name = "/tmp/test_clock_getres"
+
+    if not os.path.isfile(source_name):
+        raise error.TestError("Could not find %s" % source_name)
+
+    vm = env.get_vm(params["main_vm"])
+    vm.verify_alive()
+    timeout = int(params.get("login_timeout", 360))
+    session = vm.wait_for_login(timeout=timeout)
+
+    vm.copy_files_to(source_name, dest_name)
+    session.cmd("gcc -lrt -o %s %s" % (bin_name, dest_name))
+    session.cmd(bin_name)
+    logging.info("PASS: Guest reported appropriate clock resolution")
+    logging.info("Guest's dmesg:\n%s", session.cmd_output("dmesg").strip())
client/virt/tests/ethtool.py new file +235 -0

235 lines not on this page · raw message

client/virt/tests/file_transfer.py new file +84 -0

84 lines not on this page · raw message

client/virt/tests/guest_s4.py new file +76 -0

76 lines not on this page · raw message

client/virt/tests/guest_test.py new file +80 -0

80 lines not on this page · raw message

client/virt/tests/image_copy.py new file +45 -0

45 lines not on this page · raw message

client/virt/tests/iofuzz.py new file +136 -0

135 lines not on this page · raw message

client/virt/tests/ioquit.py new file +31 -0
new file mode 100644
index 0000000..34b4fb5

Lines of this file are not shown. View the raw message.

client/virt/tests/iozone_windows.py new file +40 -0
new file mode 100644
index 0000000..4046106

Lines of this file are not shown. View the raw message.

client/virt/tests/jumbo.py new file +127 -0

127 lines not on this page · raw message

client/virt/tests/kdump.py new file +75 -0

75 lines not on this page · raw message

client/virt/tests/linux_s3.py new file +41 -0

41 lines not on this page · raw message

client/virt/tests/mac_change.py new file +60 -0

60 lines not on this page · raw message

client/virt/tests/multicast.py new file +90 -0

90 lines not on this page · raw message

client/virt/tests/netperf.py new file +111 -0

111 lines not on this page · raw message

client/virt/tests/nic_promisc.py new file +39 -0
new file mode 100644
index 0000000..0ff07b8

Lines of this file are not shown. View the raw message.

client/virt/tests/nicdriver_unload.py new file +63 -0

63 lines not on this page · raw message

client/virt/tests/ping.py new file +73 -0

73 lines not on this page · raw message

client/virt/tests/pxe.py new file +29 -0
new file mode 100644
index 0000000..325e353

Lines of this file are not shown. View the raw message.

client/virt/tests/shutdown.py new file +43 -0

43 lines not on this page · raw message

client/virt/tests/stress_boot.py new file +53 -0

53 lines not on this page · raw message

client/virt/tests/vlan.py new file +175 -0

175 lines not on this page · raw message

client/virt/tests/whql_client_install.py new file +136 -0

136 lines not on this page · raw message

client/virt/tests/whql_submission.py new file +275 -0

275 lines not on this page · raw message

client/virt/tests/yum_update.py new file +49 -0

49 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.4

Part of the diff is not shown here. View the raw message.