• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python env_process.preprocess_vm函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中virttest.env_process.preprocess_vm函数的典型用法代码示例。如果您正苦于以下问题:Python preprocess_vm函数的具体用法?Python preprocess_vm怎么用?Python preprocess_vm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了preprocess_vm函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_guest_cpuid

    def get_guest_cpuid(self, cpu_model, feature=None, extra_params=None, qom_mode=False):
        if not qom_mode:
            test_kernel_dir = os.path.join(data_dir.get_deps_dir(), "cpuid", "src")
            os.chdir(test_kernel_dir)
            utils.make("cpuid_dump_kernel.bin")

        vm_name = params['main_vm']
        params_b = params.copy()
        if not qom_mode:
            params_b["kernel"] = os.path.join(
                test_kernel_dir, "cpuid_dump_kernel.bin")
        params_b["cpu_model"] = cpu_model
        params_b["cpu_model_flags"] = feature
        del params_b["images"]
        del params_b["nics"]
        if extra_params:
            params_b.update(extra_params)
        env_process.preprocess_vm(self, params_b, env, vm_name)
        vm = env.get_vm(vm_name)
        dbg('is dead: %r', vm.is_dead())
        vm.create()
        self.vm = vm
        if qom_mode:
            return get_qom_cpuid(self, vm)
        else:
            return get_test_kernel_cpuid(self, vm)
开发者ID:Zhengtong,项目名称:tp-qemu,代码行数:26,代码来源:cpuid.py


示例2: run

