qemu: Fix pci_hotplug testing

Turns out commit e9953f8a doesn't include the definition
of the function vm.is_supported_device, making this test
to fail. As a fix, instead of adding yet another vm method,
add a function local to the test, at least for now. This
function could be turned to an API in case it looks and
works OK to the other reviewers, although I'd like to
avoid API proliferation.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 29d3e2f3
...@@ -51,8 +51,28 @@ def run_pci_hotplug(test, params, env): ...@@ -51,8 +51,28 @@ def run_pci_hotplug(test, params, env):
return vm.monitor.info("pci") return vm.monitor.info("pci")
def is_supported_device(dev):
# Probe qemu to verify what is the supported syntax for PCI hotplug
cmd_output = vm.monitor.cmd("?")
if len(re.findall("\ndevice_add", cmd_output)) > 0:
cmd_type = "device_add"
elif len(re.findall("\npci_add", cmd_output)) > 0:
cmd_type = "pci_add"
else:
raise error.TestError("Unknow version of qemu")
# Probe qemu for a list of supported devices
probe_output = vm.monitor.cmd("%s ?" % cmd_type)
devices_supported = [j.strip('"') for j in
re.findall('\"[a-z|0-9|\-|\_|\,|\.]*\"',
probe_output, re.MULTILINE)]
logging.debug("QEMU reported the following supported devices for "
"PCI hotplug: %s", devices_supported)
return (dev in devices_supported)
def verify_supported_device(dev): def verify_supported_device(dev):
if not vm.is_supported_device(dev): if not is_supported_device(dev):
raise error.TestError("%s doesn't support device: %s" % raise error.TestError("%s doesn't support device: %s" %
(cmd_type, dev)) (cmd_type, dev))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册