当前位置: 首页>>代码示例>>Python>>正文


Python utils_misc.get_qemu_img_binary函数代码示例

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


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

示例1: run_test

    def run_test(qemu_src_dir):
        """
        run QEMU I/O test suite

        :qemu_src_dir: path of qemu source code
        """
        iotests_root = params.get("iotests_root", "tests/qemu-iotests")
        extra_options = params.get("qemu_io_extra_options", "")
        image_format = params.get("qemu_io_image_format")
        result_pattern = params.get("iotests_result_pattern")
        error_context.context("running qemu-iotests for image format %s"
                              % image_format, logging.info)
        os.environ["QEMU_PROG"] = utils_misc.get_qemu_binary(params)
        os.environ["QEMU_IMG_PROG"] = utils_misc.get_qemu_img_binary(params)
        os.environ["QEMU_IO_PROG"] = utils_misc.get_qemu_io_binary(params)
        os.environ["QEMU_NBD_PROG"] = utils_misc.get_binary('qemu-nbd', params)
        os.chdir(os.path.join(qemu_src_dir, iotests_root))
        cmd = './check'
        if extra_options:
            cmd += " %s" % extra_options
        cmd += " -%s" % image_format
        output = process.system_output(cmd, ignore_status=True, shell=True)
        match = re.search(result_pattern, output, re.I | re.M)
        if match:
            iotests_log_file = "qemu_iotests_%s.log" % image_format
            iotests_log_file = utils_misc.get_path(test.debugdir, iotests_log_file)
            with open(iotests_log_file, 'w+') as log:
                log.write(output)
                log.flush()
            msg = "Total test %s cases, %s failed"
            raise exceptions.TestFail(msg % (match.group(2), match.group(1)))
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:31,代码来源:rh_qemu_iotests.py

示例2: get_image_size

 def get_image_size(self, image_file):
     qemu_img = utils_misc.get_qemu_img_binary(self.params)
     cmd = "%s info %s" % (qemu_img, image_file)
     info = utils.system_output(cmd)
     size = re.findall("(\d+) bytes", info)
     if size:
         return int(size[0])
     return 0
开发者ID:LeiCui,项目名称:virt-test,代码行数:8,代码来源:block_stream.py

示例3: __init__

    def __init__(self, params, root_dir, tag):
        """
        Init the default value for image object.

        :param params: Dictionary containing the test parameters.
        :param root_dir: Base directory for relative filenames.
        :param tag: Image tag defined in parameter images
        """
        storage.QemuImg.__init__(self, params, root_dir, tag)
        self.image_cmd = utils_misc.get_qemu_img_binary(params)
        q_result = process.run(self.image_cmd + ' -h', ignore_status=True,
                               shell=True, verbose=False)
        self.help_text = results_stdout_52lts(q_result)
        self.cap_force_share = '-U' in self.help_text
开发者ID:jcfaracco,项目名称:avocado-vt,代码行数:14,代码来源:qemu_storage.py

示例4: get_backingfile

    def get_backingfile(self, method="monitor"):
        """
        return backingfile of the device, if not return None;
        """
        if method == "monitor":
            return self.vm.monitor.get_backingfile(self.device)

        qemu_img = utils_misc.get_qemu_img_binary(self.params)
        cmd = "%s info %s " % (qemu_img, self.get_image_file())
        info = utils.system_output(cmd)
        try:
            matched = re.search(r"backing file: +(.*)", info, re.M)
            return matched.group(1)
        except AttributeError:
            logging.warn("No backingfile found, cmd output: %s" % info)
开发者ID:Chenditang,项目名称:tp-qemu,代码行数:15,代码来源:block_copy.py

示例5: __init__

 def __init__(self, test, params):
     self.__dict__ = self.__shared_state
     self.tmpdir = test.tmpdir
     self.qemu_img_binary = utils_misc.get_qemu_img_binary(params)
     self.raw_files = ["stg1.raw", "stg2.raw"]
     self.raw_files = list(map(lambda f: os.path.join(self.tmpdir, f),
                               self.raw_files))
     # Here we're trying to choose fairly explanatory names so it's less
     # likely that we run in conflict with other devices in the system
     self.vgtest_name = params.get("vgtest_name", "vg_kvm_test_qemu_io")
     self.lvtest_name = params.get("lvtest_name", "lv_kvm_test_qemu_io")
     self.lvtest_device = "/dev/%s/%s" % (
         self.vgtest_name, self.lvtest_name)
     try:
         getattr(self, 'loopback')
     except AttributeError:
         self.loopback = []
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:17,代码来源:qemu_io.py

