qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 12/29] python/qemu/accel: Use binutils::binary_get_accels(


From: Liam Merwick
Subject: Re: [PATCH v2 12/29] python/qemu/accel: Use binutils::binary_get_accels()
Date: Fri, 7 Feb 2020 14:37:24 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 29/01/2020 21:23, Philippe Mathieu-Daudé wrote:
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>


Reviewed-by: Liam Merwick <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)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]