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

Python virsh.dumpxml函数代码示例

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

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



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

示例1: run

def run(test, params, env):
    """
    Test command: virsh qemu-agent-command.
    """
    vm_name = params.get("main_vm")
    vm = env.get_vm(vm_name)
    vm_ref = params.get("vm_ref", "domname")
    vm_state = params.get("vm_state", "running")
    cmd = params.get("agent_cmd", "")
    options = params.get("options", "")
    needs_agent = "yes" == params.get("needs_agent", "yes")
    status_error = "yes" == params.get("status_error", "no")
    if not status_error and options:
        option = options.split()[0]
        test_cmd = "qemu-agent-command"
        if virsh.has_command_help_match(test_cmd, option) is None:
            raise error.TestNAError("The current libvirt doesn't support"
                                    " %s option for %s" % (option, test_cmd))
    guest_cpu_busy = "yes" == params.get("guest_cpu_busy", "no")
    password = params.get("password", None)
    domuuid = vm.get_uuid()
    domid = ""
    xml_file = os.path.join(test.tmpdir, "vm.xml")
    virsh.dumpxml(vm_name, extra="--inactive", to_file=xml_file)
    libvirtd_inst = utils_libvirtd.Libvirtd()

    # Prepare domain
    try:
        reset_domain(vm, vm_state, needs_agent, guest_cpu_busy, password)
    except error.TestNAError, details:
        reset_env(vm_name, xml_file)
        raise error.TestNAError(details)
开发者ID:CongLi,项目名称:tp-libvirt,代码行数:32,代码来源:virsh_qemu_agent_command.py


示例2: run

def run(test, params, env):
    """
    Test for virt-xml-validate
    """
    # Get the full path of virt-xml-validate command.
    VIRT_XML_VALIDATE = os_dep.command("virt-xml-validate")

    vm_name = params.get("main_vm", "virt-tests-vm1")
    vm = env.get_vm(vm_name)
    schema = params.get("schema", "domain")
    output = params.get("output_file", "output")
    output_path = os.path.join(data_dir.get_tmp_dir(), output)

    if schema == "domain":
        virsh.dumpxml(vm_name, to_file=output_path)
    # TODO Add more case for other schema.

    cmd = "%s %s %s" % (VIRT_XML_VALIDATE, output_path, schema)
    cmd_result = utils.run(cmd, ignore_status=True)
    if cmd_result.exit_status:
        raise error.TestFail("virt-xml-validate command failed.\n"
                             "Detail: %s." % cmd_result)

    if cmd_result.stdout.count("fail"):
        raise error.TestFail("xml fails to validate\n"
                             "Detail: %s." % cmd_result)
开发者ID:Acidburn0zzz,项目名称:tp-libvirt,代码行数:26,代码来源:virt_xml_validate.py


示例3: run

def run(test, params, env):
    """
    Test command: virsh qemu-agent-command.
    """
    vm_name = params.get("main_vm")
    vm = env.get_vm(vm_name)
    vm_ref = params.get("vm_ref", "domname")
    vm_state = params.get("vm_state", "running")
    cmd = params.get("agent_cmd", "")
    options = params.get("options", "")
    needs_agent = "yes" == params.get("needs_agent", "yes")
    start_vm = "yes" == params.get("start_vm")
    status_error = "yes" == params.get("status_error", "no")
    domuuid = vm.get_uuid()
    domid = ""
    xml_file = os.path.join(test.tmpdir, "vm.xml")
    virsh.dumpxml(vm_name, extra="--inactive", to_file=xml_file)
    libvirtd_inst = utils_libvirtd.Libvirtd()

    # Prepare domain
    try:
        reset_domain(vm, vm_state, needs_agent)
    except Exception, details:
        reset_env(vm_name, xml_file)
        error.TestFail(details)
开发者ID:Acidburn0zzz,项目名称:tp-libvirt,代码行数:25,代码来源:virsh_qemu_agent_command.py


示例4: run

