[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/29] python/qemu/accel: Use binutils::binary_get_accels()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 12/29] python/qemu/accel: Use binutils::binary_get_accels() |
Date: |
Wed, 29 Jan 2020 22:23:28 +0100 |
Instead of parsing the process help output, use the
binary_get_accels() helper which queries the list of
accelerators over a QMP socket.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
python/qemu/accel.py | 26 ++++----------------------
1 file changed, 4 insertions(+), 22 deletions(-)
diff --git a/python/qemu/accel.py b/python/qemu/accel.py
index 0b38ddf0ab..cde51ae159 100644
--- a/python/qemu/accel.py
+++ b/python/qemu/accel.py
@@ -16,7 +16,8 @@ accelerators.
import logging
import os
-import subprocess
+
+from .binutils import binary_get_accels
LOG = logging.getLogger(__name__)
@@ -27,25 +28,6 @@ ADDITIONAL_ARCHES = {
"aarch64" : "armhf"
}
-def list_accel(qemu_bin):
- """
- List accelerators enabled in the QEMU binary.
-
- @param qemu_bin (str): path to the QEMU binary.
- @raise Exception: if failed to run `qemu -accel help`
- @return a list of accelerator names.
- """
- if not qemu_bin:
- return []
- try:
- out = subprocess.check_output([qemu_bin, '-accel', 'help'],
- universal_newlines=True)
- 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:]]
-
def kvm_available(target_arch=None, qemu_bin=None):
"""
Check if KVM is available using the following heuristic:
@@ -64,7 +46,7 @@ def kvm_available(target_arch=None, qemu_bin=None):
if target_arch != host_arch:
if target_arch != ADDITIONAL_ARCHES.get(host_arch):
return False
- if qemu_bin and "kvm" not in list_accel(qemu_bin):
+ if qemu_bin and "kvm" not in binary_get_accels(qemu_bin):
return False
return True
@@ -74,4 +56,4 @@ def tcg_available(qemu_bin):
@param qemu_bin (str): path to the QEMU binary
"""
- return 'tcg' in list_accel(qemu_bin)
+ return 'tcg' in binary_get_accels(qemu_bin)
--
2.21.1
- Re: [PATCH v2 04/29] tests/acceptance: Use 'version-min' tag to verify QEMU binary version, (continued)
[PATCH v2 05/29] tests/acceptance: Restrict X86CPUModelAliases test to QEMU >= 4.1, Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 06/29] python/qemu: Add binutils::binary_get_arch(), Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 07/29] tests/acceptance: Use the 'arch' tag to verify QEMU binary target, Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 08/29] python/qemu: Add binutils::binary_get_machines(), Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 10/29] python/qemu: Add binutils::binary_get_qom_implementations(), Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 09/29] tests/acceptance: Use 'machine' tag to check if available in QEMU binary, Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 11/29] python/qemu: Add binutils::binary_get_accels(), Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 12/29] python/qemu/accel: Use binutils::binary_get_accels(),
Philippe Mathieu-Daudé <=
[PATCH v2 13/29] python/qemu: Add binutils::binary_get_devices(), Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 15/29] tests: rename virtio_seg_max_adjust to virtio_check_params, Philippe Mathieu-Daudé, 2020/01/29
[RFC PATCH v2 14/29] tests/acceptance: Use 'device' tags to check availability in QEMU binary, Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 16/29] tests/acceptance/virtio_check_params: Only remove listed machines, Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 17/29] tests/acceptance/virtio_check_params: Improve exception logging, Philippe Mathieu-Daudé, 2020/01/29
[PATCH v2 19/29] tests/acceptance/virtio_check_params: Only test Xen as superuser, Philippe Mathieu-Daudé, 2020/01/29