示例#1
0
def run_stress_boot(test, params, env):
    """
    Boots VMs until one of them becomes unresponsive, and records the maximum
    number of VMs successfully started:
    1) boot the first vm
    2) boot the second vm cloned from the first vm, check whether it boots up
       and all booted vms respond to shell commands
    3) go on until cannot create VM anymore or cannot allocate memory for VM

    @param test:   kvm test object
    @param params: Dictionary with the test parameters
    @param env:    Dictionary with test environment.
    """
    error.base_context("waiting for the first guest to be up", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    login_timeout = float(params.get("login_timeout", 240))
    session = vm.wait_for_login(timeout=login_timeout)

    num = 2
    sessions = [session]

    # Boot the VMs
    try:
        while num <= int(params.get("max_vms")):
            # Clone vm according to the first one
            error.base_context("booting guest #%d" % num, logging.info)
            vm_name = "vm%d" % num
            vm_params = vm.params.copy()
            curr_vm = vm.clone(vm_name, vm_params)
            env.register_vm(vm_name, curr_vm)
            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))
            logging.info("Guest #%d booted up successfully", num)

            # Check whether all previous shell sessions are responsive
            for i, se in enumerate(sessions):
                error.context("checking responsiveness of guest #%d" % (i + 1),
                              logging.debug)
                se.cmd(params.get("alive_test_cmd"))
            num += 1
    finally:
        for se in sessions:
            se.close()
        logging.info("Total number booted: %d" % (num - 1))
示例#2
0
def run_stress_boot(test, params, env):
    """
    Boots VMs until one of them becomes unresponsive, and records the maximum
    number of VMs successfully started:
    1) boot the first vm
    2) boot the second vm cloned from the first vm, check whether it boots up
       and all booted vms respond to shell commands
    3) go on until cannot create VM anymore or cannot allocate memory for VM

    @param test:   kvm test object
    @param params: Dictionary with the test parameters
    @param env:    Dictionary with test environment.
    """
    error.base_context("waiting for the first guest to be up", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    login_timeout = float(params.get("login_timeout", 240))
    session = vm.wait_for_login(timeout=login_timeout)

    num = 2
    sessions = [session]

    # Boot the VMs
    try:
        while num <= int(params.get("max_vms")):
            # Clone vm according to the first one
            error.base_context("booting guest #%d" % num, logging.info)
            vm_name = "vm%d" % num
            vm_params = vm.params.copy()
            curr_vm = vm.clone(vm_name, vm_params)
            env.register_vm(vm_name, curr_vm)
            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))
            logging.info("Guest #%d booted up successfully", num)

            # Check whether all previous shell sessions are responsive
            for i, se in enumerate(sessions):
                error.context("checking responsiveness of guest #%d" % (i + 1),
                              logging.debug)
                se.cmd(params.get("alive_test_cmd"))
            num += 1
    finally:
        for se in sessions:
            se.close()
        logging.info("Total number booted: %d" % (num -1))
