提交 824043c6 编写于 作者: Y Yongxue Hong

insert_media: New case that inserts media in blockdev mode

New a case that inserts a media in the blockdev mode.
Signed-off-by: NYongxue Hong <yhong@redhat.com>
上级 b2f64207
- insert_media:
only Linux
only virtio_scsi
type = insert_media
virt_test_type = qemu
kill_vm = yes
start_vm = no
not_preprocess = yes
monitor_type = qmp
pre_command = "dd if=/dev/zero of=/tmp/new bs=10M count=1 && "
pre_command += "mkisofs -o /tmp/new.iso /tmp/new"
post_command = "rm -rf /tmp/new.iso /tmp/new"
cdrom_cd1 = /tmp/new.iso
tray_move_event = DEVICE_TRAY_MOVED
paused_after_start_vm = yes
force_drive_format_cd1 = scsi-cd
# disable iothread
iothread_scheme ?=
image_iothread ?=
iothreads ?=
from virttest import env_process
from virttest import utils_misc
from virttest.qemu_capabilities import Flags
from virttest.qemu_devices import qdevices
def run(test, params, env):
"""
Steps:
1. Boot guest with scsi-cd without file, not dummy image.
2. Add drive layer and insert media.
:param test: QEMU test object.
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
"""
def move_tary(action, dev_id):
getattr(vm.monitor, 'blockdev_%s_tray' % action)(dev_id)
if not utils_misc.wait_for(
lambda: vm.monitor.get_event(tray_move_event), 60, 0, 3):
test.fail('Failed to get event %s after %s tray.' %
(tray_move_event, action))
tray_move_event = params.get('tray_move_event')
dev_id = params.get('cdroms').split()[0]
params["start_vm"] = "yes"
vm_name = params.get('main_vm')
env_process.preprocess_vm(test, params, env, vm_name)
vm = env.get_vm(vm_name)
if not vm.check_capability(Flags.BLOCKDEV):
test.cancel("Unsupported the insertion media.")
vm.verify_alive()
drive = vm.devices[dev_id]
format_node = vm.devices[drive.get_param('drive')]
nodes = [format_node]
nodes.extend((n for n in format_node.get_child_nodes()))
for node in nodes:
vm.devices.remove(node, True if isinstance(
node, qdevices.QBlockdevFormatNode) else False)
if not isinstance(node, qdevices.QBlockdevFormatNode):
format_node.del_child_node(node)
drive.set_param('drive', None)
vm.destroy(False)
vm = vm.clone(copy_state=True)
vm.create()
move_tary('open', dev_id)
vm.monitor.blockdev_remove_medium(dev_id)
for node in reversed(nodes):
vm.devices.simple_hotplug(node, vm.monitor)
vm.monitor.blockdev_insert_medium(dev_id, format_node.get_qid())
move_tary('close', dev_id)
vm.destroy()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册