def run(test, params, env):
    """
    Test for virt-xml-validate
    """
    # Get the full path of virt-xml-validate command.
    try:
        VIRT_XML_VALIDATE = os_dep.command("virt-xml-validate")
    except ValueError:
        raise error.TestNAError("Not find virt-xml-validate command on host.")

    vm_name = params.get("main_vm", "virt-tests-vm1")
    net_name = params.get("net_dumpxml_name", "default")
    pool_name = params.get("pool_dumpxml_name", "default")
    schema = params.get("schema", "domain")
    output = params.get("output_file", "output")
    output_path = os.path.join(data_dir.get_tmp_dir(), output)

    valid_schemas = ['domain', 'domainsnapshot', 'network', 'storagepool',
                     'storagevol', 'nodedev', 'capability',
                     'nwfilter', 'secret', 'interface']
    if schema not in valid_schemas:
        raise error.TestFail("invalid %s specified" % schema)

    virsh_dargs = {'ignore_status': True, 'debug': True}
    if schema == "domainsnapshot":
        domainsnapshot_validate(vm_name, file=output_path, **virsh_dargs)
    elif schema == "network":
        network_validate(net_name, file=output_path, **virsh_dargs)
    elif schema == "storagepool":
        storagepool_validate(pool_name, file=output_path, **virsh_dargs)
    elif schema == "storagevol":
        storagevol_validate(pool_name, file=output_path, **virsh_dargs)
    elif schema == "nodedev":
        nodedev_validate(file=output_path, **virsh_dargs)
    elif schema == "capability":
        capability_validate(file=output_path, **virsh_dargs)
    elif schema == "nwfilter":
        nwfilter_validate(file=output_path, **virsh_dargs)
    elif schema == "secret":
        secret_validate(file=output_path, **virsh_dargs)
    elif schema == "interface":
        interface_validate(file=output_path, **virsh_dargs)
    else:
        # domain
        virsh.dumpxml(vm_name, to_file=output_path)

    cmd = "%s %s %s" % (VIRT_XML_VALIDATE, output_path, schema)
    cmd_result = utils.run(cmd, ignore_status=True)
    if cmd_result.exit_status:
        raise error.TestFail("virt-xml-validate command failed.\n"
                             "Detail: %s." % cmd_result)

    if cmd_result.stdout.count("fail"):
        raise error.TestFail("xml fails to validate\n"
                             "Detail: %s." % cmd_result)
开发者ID:noxdafox,项目名称:tp-libvirt,代码行数:55,代码来源:virt_xml_validate.py


示例5: run

def run(test, params, env):
    """
    Test the command virsh vcpucount

    (1) Iterate perform setvcpus operation with four valid options.
    (2) Iterate call virsh vcpucount with given options.
    (3) Check whether the virsh vcpucount works as expected.
    (4) Recover test environment.

    The test works for domain state as "shut off" or "running", it check
    vcpucount result after vcpu hotplug using setvcpus.

    For setvcpus, include four valid options:
      --config
      --config --maximum
      --live
      --guest

    For vcpucount options, restrict up to 2 options together, upstream libvirt
    support more options combinations now (e.g. 3 options together or single
    --maximum option), for backward support, only following options are
    checked:
      None
      --config --active
      --config --maximum
      --live --active
      --live --maximum
      --current --active
      --current --maximum
      --guest
    """

    vm_name = params.get("main_vm")
    vm = env.get_vm(vm_name)
    xml_file = params.get("vcpucount_xml_file", "vm.xml")
    virsh.dumpxml(vm_name, extra="--inactive", to_file=xml_file)
    pre_vm_state = params.get("vcpucount_pre_vm_state")
    options = params.get("vcpucount_options")
    status_error = params.get("status_error")
    set_option = ["--config", "--config --maximum", "--live", "--guest"]

    # maximum options should be 2
    if len(options.split()) > 2:
        raise error.TestNAError("Options exceeds 2 is not supported")

    # Prepare domain
    try:
        reset_domain(vm, pre_vm_state, (options == "--guest"))
    except Exception, details:
        reset_env(vm_name, xml_file)
        error.TestFail(details)
开发者ID:FengYang,项目名称:tp-libvirt,代码行数:51,代码来源:virsh_vcpucount.py


示例6: get_current_vcpus

 def get_current_vcpus():
     """
     Get current vcpu number.
     """
     vcpus_set = ""
     virsh.dumpxml(vm_name, extra="", to_file=tmp_file)
     dom = parse(tmp_file)
     root = dom.documentElement
     vcpus_2 = root.getElementsByTagName("vcpu")
     for n in vcpus_2:
         vcpus_set += n.getAttribute("current")
         vcpus_set = int(vcpus_set)
     dom.unlink()
     return vcpus_set
开发者ID:Antique,项目名称:virt-test,代码行数:14,代码来源:virsh_setvcpus.py