def run_trans_hugepage_swapping(test, params, env):
    """
    KVM khugepage user side test:
    1) Verify that the hugepages can be swapped in/out.

    @param test: KVM test object.
    @param params: Dictionary with test parameters.
    @param env: Dictionary with the test environment.
    """
    def get_args(args_list):
        """
        Get the memory arguments from system
        """
        args_list_tmp = args_list.copy()
        for line in file('/proc/meminfo', 'r').readlines():
            for key in args_list_tmp.keys():
                if line.startswith("%s" % args_list_tmp[key]):
                    args_list_tmp[key] = int(re.split('\s+', line)[1])
        return args_list_tmp

    test_config = virt_test_setup.TransparentHugePageConfig(test, params)
    try:
        test_config.setup()
        # Swapping test
        logging.info("Swapping test start")
        # Parameters of memory information
        # @total: Memory size
        # @free: Free memory size
        # @swap_size: Swap size
        # @swap_free: Free swap size
        # @hugepage_size: Page size of one hugepage
        # @page_size: The biggest page size that app can ask for
        args_dict_check = {
            "free": "MemFree",
            "swap_size": "SwapTotal",
            "swap_free": "SwapFree",
            "total": "MemTotal",
            "hugepage_size": "Hugepagesize",
        }
        args_dict = get_args(args_dict_check)
        swap_free = []
        total = int(args_dict['total']) / 1024
        free = int(args_dict['free']) / 1024
        swap_size = int(args_dict['swap_size']) / 1024
        swap_free.append(int(args_dict['swap_free']) / 1024)
        hugepage_size = int(args_dict['hugepage_size']) / 1024
        login_timeout = float(params.get("login_timeout", 360))
        check_cmd_timeout = float(params.get("check_cmd_timeout", 900))
        mem_path = os.path.join(test.tmpdir, 'thp_space')

        # If swap is enough fill all memory with dd
        if swap_free > (total - free):
            count = total / hugepage_size
            tmpfs_size = total
        else:
            count = free / hugepage_size
            tmpfs_size = free

        if swap_size <= 0:
            logging.warning("Host does not have swap enabled")
        session = None
        try:
            if not os.path.isdir(mem_path):
                os.makedirs(mem_path)
            utils.run("mount -t tmpfs  -o size=%sM none %s" %
                      (tmpfs_size, mem_path))

            # Set the memory size of vm
            # To ignore the oom killer set it to the free swap size
            vm = env.get_vm(params.get("main_vm"))
            vm.verify_alive()
            if int(params['mem']) > swap_free[0]:
                vm.destroy()
                vm_name = 'vmsw'
                vm0 = params.get("main_vm")
                vm0_key = env.get_vm(vm0)
                params['vms'] = params['vms'] + " " + vm_name
                params['mem'] = str(swap_free[0])
                vm_key = vm0_key.clone(vm0, params)
                virt_utils.env_register_vm(env, vm_name, vm_key)
                virt_env_process.preprocess_vm(test, params, env, vm_name)
                vm_key.create()
                session = vm_key.wait_for_login(timeout=login_timeout)
            else:
                session = vm.wait_for_login(timeout=login_timeout)

            error.context("making guest to swap memory")
            cmd = ("dd if=/dev/zero of=%s/zero bs=%s000000 count=%s" %
                   (mem_path, hugepage_size, count))
            utils.run(cmd)

            args_dict = get_args(args_dict_check)
            swap_free.append(int(args_dict['swap_free']) / 1024)

            if swap_free[1] - swap_free[0] >= 0:
                raise error.TestFail("No data was swapped to memory")

            # Try harder to make guest memory to be swapped
            session.cmd("find / -name \"*\"", timeout=check_cmd_timeout)
        finally:
            if session is not None:
                utils.run("umount %s" % mem_path)

        logging.info("Swapping test succeed")

    finally:
        if session is not None:
            session.close()
        test_config.cleanup()
