diff mbox series

[v2,11/29] python/qemu: Add binutils::binary_get_accels()

Message ID 20200129212345.20547-12-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series tests/acceptance/virtio_seg_max_adjust: Restrict it to Linux/X86 | expand

Commit Message

Philippe Mathieu-Daudé Jan. 29, 2020, 9:23 p.m. UTC
Add a helper to query the list of accelerators built into a
QEMU binary.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 python/qemu/binutils.py          | 10 ++++++++++
 tests/acceptance/core_scripts.py | 10 ++++++++++
 2 files changed, 20 insertions(+)

Comments

Liam Merwick Feb. 7, 2020, 2:35 p.m. UTC | #1
On 29/01/2020 21:23, Philippe Mathieu-Daudé wrote:
> Add a helper to query the list of accelerators built into a
> QEMU binary.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>


Reviewed-by: Liam Merwick <liam.merwick@oracle.com>


> ---
>   python/qemu/binutils.py          | 10 ++++++++++
>   tests/acceptance/core_scripts.py | 10 ++++++++++
>   2 files changed, 20 insertions(+)
> 
> diff --git a/python/qemu/binutils.py b/python/qemu/binutils.py
> index 76f256f5d2..bba203bc8d 100644
> --- a/python/qemu/binutils.py
> +++ b/python/qemu/binutils.py
> @@ -86,3 +86,13 @@ def binary_get_qom_implementations(qemu_bin, type_name, include_abstract=False):
>           LOG.info(res)
>           vm.shutdown()
>           return [m['name'] for m in res]
> +
> +def binary_get_accels(qemu_bin):
> +    '''
> +    Get list of accelerators supported by a QEMU binary
> +
> +    @param qemu_bin (str): path to the QEMU binary
> +    @return list of accelerators supported by the binary
> +    '''
> +    accel_types = binary_get_qom_implementations(qemu_bin, "accel", False)
> +    return [a.strip("-accel") for a in accel_types]
> diff --git a/tests/acceptance/core_scripts.py b/tests/acceptance/core_scripts.py
> index c2fe4acf1d..7380f2f49b 100644
> --- a/tests/acceptance/core_scripts.py
> +++ b/tests/acceptance/core_scripts.py
> @@ -16,6 +16,7 @@ import logging
>   
>   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_machines
>   from qemu.binutils import binary_get_qom_implementations
> @@ -59,3 +60,12 @@ class PythonQemuCoreScripts(Test):
>           for t in type_impl:
>               logger.debug('type: {}'.format(t))
>           self.assertIn(type_name, type_impl)
> +
> +    def test_get_accels(self):
> +        logger = logging.getLogger('core')
> +        accels = binary_get_accels(self.qemu_bin)
> +        for a in accels:
> +            logger.debug('accel: {}'.format(a))
> +        self.assertNotIn("accel", accels)
> +        # qtest is always available
> +        self.assertIn("qtest", accels)
>
diff mbox series

Patch

diff --git a/python/qemu/binutils.py b/python/qemu/binutils.py
index 76f256f5d2..bba203bc8d 100644
--- a/python/qemu/binutils.py
+++ b/python/qemu/binutils.py
@@ -86,3 +86,13 @@  def binary_get_qom_implementations(qemu_bin, type_name, include_abstract=False):
         LOG.info(res)
         vm.shutdown()
         return [m['name'] for m in res]
+
+def binary_get_accels(qemu_bin):
+    '''
+    Get list of accelerators supported by a QEMU binary
+
+    @param qemu_bin (str): path to the QEMU binary
+    @return list of accelerators supported by the binary
+    '''
+    accel_types = binary_get_qom_implementations(qemu_bin, "accel", False)
+    return [a.strip("-accel") for a in accel_types]
diff --git a/tests/acceptance/core_scripts.py b/tests/acceptance/core_scripts.py
index c2fe4acf1d..7380f2f49b 100644
--- a/tests/acceptance/core_scripts.py
+++ b/tests/acceptance/core_scripts.py
@@ -16,6 +16,7 @@  import logging
 
 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_machines
 from qemu.binutils import binary_get_qom_implementations
@@ -59,3 +60,12 @@  class PythonQemuCoreScripts(Test):
         for t in type_impl:
             logger.debug('type: {}'.format(t))
         self.assertIn(type_name, type_impl)
+
+    def test_get_accels(self):
+        logger = logging.getLogger('core')
+        accels = binary_get_accels(self.qemu_bin)
+        for a in accels:
+            logger.debug('accel: {}'.format(a))
+        self.assertNotIn("accel", accels)
+        # qtest is always available
+        self.assertIn("qtest", accels)