示例6: get_backingfile

 def get_backingfile(self, method="monitor"):
     """
     return backingfile of the device, if not return None;
     """
     backing_file = None
     if method == "monitor":
         backing_file = self.vm.monitor.get_backingfile(self.device)
     else:
         cmd = utils_misc.get_qemu_img_binary(self.params)
         image_file = self.get_image_file()
         cmd += " info %s " % image_file
         info = utils.system_output(cmd)
         matched = re.search(r"backing file: +(.*)", info, re.M)
         if matched:
             backing_file = matched.group(1)
     if backing_file:
         backing_file = os.path.abspath(backing_file)
     return backing_file
开发者ID:sibiaoluo,项目名称:tp-qemu,代码行数:18,代码来源:block_copy.py

示例7: clean

 def clean(self):
     super(DriveMirror, self).clean()
     params = self.parser_test_args()
     if params.get("image_type") == "iscsi":
         params["host_setup_flag"] = int(params["host_setup_flag"])
         qemu_img = utils_misc.get_qemu_img_binary(self.params)
         # Reformat it to avoid impact other test
         cmd = "%s create -f %s %s %s" % (qemu_img,
                                          params["image_format"],
                                          self.target_image,
                                          params["image_size"])
         process.system(cmd)
         image = qemu_storage.Iscsidev(params, self.data_dir,
                                       params["target_image"])
         image.cleanup()
     elif params.get("image_type") == "nfs":
         image = nfs.Nfs(params)
         image.cleanup()
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:18,代码来源:drive_mirror.py

示例8: __init__

    def __init__(self, test, params, env, tag):
        """
        Init the default values for live backup object.

        :param test: Kvm test object
        :param params: Dictionary with the test parameters
        :param env: Dictionary with test environment.
        :param tag: Image tag defined in parameter images
        """
        super(LiveBackup, self).__init__(test, params, env, tag)
        self.image_chain = self.params.get("image_chain").split()
        self.image_cmd = utils_misc.get_qemu_img_binary(params)
        self.source_image = self.params.get("source_image")
        self.speed = int(self.params.get("speed", 0))
        self.bitmap_name = "bitmap0"
        self.backup_index = 1
        self.backup_format = self.params.get("backup_format")
        self.generate_backup_params()
开发者ID:suqinhuang,项目名称:tp-qemu,代码行数:18,代码来源:live_backup_base.py

示例9: __init__

 def __init__(self, test, params):
     self.__dict__ = self.__shared_state
     root_dir = test.bindir
     self.tmpdir = test.tmpdir
     self.qemu_img_binary = utils_misc.get_qemu_img_binary(self.params)
     self.raw_file_path = os.path.join(self.tmpdir, 'enospc.raw')
     # Here we're trying to choose fairly explanatory names so it's less
     # likely that we run in conflict with other devices in the system
     self.vgtest_name = params["vgtest_name"]
     self.lvtest_name = params["lvtest_name"]
     self.lvtest_device = "/dev/%s/%s" % (
         self.vgtest_name, self.lvtest_name)
     image_dir = os.path.join(data_dir.get_data_dir(),
                              os.path.dirname(params["image_name"]))
     self.qcow_file_path = os.path.join(image_dir, 'enospc.qcow2')
     try:
         getattr(self, 'loopback')
     except AttributeError:
         self.loopback = ''
开发者ID:arges,项目名称:tp-qemu,代码行数:19,代码来源:enospc.py

示例10: get_image_size

 def get_image_size(self, image_file):
     try:
         qemu_img = utils_misc.get_qemu_img_binary(self.params)
         cmd = "%s info %s" % (qemu_img, image_file)
         logging.info("Try to get image size via qemu-img info")
         info = process.system_output(cmd)
         size = int(re.findall(r"(\d+) bytes", info)[0])
     except process.CmdError:
         logging.info("qemu-img info failed(it happens because later qemu"
                      " distributions prevent it access a running image.)."
                      " Now get image size via qmp interface 'query-block'")
         blocks_info = self.vm.monitor.info("block")
         for block in blocks_info:
             info = block["inserted"]
             if image_file == info["file"]:
                 size = info["image"]["virtual-size"]
     if size:
         return size
     return 0
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:19,代码来源:block_stream.py