示例#4
0
def run_smbios_table(test, params, env):
    """
    Check smbios table :
    1) Boot a guest with smbios options
    2) verify if host bios options have been emulated

    @param test: KVM test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    vendor_cmd = "dmidecode --type 0 | grep Vendor | awk '{print $2}'"
    date_cmd = "dmidecode --type 0 | grep Date | awk '{print $3}'"
    version_cmd = "dmidecode --type 0 | grep Version | awk '{print $2}'"

    error.context("getting smbios table on host")
    host_vendor = utils.system_output(vendor_cmd)
    host_date = utils.system_output(date_cmd)
    host_version = utils.system_output(version_cmd)

    smbios = (" -smbios type=0,vendor=%s,version=%s,date=%s" %
              (host_vendor, host_version, host_date))

    extra_params = params.get("extra_params", "")
    params["extra_params"] = extra_params + smbios

    logging.debug("Booting guest %s", params.get("main_vm"))
    virt_env_process.preprocess_vm(test, params, env, params.get("main_vm"))
    vm = env.get_vm(params["main_vm"])
    vm.create()
    login_timeout = float(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=login_timeout)

    error.context("getting smbios table on guest")
    guest_vendor = session.cmd(vendor_cmd).strip()
    guest_date = session.cmd(date_cmd).strip()
    guest_version = session.cmd(version_cmd).strip()

    failures = []

    if host_vendor != guest_vendor:
        e_msg = ("Vendor str mismatch -> host: %s guest: %s" %
                 (guest_vendor, host_vendor))
        logging.error(e_msg)
        failures.append(e_msg)

    if host_date != guest_date:
        e_msg = ("Date str mismatch -> host: %s guest: %s" %
                 (guest_date, host_date))
        logging.error(e_msg)
        failures.append(e_msg)

    if host_version != guest_version:
        e_msg = ("Version str mismatch -> host: %s guest: %s" %
                 (guest_version, host_version))
        logging.error(e_msg)
        failures.append(e_msg)

    error.context("")
    if failures:
        raise error.TestFail("smbios table test reported %s failures:\n%s" %
                             (len(failures), "\n".join(failures)))
示例#5
0
        utils.system(create_cmd)

        info_cmd = "%s info %s.%s" % (qemu_img,image_name,image_format)
        error.context("Image file can not be find")
        results = utils.system_output(info_cmd)
        logging.info("Infocmd output of basefile: %s" ,results)

        # Set the qemu harddisk to the backing file
        logging.info("Original image_name is: %s", params.get('image_name'))
        params['image_name'] = backing_file_name
        logging.info("Param image_name changed to: %s",
                     params.get('image_name'))

        # Start virtual machine, using backing file as its harddisk
        vm_name = params.get('main_vm')
        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))
        session = vm.wait_for_login(timeout=timeout)

        info_cmd = "%s info %s.%s" % (qemu_img, backing_file_name, image_format)
        error.context("Image file can not be find")
        results = utils.system_output(info_cmd)
        logging.info("Infocmd output of backing file before block streaming: "
                     "%s", results)

        if not re.search("backing file:", str(results)):
            raise error.TestFail("Backing file is not available in the "
                                 "backdrive image")
示例#6
0
    def commit_test(cmd):
        """
        Subcommand 'qemu-img commit' test.
        1) Create a backing file of the qemu harddisk specified by image_name.
        2) Start a VM using the backing file as its harddisk.
        3) Touch a file "commit_testfile" in the backing_file, and shutdown the
           VM.
        4) Make sure touching the file does not affect the original harddisk.
        5) Commit the change to the original harddisk by executing
           "qemu-img commit" command.
        6) Start the VM using the original harddisk.
        7) Check if the file "commit_testfile" exists.

        @param cmd: qemu-img base command.
        """
        cmd += " commit"

        logging.info("Commit testing started!")
        image_name = params.get("image_name", "image")
        image_format = params.get("image_format", "qcow2")
        backing_file_name = "%s_bak" % (image_name)

        try:
            # Remove the existing backing file
            backing_file = "%s.%s" % (backing_file_name, image_format)
            if os.path.isfile(backing_file):
                os.remove(backing_file)

            # Create the new backing file
            create_cmd = "qemu-img create -b %s.%s -f %s %s.%s" % (image_name,
                                                                  image_format,
                                                                  image_format,
                                                             backing_file_name,
                                                                  image_format)
            try:
                utils.system(create_cmd)
            except error.CmdError, e:
                raise error.TestFail("Could not create a backing file!")
            logging.info("backing_file created!")

            # Set the qemu harddisk to the backing file
            logging.info("Original image_name is: %s", params.get('image_name'))
            params['image_name'] = backing_file_name
            logging.info("Param image_name changed to: %s",
                         params.get('image_name'))

            # Start a new VM, using backing file as its harddisk
            vm_name = params.get('main_vm')
            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))
            session = vm.wait_for_login(timeout=timeout)

            # Do some changes to the backing_file harddisk
            try:
                output = session.cmd("touch /commit_testfile")
                logging.info("Output of touch /commit_testfile: %s", output)
                output = session.cmd("ls / | grep commit_testfile")
                logging.info("Output of ls / | grep commit_testfile: %s",
                             output)
            except Exception, e:
                raise error.TestFail("Could not create commit_testfile in the "
                                     "backing file %s" % e)
示例#7
0
            except Exception, e:
                raise error.TestFail("Could not create commit_testfile in the "
                                     "backing file %s" % e)
            vm.destroy()

            # Make sure there is no effect on the original harddisk
            # First, set the harddisk back to the original one
            logging.info("Current image_name is: %s", params.get('image_name'))
            params['image_name'] = image_name
            logging.info("Param image_name reverted to: %s",
                         params.get('image_name'))

            # Second, Start a new VM, using image_name as its harddisk
            # Here, the commit_testfile should not exist
            vm_name = params.get('main_vm')
            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))
            session = vm.wait_for_login(timeout=timeout)
            try:
                output = session.cmd("[ ! -e /commit_testfile ] && echo $?")
                logging.info("Output of [ ! -e /commit_testfile ] && echo $?: "
                             "%s", output)
            except Exception:
                output = session.cmd("rm -f /commit_testfile")
                raise error.TestFail("The commit_testfile exists on the "
                                     "original file")
            vm.destroy()

            # Excecute the commit command
def run_trans_hugepage_swapping(test, params, env):
    """
    KVM khugepage user side test:
    1) Verify that the hugepages can be swapped in/out.

    @param test: KVM test object.
    @param params: Dictionary with test parameters.
    @param env: Dictionary with the test environment.
    """
    def get_args(args_list):
        """
        Get the memory arguments from system
        """
        args_list_tmp = args_list.copy()
        for line in file('/proc/meminfo', 'r').readlines():
            for key in args_list_tmp.keys():
                if line.startswith("%s" % args_list_tmp[key]):
                    args_list_tmp[key] = int(re.split('\s+', line)[1])
        return args_list_tmp

    test_config = virt_test_setup.TransparentHugePageConfig(test, params)
    try:
        test_config.setup()
        # Swapping test
        logging.info("Swapping test start")
        # Parameters of memory information
        # @total: Memory size
        # @free: Free memory size
        # @swap_size: Swap size
        # @swap_free: Free swap size
        # @hugepage_size: Page size of one hugepage
        # @page_size: The biggest page size that app can ask for
        args_dict_check = {"free" : "MemFree", "swap_size" : "SwapTotal",
                           "swap_free" : "SwapFree", "total" : "MemTotal",
                           "hugepage_size" : "Hugepagesize",}
        args_dict = get_args(args_dict_check)
        swap_free = []
        total = int(args_dict['total']) / 1024
        free = int(args_dict['free']) / 1024
        swap_size = int(args_dict['swap_size']) / 1024
        swap_free.append(int(args_dict['swap_free'])/1024)
        hugepage_size = int(args_dict['hugepage_size']) / 1024
        login_timeout = float(params.get("login_timeout", 360))
        check_cmd_timeout = float(params.get("check_cmd_timeout", 900))
        mem_path = os.path.join(test.tmpdir, 'thp_space')

        # If swap is enough fill all memory with dd
        if swap_free > (total - free):
            count = total / hugepage_size
            tmpfs_size = total
        else:
            count = free / hugepage_size
            tmpfs_size = free

        if swap_size <= 0:
            logging.warning("Host does not have swap enabled")
        session = None
        try:
            if not os.path.isdir(mem_path):
                os.makedirs(mem_path)
            utils.run("mount -t tmpfs  -o size=%sM none %s" % (tmpfs_size,
                                                               mem_path))

            # Set the memory size of vm
            # To ignore the oom killer set it to the free swap size
            vm = env.get_vm(params.get("main_vm"))
            vm.verify_alive()
            if int(params['mem']) > swap_free[0]:
                vm.destroy()
                vm_name = 'vmsw'
                vm0 =  params.get("main_vm")
                vm0_key = env.get_vm(vm0)
                params['vms'] = params['vms'] + " " + vm_name
                params['mem'] = str(swap_free[0])
                vm_key = vm0_key.clone(vm0, params)
                virt_utils.env_register_vm(env, vm_name, vm_key)
                virt_env_process.preprocess_vm(test, params, env, vm_name)
                vm_key.create()
                session = vm_key.wait_for_login(timeout=login_timeout)
            else:
                session = vm.wait_for_login(timeout=login_timeout)

            error.context("making guest to swap memory")
            cmd = ("dd if=/dev/zero of=%s/zero bs=%s000000 count=%s" %
                   (mem_path, hugepage_size, count))
            utils.run(cmd)

            args_dict = get_args(args_dict_check)
            swap_free.append(int(args_dict['swap_free'])/1024)

            if swap_free[1] - swap_free[0] >= 0:
                raise error.TestFail("No data was swapped to memory")

            # Try harder to make guest memory to be swapped
            session.cmd("find / -name \"*\"", timeout=check_cmd_timeout)
        finally:
            if session is not None:
                utils.run("umount %s" % mem_path)

        logging.info("Swapping test succeed")

    finally:
        if session is not None:
            session.close()
        test_config.cleanup()
示例#9
0
def run_unittest(test, params, env):
    """
    KVM RHEL-6 style unit test:
    1) Resume a stopped VM
    2) Wait for VM to terminate
    3) If qemu exited with code = 0, the unittest passed. Otherwise, it failed
    4) Collect all logs generated

    @param test: kvm test object
    @param params: Dictionary with the test parameters
    @param env: Dictionary with test environment
    """
    unittest_dir = os.path.join(test.bindir, 'unittests')
    if not os.path.isdir(unittest_dir):
        raise error.TestError("No unittest dir %s available (did you run the "
                              "build test first?)" % unittest_dir)
    os.chdir(unittest_dir)
    unittest_list = glob.glob('*.flat')
    if not unittest_list:
        raise error.TestError("No unittest files available (did you run the "
                              "build test first?)")
    logging.debug('Flat file list: %s', unittest_list)

    unittest_cfg = os.path.join(unittest_dir, 'unittests.cfg')
    parser = ConfigParser.ConfigParser()
    parser.read(unittest_cfg)
    test_list = parser.sections()

    if not test_list:
        raise error.TestError("No tests listed on config file %s" %
                              unittest_cfg)
    logging.debug('Unit test list: %s', test_list)

    if params.get('test_list'):
        test_list = params.get('test_list').split()
        logging.info('Original test list overriden by user')
        logging.info('User defined unit test list: %s', test_list)

    nfail = 0
    tests_failed = []

    timeout = int(params.get('unittest_timeout', 600))

    extra_params_original = params['extra_params']

    for t in test_list:
        logging.info('Running %s', t)

        flat_file = None
        if parser.has_option(t, 'file'):
            flat_file = parser.get(t, 'file')

        if flat_file is None:
            nfail += 1
            tests_failed.append(t)
            logging.error('Unittest config file %s has section %s but no '
                          'mandatory option file', unittest_cfg, t)
            continue

        if flat_file not in unittest_list:
            nfail += 1
            tests_failed.append(t)
            logging.error('Unittest file %s referenced in config file %s but '
                          'was not find under the unittest dir', flat_file,
                          unittest_cfg)
            continue

        smp = None
        if parser.has_option(t, 'smp'):
            smp = int(parser.get(t, 'smp'))
            params['smp'] = smp

        extra_params = None
        if parser.has_option(t, 'extra_params'):
            extra_params = parser.get(t, 'extra_params')
            params['extra_params'] += ' %s' % extra_params

        vm_name = params.get("main_vm")
        params['kernel'] = os.path.join(unittest_dir, flat_file)
        testlog_path = os.path.join(test.debugdir, "%s.log" % t)

        try:
            try:
                vm_name = params.get('main_vm')
                virt_env_process.preprocess_vm(test, params, env, vm_name)
                vm = env.get_vm(vm_name)
                vm.create()
                vm.resume()
                logging.info("Waiting for unittest %s to complete, timeout %s, "
                             "output in %s", t, timeout,
                             vm.get_testlog_filename())
                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()
                if status != 0:
                    nfail += 1
                    tests_failed.append(t)
                    logging.error("Unit test %s failed", t)
            except Exception, e:
                nfail += 1
                tests_failed.append(t)
                logging.error('Exception happened during %s: %s', t, str(e))
        finally:
            try:
                shutil.copy(vm.get_testlog_filename(), testlog_path)
                logging.info("Unit test log collected and available under %s",
                             testlog_path)
            except (NameError, IOError):
                logging.error("Not possible to collect logs")

        # Restore the extra params so other tests can run normally
        params['extra_params'] = extra_params_original

    if nfail != 0:
        raise error.TestFail("Unit tests failed: %s" % " ".join(tests_failed))
示例#10
0
    def commit_test(cmd):
        """
        Subcommand 'qemu-img commit' test.
        1) Create a backing file of the qemu harddisk specified by image_name.
        2) Start a VM using the backing file as its harddisk.
        3) Touch a file "commit_testfile" in the backing_file, and shutdown the
           VM.
        4) Make sure touching the file does not affect the original harddisk.
        5) Commit the change to the original harddisk by executing
           "qemu-img commit" command.
        6) Start the VM using the original harddisk.
        7) Check if the file "commit_testfile" exists.

        @param cmd: qemu-img base command.
        """
        cmd += " commit"

        logging.info("Commit testing started!")
        image_name = params.get("image_name", "image")
        image_format = params.get("image_format", "qcow2")
        backing_file_name = "%s_bak" % (image_name)

        try:
            # Remove the existing backing file
            backing_file = "%s.%s" % (backing_file_name, image_format)
            if os.path.isfile(backing_file):
                os.remove(backing_file)

            # Create the new backing file
            create_cmd = "qemu-img create -b %s.%s -f %s %s.%s" % (image_name,
                                                                  image_format,
                                                                  image_format,
                                                             backing_file_name,
                                                                  image_format)
            try:
                utils.system(create_cmd)
            except error.CmdError, e:
                raise error.TestFail("Could not create a backing file!")
            logging.info("backing_file created!")

            # Set the qemu harddisk to the backing file
            logging.info("Original image_name is: %s", params.get('image_name'))
            params['image_name'] = backing_file_name
            logging.info("Param image_name changed to: %s",
                         params.get('image_name'))

            # Start a new VM, using backing file as its harddisk
            vm_name = params.get('main_vm')
            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))
            session = vm.wait_for_login(timeout=timeout)

            # Do some changes to the backing_file harddisk
            try:
                output = session.cmd("touch /commit_testfile")
                logging.info("Output of touch /commit_testfile: %s", output)
                output = session.cmd("ls / | grep commit_testfile")
                logging.info("Output of ls / | grep commit_testfile: %s",
                             output)
            except Exception, e:
                raise error.TestFail("Could not create commit_testfile in the "
                                     "backing file %s" % e)
示例#11
0
def run_time_manage(test, params, env):
    """
    Time manage test:

    1) Generate stress in host.
    2) Run atleast 15 vms with "driftfix=slew" option
    3) Reboot the guest.
    4) Repeat the step 3 for all guests and check whether the guest
       responds properly(not any watchdog reported).
    5) TODO: Improve the way of checking the response and
        run some stress inside guest too.
    6) Continue the step 4 for 10 iterations and
       record the guest/host realtime, calculate drift in time for
       each iterations.
    7) Print the drift values for all sessions
    8) TODO: Validate if the drift value has to be within defined value

    @param test: KVM test object.
    @param params: Dictionary with test parameters.
    @param env: Dictionary with the test environment.
    """
    # Checking the main vm is alive
    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
    login_timeout = float(params.get("login_timeout", 240))
    host_load_command = params.get("host_load_command")
    host_load_kill_command = params.get("host_load_kill_command")
    time_command = params.get("time_command")
    time_filter_re = params.get("time_filter_re")
    time_format = params.get("time_format")

    # Intialize the variables
    itr = 0
    num = 2
    host_load_sessions = []
    sessions = [session]
    prev_time = []
    curr_time = []
    timedrift = []
    totaldrift = []
    vmnames =["vm1"]

    # Run some load on the host
    logging.info("Starting load on host.")
    host_load_sessions.append(aexpect.run_bg(host_load_command,
                                             output_func=logging.debug,
                                             output_prefix="host load ",
                                             timeout=0.5))
    # Boot the VMs
    try:
        while num <= int(params.get("max_vms")):
            # Clone vm according to the first one
            vm_name = "vm%d" % num
            vmnames.append(vm_name)
            vm_params = vm.params.copy()
            curr_vm = vm.clone(vm_name, vm_params)
            env.register_vm(vm_name, curr_vm)
            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))
            logging.info("Guest #%d booted up successfully", num)

            # Check whether all previous shell sessions are responsive
            error.context("checking responsiveness of the booted guest")
            for se in sessions:
                se.cmd(params.get("alive_test_cmd"))
            num += 1

        while itr <= int(params.get("max_itrs")):
            for vmid,se in enumerate(sessions):
                # Get the respective vm object
                vmname = "vm%d" % (vmid +1)
                vm = env.get_vm(vmname)
                # Run current iteration
                logging.info("Rebooting:vm%d iteration %d " % ((vmid + 1), itr))
                se = vm.reboot(se ,timeout=timeout)
                # Remember the current changed session
                sessions[vmid] = se
                error.context("checking responsiveness of guest")
                se.cmd(params.get("alive_test_cmd"))
                if itr == 0:
                    (ht0, gt0) = virt_test_utils.get_time(se, time_command,
                                                   time_filter_re, time_format)
                    prev_time.append((ht0, gt0))
                else:
                    (ht1, gt1) = virt_test_utils.get_time(se, time_command,
                                                   time_filter_re, time_format)
                    curr_time.append((ht1, gt1))
            if itr != 0:
                for i in range(int(params.get("max_vms"))):
                    hdelta = curr_time[i][0] - prev_time[i][0]
                    gdelta = curr_time[i][1] - prev_time[i][1]
                    drift = format( 100.0 * (hdelta - gdelta) / hdelta, ".2f" )
                    timedrift.append(drift)
                totaldrift.append(timedrift)
                prev_time = curr_time
                timedrift = []
                curr_time = []
            # Wait for some time before next iteration
            time.sleep(30)
            itr += 1

        logging.info("The time drift values for all VM sessions/iterations")
        logging.info("VM-Name:%s" % vmnames)
        for idx,value in enumerate(totaldrift):
            logging.info("itr-%2d:%s" % (idx+1,value))

    finally:
        for se in sessions:
            # Closing all the sessions.
            se.close()
        logging.info("killing load on host.")
        host_load_sessions.append(aexpect.run_bg(host_load_kill_command,
                                                 output_func=logging.debug,
                                                 output_prefix="host load kill",
                                                 timeout=0.5))