def run(test, params, env):
    """
    Qemu guest pxe boot test:
    1). check npt/ept function enable, then boot vm
    2). execute query/info cpus in loop
    3). verify vm not paused during pxe booting

    params:
    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    restore_mmu_cmd = None
    pxe_timeout = int(params.get("pxe_timeout", 60))

    error_context.context("Enable ept/npt", logging.info)
    try:
        flag = list(filter(lambda x: x in utils_misc.get_cpu_flags(),
                           ['ept', 'npt']))[0]
    except IndexError:
        logging.info("Host doesn't support ept/npt, skip the configuration")
    else:
        enable_mmu_cmd = params["enable_mmu_cmd_%s" % flag]
        check_mmu_cmd = params["check_mmu_cmd_%s" % flag]
        restore_mmu_cmd = params["restore_mmu_cmd_%s" % flag]
        status = process.system(check_mmu_cmd, timeout=120, ignore_status=True,
                                shell=True)
        if status != 0:
            _kill_vms(params, env)
            process.run(enable_mmu_cmd, shell=True)

    params["start_vm"] = "yes"
    params["kvm_vm"] = "yes"
    params["paused_after_start_vm"] = "yes"

    error_context.context("Try to boot from NIC", logging.info)
    env_process.preprocess_vm(test, params, env, params["main_vm"])
    vm = env.get_vm(params["main_vm"])
    bg = utils_misc.InterruptedThread(_capture_tftp, (test, vm, pxe_timeout))

    count = 0
    try:
        bg.start()
        error_context.context("Query cpus in loop", logging.info)
        vm.resume()
        while True:
            count += 1
            try:
                vm.monitor.info("cpus")
                vm.verify_status("running")
                if not bg.is_alive():
                    break
            except qemu_monitor.MonitorSocketError:
                test.fail("Qemu looks abnormally, please read the log")
        logging.info("Execute info/query cpus %d times", count)
    finally:
        bg.join()
        if restore_mmu_cmd:
            _kill_vms(params, env)
            process.run(restore_mmu_cmd, shell=True)
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:60,代码来源:pxe_query_cpus.py


示例3: get_guest_cpuid

    def get_guest_cpuid(self, cpu_model, feature=None, extra_params=None):
        test_kernel_dir = os.path.join(data_dir.get_deps_dir(), "cpuid", "src")
        os.chdir(test_kernel_dir)
        utils.make("cpuid_dump_kernel.bin")

        vm_name = params['main_vm']
        params_b = params.copy()
        params_b["kernel"] = os.path.join(
            test_kernel_dir, "cpuid_dump_kernel.bin")
        params_b["cpu_model"] = cpu_model
        params_b["cpu_model_flags"] = feature
        del params_b["images"]
        del params_b["nics"]
        if extra_params:
            params_b.update(extra_params)
        env_process.preprocess_vm(self, params_b, env, vm_name)
        vm = env.get_vm(vm_name)
        dbg('is dead: %r', vm.is_dead())
        vm.create()
        self.vm = vm
        vm.resume()

        timeout = float(params.get("login_timeout", 240))
        f = lambda: re.search("==END TEST==", vm.serial_console.get_output())
        if not utils_misc.wait_for(f, timeout, 1):
            raise error.TestFail("Could not get test complete message.")

        test_output = parse_cpuid_dump(vm.serial_console.get_output())
        if test_output is None:
            raise error.TestFail("Test output signature not found in "
                                 "output:\n %s", vm.serial_console.get_output())
        vm.destroy(gracefully=False)
        return test_output
开发者ID:QiuMike,项目名称:tp-qemu,代码行数:33,代码来源:cpuid.py


示例4: run_valgrind_memalign

def run_valgrind_memalign(test, params, env):
    """
    This case is from [general operation] Work around valgrind choking on our
    use of memalign():
    1.download valgrind form valgrind download page: www.valgrind.org.
    2.install the valgrind in host.
    3.run # valgrind /usr/libexec/qemu-kvm  -vnc :0 -S -m 384 -monitor stdio
    4.check the status and do continue the VM.
    5.quit the VM.

    @param test: QEMU test object
    @param params: Dictionary with the test parameters
    @param env: Dictionary with test environment
    """
    interval = float(params.get("interval_time", "10"))
    def valgrind_intall():
        valgrind_install_cmd = params.get("valgrind_install_cmd")
        s = utils.system(valgrind_install_cmd, timeout=3600)
        if s != 0:
            raise error.TestError("Fail to install valgrind")
        else:
            logging.info("Install valgrind successfully.")

    valgring_support_check_cmd = params.get("valgring_support_check_cmd")
    try:
        utils.system(valgring_support_check_cmd,timeout=interval)
    except Exception:
        valgrind_intall()

    params["start_vm"] = "yes"
    env_process.preprocess_vm(test, params, env, params.get("main_vm"))
    vm = env.get_vm(params["main_vm"])

    time.sleep(interval)
    vm.verify_status("running")
开发者ID:FengYang,项目名称:virt-test,代码行数:35,代码来源:valgrind_memalign.py


示例5: run

def run(test, params, env):
    """
    Qemu invalid parameter in qemu command line test:
    1) Try boot up guest with invalid parameters
    2) Catch the error message shows by qemu process

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    vm_name = params["main_vm"]
    params['start_vm'] = "yes"
    try:
        error_context.context("Start guest with invalid parameters.")
        env_process.preprocess_vm(test, params, env, vm_name)
        vm = env.get_vm(vm_name)
        vm.destroy()
    except Exception as emsg:
        error_context.context("Check guest exit status.")
        if "(core dumped)" in str(emsg):
            test.fail("Guest core dumped with invalid parameters.")
        else:
            logging.info("Guest quit as expect: %s" % str(emsg))
            return

    test.fail("Guest start normally, didn't quit as expect.")
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:26,代码来源:invalid_parameter.py


示例6: start

    def start(self):
        """
        Start mlock basic test
        """
        error_context.context("Get nr_mlock and nr_unevictable in host"
                              " before VM start!", logging.info)
        self.mlock_pre = read_from_vmstat("nr_mlock")
        self.unevictable_pre = read_from_vmstat("nr_unevictable")
        logging.info("mlock_pre is %d and unevictable_pre is %d.",
                     self.mlock_pre, self.unevictable_pre)
        self.params["start_vm"] = "yes"

        error_context.context("Starting VM!", logging.info)
        env_process.preprocess_vm(self.test, self.params,
                                  self.env, self.params["main_vm"])
        self.vm = self.env.get_vm(self.params["main_vm"])
        self.vm.verify_alive()

        error_context.context("Get nr_mlock and nr_unevictable in host"
                              " after VM start!", logging.info)
        self.mlock_post = read_from_vmstat("nr_mlock")
        self.unevictable_post = read_from_vmstat("nr_unevictable")
        logging.info("mlock_post is %d and unevictable_post is %d.",
                     self.mlock_post, self.unevictable_post)

        self._check_mlock_unevictable()
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:26,代码来源:mlock_basic.py