示例11: backup_img_chain

 def backup_img_chain(image_file):
     """
     Backup whole image in a image chain;
     """
     mount_point = tempfile.mkdtemp(dir=test.resultsdir)
     qemu_img = utils_misc.get_qemu_img_binary(params)
     if enable_gluster:
         g_uri = gluster.create_gluster_uri(params)
         gluster.glusterfs_mount(g_uri, mount_point)
         image_name = os.path.basename(image_file)
         image_file = os.path.join(mount_point, image_name)
     logging.warn("backup %s to %s" % (image_file, test.resultsdir))
     shutil.copy(image_file, test.resultsdir)
     backing_file = _info(qemu_img, image_file, "backing file", None)
     if backing_file:
         backup_img_chain(backing_file)
     elif enable_gluster:
         utils_misc.umount(g_uri, mount_point, "glusterfs", False, "fuse.glusterfs")
         shutil.rmtree(mount_point)
     return None
开发者ID:uni-peter-zheng,项目名称:tp-qemu,代码行数:20,代码来源:qemu_img.py

示例12: run_qemu_iotests

def run_qemu_iotests(test, params, env):
    """
    Fetch from git and run qemu-iotests using the qemu binaries under test.

    1) Fetch qemu-io from git
    3) Run test for the file format detected
    4) Report any errors found to autotest

    :param test:   QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env:    Dictionary with test environment.
    """
    # First, let's get qemu-io
    std = "http://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git"
    uri = params.get("qemu_io_uri", std)
    branch = params.get("qemu_io_branch", 'master')
    lbranch = params.get("qemu_io_lbranch", 'master')
    commit = params.get("qemu_io_commit", None)
    base_uri = params.get("qemu_io_base_uri", None)
    iotests_dir = params.get("qemu_iotests_dir", "tests/qemu-iotests")
    destination_dir = os.path.join(test.srcdir, "qemu_io_tests")
    git.get_repo(uri=uri, branch=branch, lbranch=lbranch, commit=commit,
                 destination_dir=destination_dir, base_uri=base_uri)

    # Then, set the qemu paths for the use of the testsuite
    os.environ["QEMU_PROG"] = utils_misc.get_qemu_binary(params)
    os.environ["QEMU_IMG_PROG"] = utils_misc.get_qemu_img_binary(params)
    os.environ["QEMU_IO_PROG"] = utils_misc.get_qemu_io_binary(params)

    # qemu-iotests has merged into tests/qemu_iotests folder
    os.chdir(os.path.join(destination_dir, iotests_dir))
    image_format = params["qemu_io_image_format"]
    extra_options = params.get("qemu_io_extra_options", "")

    cmd = './check'
    if extra_options:
        cmd += extra_options

    error.context("running qemu-iotests for image format %s" % image_format)
    utils.system("%s -%s" % (cmd, image_format))
开发者ID:Antique,项目名称:virt-test,代码行数:40,代码来源:qemu_iotests.py

示例13: run_qemu_img

def run_qemu_img(test, params, env):
    """
    'qemu-img' functions test:
    1) Judge what subcommand is going to be tested
    2) Run subcommand test

    @param test: QEMU test object
    @param params: Dictionary with the test parameters
    @param env: Dictionary with test environment.
    """
    qemu_img_binary = utils_misc.get_qemu_img_binary(params)
    cmd = qemu_img_binary
    if not os.path.exists(cmd):
        raise error.TestError("Binary of 'qemu-img' not found")
    image_format = params["image_format"]
    image_size = params.get("image_size", "10G")
    image_name = storage.get_image_filename(params, data_dir.get_data_dir())


    def _check(cmd, img):
        """
        Simple 'qemu-img check' function implementation.

        @param cmd: qemu-img base command.
        @param img: image to be checked
        """
        cmd += " check %s" % img
        error.context("Checking image '%s' by command '%s'" % (img, cmd),
                      logging.info)
        try:
            output = utils.system_output(cmd, verbose=False)
        except error.CmdError, err:
            if "does not support checks" in str(err):
                return (True, "")
            else:
                return (False, str(err))
        return (True, output)
开发者ID:LeiCui,项目名称:virt-test,代码行数:37,代码来源:qemu_img.py

示例14: run_boot_savevm