示例7: check_blockcopy

    def check_blockcopy(target):
        """
        Block copy operation test.
        """
        blk_file = os.path.join(data_dir.get_tmp_dir(), "blk.rbd")
        if os.path.exists(blk_file):
            os.remove(blk_file)
        blk_mirror = ("mirror type='file' file='%s' "
                      "format='raw' job='copy'" % blk_file)

        # Do blockcopy
        ret = virsh.blockcopy(vm_name, target, blk_file)
        libvirt.check_result(ret, skip_if=unsupported_err)

        dom_xml = virsh.dumpxml(vm_name, debug=True).stdout.strip()
        if not dom_xml.count(blk_mirror):
            test.fail("Can't see block job in domain xml")

        # Abort
        ret = virsh.blockjob(vm_name, target, "--abort")
        libvirt.check_exit_status(ret)
        dom_xml = virsh.dumpxml(vm_name, debug=True).stdout.strip()
        if dom_xml.count(blk_mirror):
            test.fail("Failed to abort block job")
        if os.path.exists(blk_file):
            os.remove(blk_file)

        # Sleep for a while after abort operation.
        time.sleep(5)
        # Do blockcopy again
        ret = virsh.blockcopy(vm_name, target, blk_file)
        libvirt.check_exit_status(ret)

        # Wait for complete
        def wait_func():
            ret = virsh.blockjob(vm_name, target, "--info")
            return ret.stderr.count("Block Copy: [100 %]")
        timeout = params.get("blockjob_timeout", 600)
        utils_misc.wait_for(wait_func, int(timeout))

        # Pivot
        ret = virsh.blockjob(vm_name, target, "--pivot")
        libvirt.check_exit_status(ret)
        dom_xml = virsh.dumpxml(vm_name, debug=True).stdout.strip()
        if not dom_xml.count("source file='%s'" % blk_file):
            test.fail("Failed to pivot block job")
        # Remove the disk file.
        if os.path.exists(blk_file):
            os.remove(blk_file)
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:49,代码来源:virtual_disks_ceph.py


示例8: config_xml_multiqueue

def config_xml_multiqueue(vm_name, vcpu=1, multiqueue=4):
    """
    Configure vCPU and interface for multiqueue test.
    """
    vm_xml.VMXML.set_vm_vcpus(vm_name, int(vcpu), int(vcpu))
    vm_xml.VMXML.set_multiqueues(vm_name, multiqueue)
    logging.debug("XML:%s", virsh.dumpxml(vm_name))
开发者ID:CongLi,项目名称:tp-libvirt,代码行数:7,代码来源:multiqueue.py


示例9: get_info

 def get_info(self, name):
     infos = {}
     for line in virsh.dominfo(name).stdout.strip().splitlines():
         key, value = line.split(':', 1)
         infos[key.lower()] = value.strip()
     infos['inactive xml'] = virsh.dumpxml(
         name, extra='--inactive').stdout.splitlines()
     return infos
开发者ID:cheneydc,项目名称:virt-test-ci,代码行数:8,代码来源:ci.py


示例10: check_device_exist

 def check_device_exist(check, virsh_session_id):
     """
     Check if device exist after convertion
     """
     xml = virsh.dumpxml(vm_name, session_id=virsh_session_id).stdout
     if check == 'cdrom':
         if "device='cdrom'" not in xml:
             log_fail('CDROM no longer exists')
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:8,代码来源:function_test_esx.py


