[PATCH v2 25/26] tests/functional: Add hvf_available() helper

Philippe Mathieu-Daudé posted 26 patches 4 months, 4 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Radoslaw Biernacki <rad@semihalf.com>, Peter Maydell <peter.maydell@linaro.org>, Leif Lindholm <leif.lindholm@oss.qualcomm.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>, Alexander Graf <agraf@csgraf.de>, Thomas Huth <thuth@redhat.com>, Bernhard Beschow <shentey@gmail.com>, Eric Auger <eric.auger@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>
There is a newer version of this series
[PATCH v2 25/26] tests/functional: Add hvf_available() helper
Posted by Philippe Mathieu-Daudé 4 months, 4 weeks ago
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 python/qemu/utils/__init__.py          | 2 +-
 python/qemu/utils/accel.py             | 8 ++++++++
 tests/functional/qemu_test/testcase.py | 6 ++++--
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/python/qemu/utils/__init__.py b/python/qemu/utils/__init__.py
index 017cfdcda75..d2fe5db223c 100644
--- a/python/qemu/utils/__init__.py
+++ b/python/qemu/utils/__init__.py
@@ -23,7 +23,7 @@
 from typing import Optional
 
 # pylint: disable=import-error
-from .accel import kvm_available, list_accel, tcg_available
+from .accel import hvf_available, kvm_available, list_accel, tcg_available
 
 
 __all__ = (
diff --git a/python/qemu/utils/accel.py b/python/qemu/utils/accel.py
index 386ff640ca8..376d1e30005 100644
--- a/python/qemu/utils/accel.py
+++ b/python/qemu/utils/accel.py
@@ -82,3 +82,11 @@ def tcg_available(qemu_bin: str) -> bool:
     @param qemu_bin (str): path to the QEMU binary
     """
     return 'tcg' in list_accel(qemu_bin)
+
+def hvf_available(qemu_bin: str) -> bool:
+    """
+    Check if HVF is available.
+
+    @param qemu_bin (str): path to the QEMU binary
+    """
+    return 'hvf' in list_accel(qemu_bin)
diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index 50c401b8c3c..2082c6fce43 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -23,7 +23,7 @@
 import uuid
 
 from qemu.machine import QEMUMachine
-from qemu.utils import kvm_available, tcg_available
+from qemu.utils import hvf_available, kvm_available, tcg_available
 
 from .archive import archive_extract
 from .asset import Asset
@@ -317,7 +317,9 @@ def require_accelerator(self, accelerator):
         :type accelerator: str
         """
         checker = {'tcg': tcg_available,
-                   'kvm': kvm_available}.get(accelerator)
+                   'kvm': kvm_available,
+                   'hvf': hvf_available,
+                  }.get(accelerator)
         if checker is None:
             self.skipTest("Don't know how to check for the presence "
                           "of accelerator %s" % accelerator)
-- 
2.49.0


Re: [PATCH v2 25/26] tests/functional: Add hvf_available() helper
Posted by Thomas Huth 4 months, 3 weeks ago
On 20/06/2025 15.07, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   python/qemu/utils/__init__.py          | 2 +-
>   python/qemu/utils/accel.py             | 8 ++++++++
>   tests/functional/qemu_test/testcase.py | 6 ++++--
>   3 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/python/qemu/utils/__init__.py b/python/qemu/utils/__init__.py
> index 017cfdcda75..d2fe5db223c 100644
> --- a/python/qemu/utils/__init__.py
> +++ b/python/qemu/utils/__init__.py
> @@ -23,7 +23,7 @@
>   from typing import Optional
>   
>   # pylint: disable=import-error
> -from .accel import kvm_available, list_accel, tcg_available
> +from .accel import hvf_available, kvm_available, list_accel, tcg_available
>   
>   
>   __all__ = (
> diff --git a/python/qemu/utils/accel.py b/python/qemu/utils/accel.py
> index 386ff640ca8..376d1e30005 100644
> --- a/python/qemu/utils/accel.py
> +++ b/python/qemu/utils/accel.py
> @@ -82,3 +82,11 @@ def tcg_available(qemu_bin: str) -> bool:
>       @param qemu_bin (str): path to the QEMU binary
>       """
>       return 'tcg' in list_accel(qemu_bin)
> +
> +def hvf_available(qemu_bin: str) -> bool:
> +    """
> +    Check if HVF is available.
> +
> +    @param qemu_bin (str): path to the QEMU binary
> +    """
> +    return 'hvf' in list_accel(qemu_bin)
> diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
> index 50c401b8c3c..2082c6fce43 100644
> --- a/tests/functional/qemu_test/testcase.py
> +++ b/tests/functional/qemu_test/testcase.py
> @@ -23,7 +23,7 @@
>   import uuid
>   
>   from qemu.machine import QEMUMachine
> -from qemu.utils import kvm_available, tcg_available
> +from qemu.utils import hvf_available, kvm_available, tcg_available
>   
>   from .archive import archive_extract
>   from .asset import Asset
> @@ -317,7 +317,9 @@ def require_accelerator(self, accelerator):
>           :type accelerator: str
>           """
>           checker = {'tcg': tcg_available,
> -                   'kvm': kvm_available}.get(accelerator)
> +                   'kvm': kvm_available,
> +                   'hvf': hvf_available,
> +                  }.get(accelerator)
>           if checker is None:
>               self.skipTest("Don't know how to check for the presence "
>                             "of accelerator %s" % accelerator)

Reviewed-by: Thomas Huth <thuth@redhat.com>


Re: [PATCH v2 25/26] tests/functional: Add hvf_available() helper
Posted by Richard Henderson 4 months, 3 weeks ago
On 6/20/25 06:07, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   python/qemu/utils/__init__.py          | 2 +-
>   python/qemu/utils/accel.py             | 8 ++++++++
>   tests/functional/qemu_test/testcase.py | 6 ++++--
>   3 files changed, 13 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~