def run_boot_savevm(test, params, env):
    """
    libvirt boot savevm test:

    1) Start guest booting
    2) Record origin informations of snapshot list for floppy(optional).
    3) Periodically savevm/loadvm while guest booting
    4) Stop test when able to login, or fail after timeout seconds.
    5) Check snapshot list for floppy and compare with the origin
       one(optional).

    @param test: test object
    @param params: Dictionary with the test parameters
    @param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    if params.get("with_floppy") == "yes":
        floppy_name = params.get("floppies", "fl")
        floppy_params = {"image_format": params.get("floppy_format", "qcow2"),
                         "image_size": params.get("floppy_size", "1.4M"),
                         "image_name": params.get("%s_name" % floppy_name,
                                                  "images/test"),
                         "vm_type": params.get("vm_type"),
                         "qemu_img_binary": utils_misc.get_qemu_img_binary(params)}
        floppy = qemu_storage.QemuImg(floppy_params,
                                     data_dir.get_data_dir(), floppy_name)
        floppy.create(floppy_params)
        floppy_orig_info = floppy.snapshot_list()
        vm.create(params=params)

    vm.verify_alive() # This shouldn't require logging in to guest
    savevm_delay = float(params["savevm_delay"])
    savevm_login_delay = float(params["savevm_login_delay"])
    savevm_login_timeout = float(params["savevm_timeout"])
    savevm_statedir = params.get("savevm_statedir", tempfile.gettempdir())
    fd, savevm_statefile = tempfile.mkstemp(suffix='.img', prefix=vm.name+'-',
                                            dir=savevm_statedir)
    os.close(fd) # save_to_file doesn't need the file open
    start_time = time.time()
    cycles = 0

    successful_login = False
    while (time.time() - start_time) < savevm_login_timeout:
        logging.info("Save/Restore cycle %d", cycles + 1)
        time.sleep(savevm_delay)
        vm.pause()
        if params['save_method'] == 'save_to_file':
            vm.save_to_file(savevm_statefile) # Re-use same filename
            vm.restore_from_file(savevm_statefile)
        else:
            vm.savevm("1")
            vm.loadvm("1")
        vm.resume() # doesn't matter if already running or not
        vm.verify_kernel_crash() # just in case
        try:
            vm.wait_for_login(timeout=savevm_login_delay)
            successful_login = True # not set if timeout expires
            os.unlink(savevm_statefile) # don't let these clutter disk
            break
        except:
            pass # loop until successful login or time runs out
        cycles += 1

    time_elapsed = int(time.time() - start_time)
    info = "after %s s, %d load/save cycles" % (time_elapsed, cycles + 1)
    if not successful_login:
        raise error.TestFail("Can't log on '%s' %s" % (vm.name, info))
    else:
        logging.info("Test ended %s", info)

    if params.get("with_floppy")  == "yes":
        vm.destroy()
        floppy_info = floppy.snapshot_list()
        if floppy_info == floppy_orig_info:
            raise error.TestFail("savevm didn't create snapshot in floppy."
                                 "    original snapshot list is: %s"
                                 "    now snapshot list is: %s"
                                 % (floppy_orig_info, floppy_info))
开发者ID:LeiCui,项目名称:virt-test,代码行数:78,代码来源:boot_savevm.py

示例15: run

def run(test, params, env):
    """
    'qemu-img' functions test:
    1) Judge what subcommand is going to be tested
    2) Run subcommand test

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    qemu_img_binary = utils_misc.get_qemu_img_binary(params)
    cmd = qemu_img_binary
    if not os.path.exists(cmd):
        raise error.TestError("Binary of 'qemu-img' not found")
    image_format = params["image_format"]
    image_size = params.get("image_size", "10G")
    enable_gluster = params.get("enable_gluster", "no") == "yes"
    image_name = storage.get_image_filename(params, data_dir.get_data_dir())

    def remove(path):
        try:
            os.remove(path)
        except OSError:
            pass

    def _get_image_filename(img_name, enable_gluster=False, img_fmt=None):
        """
        Generate an image path.

        :param image_name: Force name of image.
        :param enable_gluster: Enable gluster or not.
        :param image_format: Format for image.
        """
        if enable_gluster:
            gluster_uri = gluster.create_gluster_uri(params)
            image_filename = "%s%s" % (gluster_uri, img_name)
            if img_fmt:
                image_filename += ".%s" % img_fmt
        else:
            if img_fmt:
                img_name = "%s.%s" % (img_name, img_fmt)
            image_filename = utils_misc.get_path(data_dir.get_data_dir(),
                                                 img_name)
        return image_filename

    def _check(cmd, img):
        """
        Simple 'qemu-img check' function implementation.

        :param cmd: qemu-img base command.
        :param img: image to be checked
        """
        cmd += " check %s" % img
        error.context("Checking image '%s' by command '%s'" % (img, cmd),
                      logging.info)
        try:
            output = utils.system_output(cmd, verbose=False)
        except error.CmdError, err:
            if "does not support checks" in str(err):
                return (True, "")
            else:
                return (False, str(err))
        return (True, output)
开发者ID:gogoxiaoxiao,项目名称:tp-qemu,代码行数:63,代码来源:qemu_img.py


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