本文整理汇总了Python中virttest.libvirt_xml.devices.controller.Controller.driver方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.driver方法的具体用法?Python Controller.driver怎么用?Python Controller.driver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类virttest.libvirt_xml.devices.controller.Controller
的用法示例。
在下文中一共展示了Controller.driver方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from virttest.libvirt_xml.devices.controller import Controller [as 别名]
# 或者: from virttest.libvirt_xml.devices.controller.Controller import driver [as 别名]
if cntlr_model is not None:
ctrl.model = cntlr_model
if cntlr_index is not None:
ctrl.index = cntlr_index
ctrl_addr_dict = {}
for addr_option in controller_addr_options.split(','):
if addr_option != "":
addr_part = addr_option.split('=')
ctrl_addr_dict.update({addr_part[0].strip(): addr_part[1].strip()})
ctrl.address = ctrl.new_controller_address(attrs=ctrl_addr_dict)
# If driver_iothread is true, need add iothread attribute in controller.
if driver_iothread:
ctrl_driver_dict = {}
ctrl_driver_dict.update({"iothread": driver_iothread})
ctrl.driver = ctrl_driver_dict
logging.debug("Controller XML is:%s", ctrl)
vmxml.add_device(ctrl)
vmxml.sync()
try:
# Start the VM and check status.
vm.start()
if status_error:
raise exceptions.TestFail("VM started unexpectedly.")
# Check Qemu command line
if test_qemu_cmd:
check_qemu_cmd()
示例2: Controller
# 需要导入模块: from virttest.libvirt_xml.devices.controller import Controller [as 别名]
# 或者: from virttest.libvirt_xml.devices.controller.Controller import driver [as 别名]
# Add virtio_scsi controller.
if virtio_scsi_controller:
scsi_controller = Controller("controller")
scsi_controller.type = "scsi"
scsi_controller.index = "0"
ctl_model = params.get("virtio_scsi_controller_model")
if ctl_model:
scsi_controller.model = ctl_model
if virtio_scsi_controller_driver != "":
driver_dict = {}
for driver_option in virtio_scsi_controller_driver.split(','):
if driver_option != "":
d = driver_option.split('=')
driver_dict.update({d[0].strip(): d[1].strip()})
scsi_controller.driver = driver_dict
vmxml.del_controller("scsi")
vmxml.add_device(scsi_controller)
# Test usb devices.
usb_devices = {}
if add_usb_device:
# Delete all usb devices first.
controllers = vmxml.get_devices(device_type="controller")
for ctrl in controllers:
if ctrl.type == "usb":
vmxml.del_device(ctrl)
inputs = vmxml.get_devices(device_type="input")
for input in inputs:
if input.type_name == "tablet":
示例3: run
# 需要导入模块: from virttest.libvirt_xml.devices.controller import Controller [as 别名]
# 或者: from virttest.libvirt_xml.devices.controller.Controller import driver [as 别名]
def run(test, params, env):
"""
Test disk encryption option.
1.Prepare test environment, destroy or suspend a VM.
2.Prepare tgtd and secret config.
3.Edit disks xml and start the domain.
4.Perform test operation.
5.Recover test environment.
6.Confirm the test result.
"""
vm_name = params.get("main_vm")
vm = env.get_vm(vm_name)
virsh_dargs = {'debug': True, 'ignore_status': True}
def check_save_restore(save_file):
"""
Test domain save and restore.
"""
# Save the domain.
ret = virsh.save(vm_name, save_file, **virsh_dargs)
libvirt.check_exit_status(ret)
# Restore the domain.
ret = virsh.restore(save_file, **virsh_dargs)
libvirt.check_exit_status(ret)
def check_snapshot():
"""
Test domain snapshot operation.
"""
snapshot1 = "s1"
snapshot2 = "s2"
ret = virsh.snapshot_create_as(vm_name, snapshot1)
libvirt.check_exit_status(ret)
ret = virsh.snapshot_create_as(vm_name,
"%s --disk-only --diskspec vda,"
"file=/tmp/testvm-snap1"
% snapshot2)
libvirt.check_exit_status(ret, True)
ret = virsh.snapshot_create_as(vm_name,
"%s --memspec file=%s,snapshot=external"
" --diskspec vda,file=/tmp/testvm-snap2"
% (snapshot2, snapshot2))
libvirt.check_exit_status(ret, True)
def check_in_vm(target, old_parts):
"""
Check mount/read/write disk in VM.
:param vm. VM guest.
:param target. Disk dev in VM.
:return: True if check successfully.
"""
try:
session = vm.wait_for_login()
new_parts = libvirt.get_parts_list(session)
added_parts = list(set(new_parts).difference(set(old_parts)))
logging.info("Added parts:%s", added_parts)
if len(added_parts) != 1:
logging.error("The number of new partitions is invalid in VM")
return False
added_part = None
if target.startswith("vd"):
if added_parts[0].startswith("vd"):
added_part = added_parts[0]
elif target.startswith("hd"):
if added_parts[0].startswith("sd"):
added_part = added_parts[0]
elif target.startswith("sd"):
added_part = added_parts[0]
if not added_part:
logging.error("Cann't see added partition in VM")
return False
cmd = ("fdisk -l /dev/{0} && mkfs.ext4 -F /dev/{0} && "
"mkdir -p test && mount /dev/{0} test && echo"
" teststring > test/testfile && umount test"
.format(added_part))
s, o = session.cmd_status_output(cmd)
logging.info("Check disk operation in VM:\n%s", o)
if s != 0:
return False
return True
except (remote.LoginError, virt_vm.VMError, aexpect.ShellError) as e:
logging.error(str(e))
return False
def check_qemu_cmd():
"""
Check qemu-kvm command line options
"""
cmd = ("ps -ef | grep %s | grep -v grep " % vm_name)
if driver_iothread:
cmd += " | grep iothread=iothread%s" % driver_iothread
#.........这里部分代码省略.........