[PATCH] python/qemu: fix accelerator detection with annotated -accel help

marcandre.lureau@redhat.com posted 1 patch 1 week, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261112112956.361209-2-marcandre.lureau@redhat.com
Maintainers: John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>
python/qemu/utils/accel.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH] python/qemu: fix accelerator detection with annotated -accel help
Posted by marcandre.lureau@redhat.com 1 week, 3 days ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

QEMU annotates the accelerator names in "-accel help" with their
security status, eg "kvm (secure)". kvm_available() compares the
entries with the plain accelerator name, so the check fails and
functional tests using require_accelerator('kvm') are silently
skipped.

Keep only the accelerator name of each line.

fwiw, I am surprised we don't seem to have a CI that exercice functional
kvm tests, or compare against a baseline to avoid this kind of
regression.

Fixes: d3b770fc6342 ("system: report acclerator security status in help output")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 python/qemu/utils/accel.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/python/qemu/utils/accel.py b/python/qemu/utils/accel.py
index f915b646692e..7e3f43d6b489 100644
--- a/python/qemu/utils/accel.py
+++ b/python/qemu/utils/accel.py
@@ -47,8 +47,9 @@ def list_accel(qemu_bin: str) -> List[str]:
     except:
         LOG.debug("Failed to get the list of accelerators in %s", qemu_bin)
         raise
-    # Skip the first line which is the header.
-    return [acc.strip() for acc in out.splitlines()[1:]]
+    # Skip the first line which is the header, and drop annotations
+    # such as " (secure)" from the accelerator names.
+    return [acc.split(' ')[0] for acc in out.splitlines()[1:]]
 
 
 def kvm_available(target_arch: Optional[str] = None,
-- 
2.56.0.116.g6de20f6092dc


Re: [PATCH] python/qemu: fix accelerator detection with annotated -accel help
Posted by John Snow 6 days, 11 hours ago
On Thu, Nov 12, 2026 at 6:30 AM <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> QEMU annotates the accelerator names in "-accel help" with their
> security status, eg "kvm (secure)". kvm_available() compares the
> entries with the plain accelerator name, so the check fails and
> functional tests using require_accelerator('kvm') are silently
> skipped.
>
> Keep only the accelerator name of each line.
>
> fwiw, I am surprised we don't seem to have a CI that exercice functional
> kvm tests, or compare against a baseline to avoid this kind of
> regression.
>
> Fixes: d3b770fc6342 ("system: report acclerator security status in help output")
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  python/qemu/utils/accel.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/python/qemu/utils/accel.py b/python/qemu/utils/accel.py
> index f915b646692e..7e3f43d6b489 100644
> --- a/python/qemu/utils/accel.py
> +++ b/python/qemu/utils/accel.py
> @@ -47,8 +47,9 @@ def list_accel(qemu_bin: str) -> List[str]:
>      except:
>          LOG.debug("Failed to get the list of accelerators in %s", qemu_bin)
>          raise
> -    # Skip the first line which is the header.
> -    return [acc.strip() for acc in out.splitlines()[1:]]
> +    # Skip the first line which is the header, and drop annotations
> +    # such as " (secure)" from the accelerator names.
> +    return [acc.split(' ')[0] for acc in out.splitlines()[1:]]
>
>
>  def kvm_available(target_arch: Optional[str] = None,
> --
> 2.56.0.116.g6de20f6092dc
>

adding to python staging and will send a pull alongside 3.15 support
(pending tests)

--js
Re: [PATCH] python/qemu: fix accelerator detection with annotated -accel help
Posted by Daniel P. Berrangé 1 week, 2 days ago
On Thu, Nov 12, 2026 at 03:29:56PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> QEMU annotates the accelerator names in "-accel help" with their
> security status, eg "kvm (secure)". kvm_available() compares the
> entries with the plain accelerator name, so the check fails and
> functional tests using require_accelerator('kvm') are silently
> skipped.
> 
> Keep only the accelerator name of each line.
> 
> fwiw, I am surprised we don't seem to have a CI that exercice functional
> kvm tests, or compare against a baseline to avoid this kind of
> regression.

We've intentionally designed our test suite to quietly skip
test with features are detected, so it is hard to detect
when the feature detection itself is not right, as that is
indistinguishable from the feature not being present.

We would need a way to instruct it to abort if the expected
feature is not present, and declare what features each CI
test expects upfront.

> 
> Fixes: d3b770fc6342 ("system: report acclerator security status in help output")
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  python/qemu/utils/accel.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>



> 
> diff --git a/python/qemu/utils/accel.py b/python/qemu/utils/accel.py
> index f915b646692e..7e3f43d6b489 100644
> --- a/python/qemu/utils/accel.py
> +++ b/python/qemu/utils/accel.py
> @@ -47,8 +47,9 @@ def list_accel(qemu_bin: str) -> List[str]:
>      except:
>          LOG.debug("Failed to get the list of accelerators in %s", qemu_bin)
>          raise
> -    # Skip the first line which is the header.
> -    return [acc.strip() for acc in out.splitlines()[1:]]
> +    # Skip the first line which is the header, and drop annotations
> +    # such as " (secure)" from the accelerator names.
> +    return [acc.split(' ')[0] for acc in out.splitlines()[1:]]
>  
>  
>  def kvm_available(target_arch: Optional[str] = None,
> -- 
> 2.56.0.116.g6de20f6092dc
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|