示例7: get_guest_cpuid

    def get_guest_cpuid(self, cpu_model, feature=None):
        test_kernel_dir = os.path.join(test.virtdir, "deps",
                                       "cpuid_test_kernel")
        os.chdir(test_kernel_dir)
        utils.make("cpuid_dump_kernel.bin")

        vm_name = params.get('main_vm')
        params_b = params.copy()
        params_b["kernel"] = os.path.join(test_kernel_dir, "cpuid_dump_kernel.bin")
        params_b["cpu_model"] = cpu_model
        params_b["cpu_model_flags"] = feature
        del params_b["images"]
        del params_b["nics"]
        env_process.preprocess_vm(self, params_b, env, vm_name)
        vm = env.get_vm(vm_name)
        vm.create()
        self.vm = vm
        vm.resume()

        timeout = float(params.get("login_timeout", 240))
        f = lambda: re.search("==END TEST==", vm.serial_console.get_output())
        if not utils_misc.wait_for(f, timeout, 1):
            raise error.TestFail("Could not get test complete message.")

        test_sig = re.compile("==START TEST==\n((?:.*\n)*)\n*==END TEST==")
        test_output = test_sig.search(vm.serial_console.get_output())
        if test_output == None:
            raise error.TestFail("Test output signature not found in "
                                 "output:\n %s", vm.serial_console.get_output())
        self.clean()
        return test_output.group(1)
开发者ID:bonzini,项目名称:virt-test,代码行数:31,代码来源:cpuid.py


示例8: run

def run(test, params, env):
    """
    KVM boot with negative parameter test:
    1) Try to boot VM with negative parameters.
    2) Verify that qemu could handle the negative parameters.
       Check the negative message (optional)

    :param test: qemu test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    neg_msg = params.get("negative_msg")
    if params.get("start_vm") == "yes":
        test.error("Please set start_vm to no")
    params["start_vm"] = "yes"
    try:
        error_context.context("Try to boot VM with negative parameters",
                              logging.info)
        case_fail = False
        env_process.preprocess_vm(test, params, env, params.get("main_vm"))
        case_fail = True
    except Exception as e:
        if neg_msg:
            error_context.context("Check qemu-qemu error message",
                                  logging.info)
            if neg_msg not in str(e):
                msg = "Could not find '%s' in error message '%s'" % (
                    neg_msg, e)
                test.fail(msg)
        logging.debug("Could not boot up vm, %s" % e)
    if case_fail:
        test.fail("Did not raise exception during vm boot up")
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:33,代码来源:sr_iov_boot_negative.py


示例9: get_vm

 def get_vm(self):
     params = self.params
     vm_name = params["main_vm"]
     params["start_vm"] = "yes"
     vm = self.env.get_vm(vm_name)
     env_process.preprocess_vm(self.test, params, self.env, vm_name)
     vm.verify_alive()
     return vm
开发者ID:FengYang,项目名称:virt-test,代码行数:8,代码来源:pxe_query_cpus.py


示例10: run

def run(test, params, env):
    """
    KVM shutdown test:
    1) Log into a guest
    2) Send a shutdown command to the guest, or issue a system_powerdown
       monitor command (depending on the value of shutdown_method)
    3) Wait until the guest is down

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment
    """
    timeout = int(params.get("login_timeout", 360))
    shutdown_count = int(params.get("shutdown_count", 1))
    shutdown_method = params.get("shutdown_method", "shell")
    sleep_time = float(params.get("sleep_before_powerdown", 10))
    shutdown_command = params.get("shutdown_command")

    for i in xrange(shutdown_count):
        vm = env.get_vm(params["main_vm"])
        vm.verify_alive()
        session = vm.wait_for_login(timeout=timeout)
        error.base_context("shutting down the VM %s/%s" % (i + 1,
                                                           shutdown_count),
                           logging.info)
        if params.get("setup_runlevel") == "yes":
            error.context("Setup the runlevel for guest", logging.info)
            expect_runlevel = params.get("expect_runlevel", "3")

            ori_runlevel = session.cmd("runlevel")
            ori_runlevel = re.findall("\d+", ori_runlevel)[-1]
            if ori_runlevel == expect_runlevel:
                logging.info("Guest runlevel is the same as expect.")
            else:
                session.cmd("init %s" % expect_runlevel)
                tmp_runlevel = session.cmd("runlevel")
                tmp_runlevel = re.findall("\d+", tmp_runlevel)[-1]
                if tmp_runlevel != expect_runlevel:
                    logging.warn("Failed to setup runlevel for guest")

        if shutdown_method == "shell":
            # Send a shutdown command to the guest's shell
            session.sendline(shutdown_command)
            error.context("waiting VM to go down (shutdown shell cmd)",
                          logging.info)
        elif shutdown_method == "system_powerdown":
            # Sleep for a while -- give the guest a chance to finish booting
            time.sleep(sleep_time)
            # Send a system_powerdown monitor command
            vm.monitor.cmd("system_powerdown")
            error.context("waiting VM to go down "
                          "(system_powerdown monitor cmd)", logging.info)

        if not utils_misc.wait_for(vm.is_dead, 360, 0, 1):
            raise error.TestFail("Guest refuses to go down")
        if i < shutdown_count - 1:
            session.close()
            env_process.preprocess_vm(test, params, env, params["main_vm"])
开发者ID:luckyh,项目名称:tp-qemu,代码行数:58,代码来源:shutdown.py


示例11: run

def run(test, params, env):
    """
    [pci-bridge]Check stress when 31 block devices attached to 1 pci-bridge, this case will:
    1) Attach one pci-bridge to guest.
    2) Create 31 disks to this pci-bridge.
    3) Start the guest.
    4) Check 'info block'.
    5) Read and write data on disks under pci bridge.

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    error_context.context("Modify params!", logging.info)
    image_parent_bus = params.get("image_parent_bus")
    image_num = int(params.get("image_num", 0))
    if image_num != 0:
        for index in xrange(image_num):
            image = "stg%s" % index
            params["images"] = ' '.join([params["images"], image])
            params["disk_pci_bus_%s" % image] = image_parent_bus
            params["image_name_%s" % image] = "images/%s" % image
            params["image_size_%s" % image] = "100M"
            params["force_create_image_%s" % image] = "yes"
            params["remove_image_%s" % image] = "yes"
            params["blk_extra_params_%s" % image] = "serial=TARGET_DISK%s" % index

    env_process.process_images(env_process.preprocess_image, test, params)
    env_process.preprocess_vm(test, params, env, params["main_vm"])

    error_context.context("Get the main VM!", logging.info)
    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)

    error_context.context("Check 'info block'!", logging.info)
    monitor_info_block = vm.monitor.info_block(False)
    if image_num + 1 != len(monitor_info_block.keys()):
        raise error.TestFail("Check 'info block' failed!")
    logging.info("Check 'info block' succeed!")

    error_context.context("Read and write data on all disks!", logging.info)
    sub_test_type = params.get("sub_test_type", "dd_test")
    images = params["images"]
    images = images.split()
    images.pop(0)
    for image in images:
        if params.get("dd_if") == "ZERO":
            params["dd_of"] = image
        else:
            params["dd_if"] = image
        utils_test.run_virt_sub_test(test, params, env, sub_test_type)

    logging.info("Read and write data on all disks succeed!")
    session.close()
