提交 e258432d 编写于 作者: Y Yongxue Hong

eject_media: Fix blockdev open tray non cdrom with virtio-blk

Since the argument "id" in qmp command "blockdev-open-tray" is
different between virtio-scsi and virtio-blk for the non-removable
media, actually it depends on the "qdev" value from the command
"query-block".
Signed-off-by: NYongxue Hong <yhong@redhat.com>
上级 8034f085
......@@ -36,6 +36,17 @@ def run(test, params, env):
def check_block(block):
return True if block in str(vm.monitor.info("block")) else False
def eject_non_cdrom(device_name, force=False):
if vm.check_capability(Flags.BLOCKDEV):
for info_dict in vm.monitor.info("block"):
if device_name in str(info_dict):
qdev = info_dict['qdev']
break
vm.monitor.blockdev_open_tray(qdev, force)
return vm.monitor.blockdev_remove_medium(qdev)
else:
vm.eject_cdrom(device_name, force)
orig_img_name = params.get("cdrom_cd1")
p_dict = {"file": orig_img_name}
device_name = vm.get_block(p_dict)
......@@ -104,9 +115,9 @@ def run(test, params, env):
test.error("Could not find non-removable device")
try:
if params.get("force_eject", "no") == "yes":
vm.eject_cdrom(device_name, force=True)
eject_non_cdrom(device_name, force=True)
else:
vm.eject_cdrom(device_name)
eject_non_cdrom(device_name)
except Exception as e:
if "is not removable" not in str(e):
test.fail(e)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册