Since QEMU binaries can be built with various configurations, the list of devices linked in can vary. Add a helper to query the list of devices built into a QEMU binary.
Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> --- python/qemu/binutils.py | 9 +++++++++ tests/acceptance/core_scripts.py | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/python/qemu/binutils.py b/python/qemu/binutils.py index bba203bc8d..9633ba8efd 100644 --- a/python/qemu/binutils.py +++ b/python/qemu/binutils.py @@ -96,3 +96,12 @@ def binary_get_accels(qemu_bin): ''' accel_types = binary_get_qom_implementations(qemu_bin, "accel", False) return [a.strip("-accel") for a in accel_types] + +def binary_get_devices(qemu_bin): + ''' + Get list of devices supported by a QEMU binary + + @param qemu_bin (str): path to the QEMU binary + @return list of devices supported by the binary + ''' + return binary_get_qom_implementations(qemu_bin, "device", False) diff --git a/tests/acceptance/core_scripts.py b/tests/acceptance/core_scripts.py index 7380f2f49b..a62eb2e46b 100644 --- a/tests/acceptance/core_scripts.py +++ b/tests/acceptance/core_scripts.py @@ -18,6 +18,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) from avocado_qemu import Test from qemu.binutils import binary_get_accels from qemu.binutils import binary_get_arch +from qemu.binutils import binary_get_devices from qemu.binutils import binary_get_machines from qemu.binutils import binary_get_qom_implementations from qemu.binutils import binary_get_version @@ -69,3 +70,10 @@ class PythonQemuCoreScripts(Test): self.assertNotIn("accel", accels) # qtest is always available self.assertIn("qtest", accels) + + def test_get_devices(self): + logger = logging.getLogger('core') + devices = binary_get_devices(self.qemu_bin) + for d in devices: + logger.debug('device: {}'.format(d)) + self.assertIn("migration", devices) -- 2.21.1