开发者ID:EIChaoYang,项目名称:tp-qemu,代码行数:58,代码来源:pci_bridge_block_stress.py


示例12: run

def run(test, params, env):
    """
    KVM boot time test:
    1) Set init run level to 1
    2) Send a shutdown command to the guest, or issue a system_powerdown
       monitor command (depending on the value of shutdown_method)
    3) Boot up the guest and measure the boot time
    4) set init run level back to the old one

    :param test: QEMU 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)

    error.context("Set guest run level to 1", logging.info)
    single_user_cmd = params['single_user_cmd']
    session.cmd(single_user_cmd)

    try:
        error.context("Shut down guest", logging.info)
        session.cmd('sync')
        vm.destroy()

        error.context("Boot up guest and measure the boot time", logging.info)
        utils_memory.drop_caches()
        vm.create()
        vm.verify_alive()
        session = vm.wait_for_serial_login(timeout=timeout)
        boot_time = utils_misc.monotonic_time() - vm.start_monotonic_time
        test.write_test_keyval({'result': "%ss" % boot_time})
        expect_time = int(params.get("expect_bootup_time", "17"))
        logging.info("Boot up time: %ss" % boot_time)

    finally:
        try:
            error.context("Restore guest run level", logging.info)
            restore_level_cmd = params['restore_level_cmd']
            session.cmd(restore_level_cmd)
            session.cmd('sync')
            vm.destroy(gracefully=False)
            env_process.preprocess_vm(test, params, env, vm.name)
            vm.verify_alive()
            vm.wait_for_login(timeout=timeout)
        except Exception:
            logging.warning("Can not restore guest run level, "
                            "need restore the image")
            params["restore_image_after_testing"] = "yes"

    if boot_time > expect_time:
        raise error.TestFail(
            "Guest boot up is taking too long: %ss" % boot_time)

    session.close()
开发者ID:CongLi,项目名称:tp-qemu,代码行数:58,代码来源:boot_time.py


示例13: test

        def test(self):
            create_floppy(params)
            params["start_vm"] = "yes"
            vm_name = params.get("main_vm", "vm1")
            env_process.preprocess_vm(test, params, env, vm_name)
            vm = env.get_vm(vm_name)
            vm.verify_alive()
            self.session = vm.wait_for_login(timeout=login_timeout)

            self.dest_dir = params.get("mount_dir")
            # If mount_dir specified, treat guest as a Linux OS
            # Some Linux distribution does not load floppy at boot and Windows
            # needs time to load and init floppy driver
            if self.dest_dir:
                lsmod = self.session.cmd("lsmod")
                if not "floppy" in lsmod:
                    self.session.cmd("modprobe floppy")
            else:
                time.sleep(20)

            error.context("Formating floppy disk before using it")
            format_cmd = params["format_floppy_cmd"]
            self.session.cmd(format_cmd, timeout=120)
            logging.info("Floppy disk formatted successfully")

            if self.dest_dir:
                error.context("Mounting floppy")
                self.session.cmd("mount -t vfat %s %s" % (guest_floppy_path, self.dest_dir))
            error.context("Testing floppy")
            self.session.cmd(params["test_floppy_cmd"])

            error.context("Copying file to the floppy")
            md5_cmd = params.get("md5_cmd")
            if md5_cmd:
                md5_source = self.session.cmd("%s %s" % (params["md5_cmd"], source_file))
                try:
                    md5_source = md5_source.split(" ")[0]
                except IndexError:
                    error.TestError("Failed to get md5 from source file," " output: '%s'" % md5_source)
            else:
                md5_source = None

            self.session.cmd("%s %s %s" % (params["copy_cmd"], source_file, dest_file))
            logging.info("Succeed to copy file '%s' into floppy disk" % source_file)

            error.context("Checking if the file is unchanged after copy")
            if md5_cmd:
                md5_dest = self.session.cmd("%s %s" % (params["md5_cmd"], dest_file))
                try:
                    md5_dest = md5_dest.split(" ")[0]
                except IndexError:
                    error.TestError("Failed to get md5 from dest file," " output: '%s'" % md5_dest)
                if md5_source != md5_dest:
                    raise error.TestFail("File changed after copy to floppy")
            else:
                md5_dest = None
                self.session.cmd("%s %s %s" % (params["diff_file_cmd"], source_file, dest_file))
开发者ID:yumingfei,项目名称:virt-test,代码行数:57,代码来源:floppy.py


示例14: run

def run(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_context.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:
        try:
            while num <= int(params.get("max_vms")):
                # Clone vm according to the first one
                error_context.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)
                env_process.preprocess_vm(test, vm_params, env, vm_name)
                params["vms"] += " " + vm_name

                session = curr_vm.wait_for_login(timeout=login_timeout)
                sessions.append(session)
                logging.info("Guest #%d booted up successfully", num)

                # Check whether all previous shell sessions are responsive
                for i, se in enumerate(sessions):
                    error_context.context("checking responsiveness of guest"
                                          " #%d" % (i + 1), logging.debug)
                    se.cmd(params.get("alive_test_cmd"))
                num += 1
        except Exception as emsg:
            test.fail("Expect to boot up %s guests."
                      "Failed to boot up #%d guest with "
                      "error: %s." % (params["max_vms"], num, emsg))
    finally:
        for se in sessions:
            se.close()
        logging.info("Total number booted: %d" % (num - 1))
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:55,代码来源:stress_boot.py


示例15: boot_guest_with_vectors

 def boot_guest_with_vectors(vectors):
     error.context("Boot guest with vectors = %s" % vectors, logging.info)
     params["vectors"] = vectors
     params["start_vm"] = "yes"
     try:
         env_process.preprocess_vm(test, params, env, params.get("main_vm"))
     except virt_vm.VMError, err:
         if int(vectors) < 0:
             txt = "Parameter 'vectors' expects uint32_t"
             if re.findall(txt, str(err)):
                 return
开发者ID:MiriamDeng,项目名称:tp-qemu,代码行数:11,代码来源:boot_with_different_vectors.py


示例16: run

def run(test, params, env):
    """
    [Memory][Numa]binding 128 guest nodes to node0 - x86 with 32M and Power
    with 256M, this case will:
    1) Boot guest with 128 numa nodes
    2) Check query-memdev
    3) Check memory in procfs on host
    4) Check numa node amount in guest

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment
    """
    error_context.context("Modify params to boot guest with 128 numa nodes",
                          logging.info)
    node_num = int(params["numa_nodes"])
    node_size = params["node_size"]
    prealloc_mem = params.get("prealloc_mem", "no")
    mem_devs = ""
    guest_numa_nodes = ""
    for index in range(node_num):
        guest_numa_nodes += "node%s " % index
        mem_devs += "mem%s " % index
        params["numa_memdev_node%s" % index] = "mem-mem%s" % index
        params["size_mem%s" % index] = node_size
        params["prealloc_mem%s" % index] = prealloc_mem

    params["guest_numa_nodes"] = guest_numa_nodes
    params["mem_devs"] = mem_devs
    params["start_vm"] = "yes"
    env_process.preprocess_vm(test, params, env, params["main_vm"])
    error_context.context("Get the main VM!", logging.info)
    vm = env.get_vm(params["main_vm"])

    login_timeout = int(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=login_timeout)

    error_context.context("Check memdevs from monitor", logging.info)
    numa_memdev_options.check_query_memdev(test, params, vm)

    error_context.context("Check memory in host procfs", logging.info)
    numa_memdev_options.check_memory_in_procfs(test, params, vm)

    error_context.context("Check numa node for linux guest", logging.info)
    if params["os_type"] == "linux":
        error_context.context("Check numa node in guest", logging.info)
        numa_cmd = params["numa_cmd"]
        numa_expected = params["numa_expected"]
        guest_numa = session.cmd_output(numa_cmd).strip()
        if guest_numa != numa_expected:
            test.fail("Guest numa node is %s while expected numa node is %s"
                      % (guest_numa, numa_expected))

    session.close()
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:54,代码来源:numa_maxnodes.py


示例17: powerup

 def powerup(self):
     """
     bootup guest with target image;
     """
     params = self.parser_test_args()
     vm_name = params['main_vm']
     logging.info("Target image: %s" % self.target_image)
     error_context.context("powerup vm with target image", logging.info)
     env_process.preprocess_vm(self.test, params, self.env, vm_name)
     vm = self.env.get_vm(vm_name)
     vm.verify_alive()
     self.vm = vm
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:12,代码来源:drive_mirror_powerdown.py


示例18: run

def run(test, params, env):
    """
    enforce quit test:
    steps:
    1). boot guest with enforce params
    2). guest will quit if flags is not supported in host

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment
    """

    guest_cpumodel = params.get("cpu_model", "Conroe").split(",")[0]
    host_cpumodel = utils_misc.get_host_cpu_models()
    host_flags = utils_misc.get_cpu_flags()
    extra_flags = params.get("cpu_model_flags", " ")

    lack_flags = []
    flags = re.findall("\+(\w+)", extra_flags)
    for flag in flags:
        if flag not in host_flags:
            lack_flags.append(flag)
    force_quit = False
    # force quit if flag is not no host
    if lack_flags:
        force_quit = True
    # force quit if 'svm' is added
    if "svm" in extra_flags:
        force_quit = True
    # force quit if guest cpu is not included in host cpu cluster
    if guest_cpumodel not in host_cpumodel and guest_cpumodel != "host":
        force_quit = True

    if "enforce" not in extra_flags:
        raise error.TestError("pls add 'enforce' params to the cmd line")

    msg_unavailable = params.get("msg_unavailable", "").split(":")
    msg_unknow = params.get("msg_unknow", "not found")
    try:
        error.context("boot guest with -cpu %s,%s" %
                      (guest_cpumodel, extra_flags),
                      logging.info)
        params["start_vm"] = "yes"
        env_process.preprocess_vm(test, params, env, params.get("main_vm"))
    except Exception, err:
        tmp_flag = False
        for msg in msg_unavailable:
            if msg in str(err):
                tmp_flag = True
        if tmp_flag or msg_unknow in str(err):
            logging.info("unavailable host feature, guest force quit")
        else:
            raise error.TestFail("guest quit with error\n%s" % str(err))
开发者ID:Chenditang,项目名称:tp-qemu,代码行数:53,代码来源:enforce_quit.py


示例19: run

def run(test, params, env):
    """
    Measure overhead of IPI with and without x2apic:
    1) Enable ept if the host supports it.
    2) Boot guest with x2apic cpu flag (at least 2 vcpu).
    3) Check x2apic flag in guest.
    4) Run pipetest script in guest.
    5) Boot guest without x2apic.
    6) Run pipetest script in guest.
    7) Compare the result of step4 and step6.

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    smp = params.get("smp")
    if int(smp) < 2:
        params["smp"] = 2
        logging.warn(
            "This case need at least 2 vcpu, but only 1 specified in" " configuration. So change the vcpu to 2."
        )
    vm_name = params.get("main_vm")
    error.context("Boot guest with x2apic cpu flag.", logging.info)
    env_process.preprocess_vm(test, params, env, vm_name)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()

    session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))

    check_x2apic_cmd = params.get("check_x2apic_cmd")
    if check_x2apic_cmd:
        error.context("Check x2apic flag in guest", logging.info)
        x2apic_output = session.cmd_output(check_x2apic_cmd).strip()
        x2apic_check_string = params.get("x2apic_check_string").split(",")
        for check_string in x2apic_check_string:
            if check_string.strip() not in x2apic_output:
                msg = "%s is not displayed in output" % check_string
                raise error.TestFail(msg)

    pipetest_cmd = params.get("pipetest_cmd")
    if session.get_command_status("test -x %s" % pipetest_cmd):
        file_link = os.path.join(test.virtdir, "scripts/pipetest.c")
        vm.copy_files_to(file_link, "/tmp/pipetest.c")
        build_pipetest_cmd = params.get("build_pipetest_cmd")
        error.context("Build pipetest script in guest.", logging.info)
        session.cmd(build_pipetest_cmd, timeout=180)

    error.context("Run pipetest script in guest.", logging.info)
    try:
        o = session.cmd(pipetest_cmd, timeout=180)
    except aexpect.ShellTimeoutError, e:
        o = e
