diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2018-10-13 02:40:26 +0200 |
---|---|---|
committer | Fam Zheng <famz@redhat.com> | 2018-10-26 22:03:21 +0800 |
commit | b59b82ededdde6ec3e63a666f5c0cfb5a3f22e2e (patch) | |
tree | 3d5a2686de28ac346fa6dc1a67e2fbde24e438c4 | |
parent | 1578466c9a744be17c755875dcb1e638b534a249 (diff) | |
download | qemu-b59b82ededdde6ec3e63a666f5c0cfb5a3f22e2e.zip qemu-b59b82ededdde6ec3e63a666f5c0cfb5a3f22e2e.tar.gz qemu-b59b82ededdde6ec3e63a666f5c0cfb5a3f22e2e.tar.bz2 |
tests/vm: Extract the kvm_available() handy function
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20181013004034.6968-2-f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Fam Zheng <famz@redhat.com>
-rw-r--r-- | scripts/qemu.py | 4 | ||||
-rwxr-xr-x | tests/vm/basevm.py | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/scripts/qemu.py b/scripts/qemu.py index f099ce7..9fc0be4 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -26,6 +26,10 @@ import tempfile LOG = logging.getLogger(__name__) +def kvm_available(target_arch=None): + return os.access("/dev/kvm", os.R_OK | os.W_OK) + + #: Maps machine types to the preferred console device types CONSOLE_DEV_TYPES = { r'^clipper$': 'isa-serial', diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index cafbc6b..834bc90 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -18,7 +18,7 @@ import logging import time import datetime sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scripts")) -from qemu import QEMUMachine +from qemu import QEMUMachine, kvm_available import subprocess import hashlib import optparse @@ -72,7 +72,7 @@ class BaseVM(object): "-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")] if vcpus: self._args += ["-smp", str(vcpus)] - if os.access("/dev/kvm", os.R_OK | os.W_OK): + if kvm_available(): self._args += ["-enable-kvm"] else: logging.info("KVM not available, not using -enable-kvm") |