示例11: check_snapshot

    def check_snapshot(bgjob=None):
        """
        Do snapshot operation and check the results
        """
        snapshot_name1 = "snap.s1"
        snapshot_name2 = "snap.s2"
        if not snapshot_vm_running:
            vm.destroy(gracefully=False)
        ret = virsh.snapshot_create_as(vm_name, snapshot_name1)
        libvirt.check_exit_status(ret)
        snap_lists = virsh.snapshot_list(vm_name)
        if snapshot_name not in snap_lists:
            test.fail("Snapshot %s doesn't exist"
                      % snapshot_name)

        if snapshot_vm_running:
            options = "--force"
        else:
            options = ""
        ret = virsh.snapshot_revert(
            vm_name, ("%s %s" % (snapshot_name, options)))
        libvirt.check_exit_status(ret)
        ret = virsh.dumpxml(vm_name)
        if ret.stdout.count("<rng model="):
            test.fail("Found rng device in xml")

        if snapshot_with_rng:
            if vm.is_alive():
                vm.destroy(gracefully=False)
            if bgjob:
                bgjob.kill_func()
            modify_rng_xml(params, False)

        # Start the domain before disk-only snapshot
        if vm.is_dead():
            # Add random server
            if params.get("backend_type") == "tcp":
                cmd = "cat /dev/random | nc -4 -l localhost 1024"
                bgjob = utils.AsyncJob(cmd)
            vm.start()
            vm.wait_for_login().close()
        err_msgs = ("live disk snapshot not supported"
                    " with this QEMU binary")
        ret = virsh.snapshot_create_as(vm_name,
                                       "%s --disk-only"
                                       % snapshot_name2)
        if ret.exit_status:
            if ret.stderr.count(err_msgs):
                test.skip(err_msgs)
            else:
                test.fail("Failed to create external snapshot")
        snap_lists = virsh.snapshot_list(vm_name)
        if snapshot_name2 not in snap_lists:
            test.fail("Failed to check snapshot list")

        ret = virsh.domblklist(vm_name)
        if not ret.stdout.count(snapshot_name2):
            test.fail("Failed to find snapshot disk")
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:58,代码来源:libvirt_rng.py


示例12: check_sound_card

 def check_sound_card(vmcheck, check):
     """
     Check sound status of vm from xml
     """
     xml = virsh.dumpxml(vm_name, session_id=vmcheck.virsh_session_id).stdout
     logging.debug(xml)
     if check == 'sound' and '<sound model' in xml:
         log_fail('Sound card should be removed')
     if check == 'pcspk' and "<sound model='pcspk'" not in xml:
         log_fail('Sound card should be "pcspk"')
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:10,代码来源:function_test_xen.py


示例13: check_bootorder_snapshot

    def check_bootorder_snapshot(disk_name):
        """
        Check VM disk's bootorder option with snapshot.

        :param disk_name. The target disk to be checked.
        """
        logging.info("Checking diskorder option with snapshot...")
        snapshot1 = "s1"
        snapshot2 = "s2"
        snapshot2_file = os.path.join(test.tmpdir, "s2")
        ret = virsh.snapshot_create(vm_name, "", **virsh_dargs)
        libvirt.check_exit_status(ret)

        ret = virsh.snapshot_create_as(vm_name, "%s --disk-only" % snapshot1,
                                       **virsh_dargs)
        libvirt.check_exit_status(ret)

        ret = virsh.snapshot_dumpxml(vm_name, snapshot1)
        libvirt.check_exit_status(ret)

        cmd = "echo \"%s\" | grep %s.%s" % (ret.stdout, disk_name, snapshot1)
        if utils.run(cmd, ignore_status=True).exit_status:
            raise error.TestError("Check snapshot disk failed")

        ret = virsh.snapshot_create_as(vm_name,
                                       "%s --memspec file=%s,snapshot=external"
                                       % (snapshot2, snapshot2_file),
                                       **virsh_dargs)
        libvirt.check_exit_status(ret)

        ret = virsh.dumpxml(vm_name)
        libvirt.check_exit_status(ret)

        cmd = ("echo \"%s\" | grep -A 16 %s.%s | grep \"boot order='%s'\""
               % (ret.stdout, disk_name, snapshot2, bootorder))
        if utils.run(cmd, ignore_status=True).exit_status:
            raise error.TestError("Check snapshot disk with bootorder failed")

        snap_lists = virsh.snapshot_list(vm_name)
        if snapshot1 not in snap_lists or snapshot2 not in snap_lists:
            raise error.TestError("Check snapshot list failed")

        # Check virsh save command after snapshot.
        save_file = "/tmp/%s.save" % vm_name
        ret = virsh.save(vm_name, save_file, **virsh_dargs)
        libvirt.check_exit_status(ret)

        # Check virsh restore command after snapshot.
        ret = virsh.restore(save_file, **virsh_dargs)
        libvirt.check_exit_status(ret)

        #Passed all test.
        os.remove(save_file)
开发者ID:CongLi,项目名称:tp-libvirt,代码行数:53,代码来源:virtual_disks_multidisks.py


示例14: get_xmldata