开发者ID:MiriamDeng,项目名称:tp-qemu,代码行数:53,代码来源:ipi_x2apic.py


示例20: run

def run(test, params, env):
    """
    KVM reset test:
    1) Boot guest.
    2) Check the guest boot up time.(optional)
    3) Reset system by monitor command for several times. The interval time
       should can be configured by cfg file or based on the boot time get
       from step 2.
    4) Log into the guest to verify it could normally boot.

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    timeout = float(params.get("login_timeout", 240))
    reset_times = int(params.get("reset_times", 20))
    interval = int(params.get("reset_interval", 10))
    wait_time = int(params.get("wait_time_for_reset", 60))
    params["start_vm"] = "yes"

    if params.get("get_boot_time") == "yes":
        error_context.context("Check guest boot up time", logging.info)
        env_process.preprocess_vm(test, params, env, vm.name)
        vm.wait_for_login(timeout=timeout)
        bootup_time = time.time() - vm.start_time
        if params.get("reset_during_boot") == "yes":
            interval = int(bootup_time)
            wait_time = random.randint(0, int(bootup_time))
        vm.destroy()

    error_context.context("Boot the guest", logging.info)
    env_process.preprocess_vm(test, params, env, vm.name)
    logging.info("Wait for %d seconds before reset" % wait_time)
    time.sleep(wait_time)

    for i in range(1, reset_times + 1):
        error_context.context("Reset guest system for %s times" % i,
                              logging.info)

        vm.monitor.cmd("system_reset")

        interval_tmp = interval
        if params.get("fixed_interval", "yes") != "yes":
            interval_tmp = random.randint(0, interval * 1000) / 1000.0

        logging.debug("Reset the system by monitor cmd"
                      " after %ssecs" % interval_tmp)
        time.sleep(interval_tmp)

    error_context.context("Try to login guest after reset", logging.info)
    vm.wait_for_login(timeout=timeout)
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:52,代码来源:system_reset_bootable.py



注:本文中的virttest.env_process.preprocess_vm函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python env_process.process函数代码示例发布时间:2022-05-26
下一篇:
Python data_dir.get_tmp_dir函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap