From 15f2f137b0a3f2ecbfa01283187c26fccecec154 Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Mon, 3 Jun 2013 13:48:11 -0300 Subject: [PATCH] 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: Lucas Meneghel Rodrigues --- qemu/tests/pci_hotplug.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/qemu/tests/pci_hotplug.py b/qemu/tests/pci_hotplug.py index 29862a56..4a9eebb5 100644 --- a/qemu/tests/pci_hotplug.py +++ b/qemu/tests/pci_hotplug.py @@ -51,8 +51,28 @@ def run_pci_hotplug(test, params, env): 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): - if not vm.is_supported_device(dev): + if not is_supported_device(dev): raise error.TestError("%s doesn't support device: %s" % (cmd_type, dev)) -- GitLab