def get_xmldata(vm_name, xml_file, options):
    """
    Get some values out of the guests xml
    Returns:
        count => Number of vCPUs set for the guest
        current => If there is a 'current' value set
                   in the xml indicating the ability
                   to add vCPUs. If 'current' is not
                   set, then return 0 for this value.
        os_machine => Name of the <os> <type machine=''>
                      to be used to determine if we can
                      support hotplug
    """
    # Grab a dump of the guest - if we're using the --config,
    # then get an --inactive dump.
    extra_opts = ""
    if "--config" in options:
        extra_opts = "--inactive"
    vcpus_current = ""
    virsh.dumpxml(vm_name, extra=extra_opts, to_file=xml_file)
    dom = parse(xml_file)
    root = dom.documentElement
    # get the vcpu value
    vcpus_parent = root.getElementsByTagName("vcpu")
    vcpus_count = int(vcpus_parent[0].firstChild.data)
    for n in vcpus_parent:
        vcpus_current += n.getAttribute("current")
        if vcpus_current != "":
            vcpus_current = int(vcpus_current)
        else:
            vcpus_current = 0
    # get the machine type
    os_parent = root.getElementsByTagName("os")
    os_machine = ""
    for os_elem in os_parent:
        for node in os_elem.childNodes:
            if node.nodeName == "type":
                os_machine = node.getAttribute("machine")
    dom.unlink()
    return vcpus_count, vcpus_current, os_machine
开发者ID:uni-peter-zheng,项目名称:tp-libvirt,代码行数:40,代码来源:virsh_setvcpus.py


示例15: vm_state_check

    def vm_state_check():
        cmd_result = virsh.dumpxml(vm_name, debug=True)
        if cmd_result.exit_status:
            test.fail("Failed to dump xml of domain %s" % vm_name)

        # The xml should contain the match_string
        xml = cmd_result.stdout.strip()
        match_string = "<boot dev='cdrom'/>"
        if not re.search(match_string, xml):
            test.fail("After domain restore the xml is not expected")

        domstate = virsh.domstate(vm_name, debug=True).stdout.strip()
        if restore_state != domstate:
            test.fail("The domain state is not expected")
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:14,代码来源:virsh_save_image_edit.py


示例16: vm_state_check

    def vm_state_check():
        cmd_result = virsh.dumpxml(vm_name, debug=True)
        libvirt.check_exit_status(cmd_result)

        # The xml should contain the match_string
        xml = cmd_result.stdout.strip()
        match_string = "<boot dev='cdrom'/>"
        if not re.search(match_string, xml):
            raise exceptions.TestFail("After domain restore, "
                                      "the xml is not expected")

        domstate = virsh.domstate(vm_name, debug=True).stdout.strip()
        if restore_state != domstate:
            raise exceptions.TestFail("The domain state is not expected")
开发者ID:chloerh,项目名称:tp-libvirt,代码行数:14,代码来源:virsh_save_image_define.py


示例17: __init__

 def __init__(self, test, params, env):
     self.errors = []
     self.params = params
     self.vm_name = params.get('main_vm')
     self.hypervisor = params.get("hypervisor")
     self.target = params.get('target')
     self.os_type = params.get('os_type')
     self.os_version = params.get('os_version', 'OS_VERSION_V2V_EXAMPLE')
     self.original_vmxml = params.get('original_vmxml')
     self.virsh_session = None
     self.virsh_session_id = None
     self.setup_session()
     self.checker = utils_v2v.VMCheck(test, params, env)
     self.checker.virsh_session_id = self.virsh_session_id
     self.vmxml = virsh.dumpxml(self.vm_name,
                                session_id=self.virsh_session_id).stdout.strip()
开发者ID:waynesun09,项目名称:tp-libvirt,代码行数:16,代码来源:v2v_vmcheck_helper.py


示例18: attach_channel_xml

    def attach_channel_xml():
        """
        Create channel xml and attach it to guest configuration
        """
        # Check if pty channel exists already
        for elem in new_xml.devices.by_device_tag('channel'):
            if elem.type_name == channel_type_name:
                logging.debug("{0} channel already exists in guest. "
                              "No need to add new one".format(channel_type_name))
                return

        params = {'channel_type_name': channel_type_name,
                  'target_type': target_type,
                  'target_name': target_name}
        channel_xml = libvirt.create_channel_xml(params)
        virsh.attach_device(domain_opt=vm_name, file_opt=channel_xml.xml,
                            flagstr="--config", ignore_status=False)
        logging.debug("New VMXML with channel:\n%s", virsh.dumpxml(vm_name))
