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>
This commit is contained in:
parent
1578466c9a
commit
b59b82eded
|
@ -26,6 +26,10 @@ import tempfile
|
||||||
LOG = logging.getLogger(__name__)
|
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
|
#: Maps machine types to the preferred console device types
|
||||||
CONSOLE_DEV_TYPES = {
|
CONSOLE_DEV_TYPES = {
|
||||||
r'^clipper$': 'isa-serial',
|
r'^clipper$': 'isa-serial',
|
||||||
|
|
|
@ -18,7 +18,7 @@ import logging
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scripts"))
|
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scripts"))
|
||||||
from qemu import QEMUMachine
|
from qemu import QEMUMachine, kvm_available
|
||||||
import subprocess
|
import subprocess
|
||||||
import hashlib
|
import hashlib
|
||||||
import optparse
|
import optparse
|
||||||
|
@ -72,7 +72,7 @@ class BaseVM(object):
|
||||||
"-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")]
|
"-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")]
|
||||||
if vcpus:
|
if vcpus:
|
||||||
self._args += ["-smp", str(vcpus)]
|
self._args += ["-smp", str(vcpus)]
|
||||||
if os.access("/dev/kvm", os.R_OK | os.W_OK):
|
if kvm_available():
|
||||||
self._args += ["-enable-kvm"]
|
self._args += ["-enable-kvm"]
|
||||||
else:
|
else:
|
||||||
logging.info("KVM not available, not using -enable-kvm")
|
logging.info("KVM not available, not using -enable-kvm")
|
||||||
|
|
Loading…
Reference in a new issue