开发者ID:balamuruhans,项目名称:tp-libvirt,代码行数:18,代码来源:migrate_options_shared.py


示例19: check_snapshot

    def check_snapshot(snap_option, target_dev='vda'):
        """
        Test snapshot operation.
        """
        snap_name = "s1"
        snap_mem = os.path.join(data_dir.get_tmp_dir(), "rbd.mem")
        snap_disk = os.path.join(data_dir.get_tmp_dir(), "rbd.disk")
        xml_snap_exp = ["disk name='%s' snapshot='external' type='file'" % target_dev]
        xml_dom_exp = ["source file='%s'" % snap_disk,
                       "backingStore type='network' index='1'",
                       "source protocol='rbd' name='%s'" % disk_src_name]
        if snap_option.count("disk-only"):
            options = ("%s --diskspec %s,file=%s --disk-only" %
                       (snap_name, target_dev, snap_disk))
        elif snap_option.count("disk-mem"):
            options = ("%s --memspec file=%s --diskspec %s,file="
                       "%s" % (snap_name, snap_mem, target_dev, snap_disk))
            xml_snap_exp.append("memory snapshot='external' file='%s'"
                                % snap_mem)
        else:
            options = snap_name

        ret = virsh.snapshot_create_as(vm_name, options)
        if test_disk_internal_snapshot or test_disk_readonly:
            libvirt.check_result(ret, expected_fails=unsupported_err)
        else:
            libvirt.check_result(ret, skip_if=unsupported_err)

        # check xml file.
        if not ret.exit_status:
            snap_xml = virsh.snapshot_dumpxml(vm_name, snap_name,
                                              debug=True).stdout.strip()
            dom_xml = virsh.dumpxml(vm_name, debug=True).stdout.strip()
            # Delete snapshots.
            libvirt.clean_up_snapshots(vm_name)
            if os.path.exists(snap_mem):
                os.remove(snap_mem)
            if os.path.exists(snap_disk):
                os.remove(snap_disk)

            if not all([x in snap_xml for x in xml_snap_exp]):
                test.fail("Failed to check snapshot xml")
            if not all([x in dom_xml for x in xml_dom_exp]):
                test.fail("Failed to check domain xml")
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:44,代码来源:virtual_disks_ceph.py


示例20: test_nic_group

def test_nic_group(vm, params):
    """
    Try to attach device in iommu group to vm.

    1.Get original available interfaces before attaching.
    2.Attaching hostdev in iommu group to vm.
    3.Start vm and check it.
    4.Check added interface in vm.
    """
    pci_id = params.get("nic_pci_id", "ETH:PCI.EXAMPLE")
    if pci_id.count("EXAMPLE"):
        raise error.TestNAError("Invalid pci device id.")

    device_type = "Ethernet"
    nic_ip = params.get("nic_pci_ip")
    nic_mask = params.get("nic_pci_mask", "255.255.0.0")
    nic_gateway = params.get("nic_pci_gateway")

    # Login vm to get interfaces before attaching pci device.
    if vm.is_dead():
        vm.start()
    before_pci_nics = vm.get_pci_devices("Ethernet")
    before_interfaces = vm.get_interfaces()
    logging.debug("Ethernet PCI devices before:%s",
                  before_pci_nics)
    logging.debug("Ethernet interfaces before:%s",
                  before_interfaces)
    vm.destroy()

    boot_order = int(params.get("boot_order", 0))
    prepare_devices(pci_id, device_type)
    try:
        if boot_order:
            utlv.alter_boot_order(vm.name, pci_id, boot_order)
        else:
            xmlfile = utlv.create_hostdev_xml(pci_id)
            virsh.attach_device(domain_opt=vm.name, file_opt=xmlfile,
                                flagstr="--config", debug=True,
                                ignore_status=False)
        logging.debug("VMXML with disk boot:\n%s", virsh.dumpxml(vm.name))
        vm.start()
    except (error.CmdError, virt_vm.VMStartError), detail:
        cleanup_devices(pci_id, device_type)
        raise error.TestFail("New device does not work well: %s" % detail)
开发者ID:Chenditang,项目名称:tp-libvirt,代码行数:44,代码来源:vfio.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python virsh.has_command_help_match函数代码示例发布时间:2022-05-26
下一篇:
Python virsh.domstate函数代码示例发布时间: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