@@ -288,7 +288,7 @@ def testimage_main(d):
boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT"))
# Get use_kvm
- kvm = oe.types.qemu_use_kvm(d.getVar('QEMU_USE_KVM'), d.getVar('TARGET_ARCH'))
+ kvm = oe.qemu.qemu_use_kvm(d.getVar('QEMU_USE_KVM'), d.getVar('TARGET_ARCH'))
# Get OVMF
ovmf = d.getVar("QEMU_USE_OVMF")
@@ -52,3 +52,27 @@ def qemu_run_binary(d, rootfs_path, binary):
base_libdir = rootfs_path + d.getVar("base_libdir", False)
return qemu_wrapper_cmdline(d, rootfs_path, [libdir, base_libdir]) + rootfs_path + binary
+
+def is_x86(arch):
+ """
+ Check whether ``arch`` is ``x86`` or ``x86_64``, return ``True`` if it is,
+ ``False`` otherwise.
+ """
+ if arch.startswith('x86_') or re.match('i.*86', arch):
+ return True
+ else:
+ return False
+
+def qemu_use_kvm(kvm, target_arch):
+ """
+ Enable kvm if target_arch == build_arch or both of them are x86 archs.
+ """
+
+ use_kvm = False
+ if kvm and boolean(kvm):
+ build_arch = os.uname()[4]
+ if is_x86(build_arch) and is_x86(target_arch):
+ use_kvm = True
+ elif build_arch == target_arch:
+ use_kvm = True
+ return use_kvm
@@ -163,26 +163,3 @@ def path(value, relativeto='', normalize='true', mustexist='false'):
raise ValueError("{0}: {1}".format(value, os.strerror(errno.ENOENT)))
return value
-
-def is_x86(arch):
- """
- Check whether arch is x86 or x86_64
- """
- if arch.startswith('x86_') or re.match('i.*86', arch):
- return True
- else:
- return False
-
-def qemu_use_kvm(kvm, target_arch):
- """
- Enable kvm if target_arch == build_arch or both of them are x86 archs.
- """
-
- use_kvm = False
- if kvm and boolean(kvm):
- build_arch = os.uname()[4]
- if is_x86(build_arch) and is_x86(target_arch):
- use_kvm = True
- elif build_arch == target_arch:
- use_kvm = True
- return use_kvm
@@ -17,7 +17,7 @@ class GenericEFITest(OESelftestTestCase):
image = "core-image-minimal"
runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', image) or ""
cmd = "runqemu %s nographic serial wic ovmf" % (runqemu_params)
- if oe.types.qemu_use_kvm(self.td.get('QEMU_USE_KVM', 0), self.td["TARGET_ARCH"]):
+ if oe.qemu.qemu_use_kvm(self.td.get('QEMU_USE_KVM', 0), self.td["TARGET_ARCH"]):
cmd += " kvm"
self.write_config("""
@@ -34,7 +34,7 @@ class RunqemuTests(OESelftestTestCase):
self.fstypes += " wic.vmdk wic.qcow2 wic.vdi wic.zst"
self.cmd_common = "runqemu nographic snapshot"
- kvm = oe.types.qemu_use_kvm(get_bb_var('QEMU_USE_KVM'), self.td["TARGET_ARCH"])
+ kvm = oe.qemu.qemu_use_kvm(get_bb_var('QEMU_USE_KVM'), self.td["TARGET_ARCH"])
if kvm:
self.cmd_common += " kvm"
@@ -21,7 +21,7 @@ class UkiTest(OESelftestTestCase):
image = "core-image-minimal"
runqemu_params = get_bb_var('TEST_RUNQEMUPARAMS', image) or ""
cmd = "runqemu %s nographic serial wic ovmf" % (runqemu_params)
- if oe.types.qemu_use_kvm(self.td.get('QEMU_USE_KVM', 0), self.td["TARGET_ARCH"]):
+ if oe.qemu.qemu_use_kvm(self.td.get('QEMU_USE_KVM', 0), self.td["TARGET_ARCH"]):
cmd += " kvm"
self.write_config("""
@@ -108,7 +108,7 @@ class QemuTarget(BaseTarget):
dump_dir = d.getVar("TESTIMAGE_DUMP_DIR")
if not dump_dir:
dump_dir = os.path.join(d.getVar('LOG_DIR'), 'runtime-hostdump')
- use_kvm = oe.types.qemu_use_kvm(d.getVar('QEMU_USE_KVM'), d.getVar('TARGET_ARCH'))
+ use_kvm = oe.qemu.qemu_use_kvm(d.getVar('QEMU_USE_KVM'), d.getVar('TARGET_ARCH'))
# Log QemuRunner log output to a file
import oe.path
The oe.types library represents OpenEmbedded types such as booleans, integers, etc. which is unrelated to what these two functions do: is_x86() checks if a given arch matches the x86 architecture, and qemu_use_kvm() is used to return True to enable KVM based on the current target architecture. Move these two functions to oe.qemu which is more appropriate. Adapt usage in OE-Core as a consequence. Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> --- meta/classes-recipe/testimage.bbclass | 2 +- meta/lib/oe/qemu.py | 24 ++++++++++++++++++++++++ meta/lib/oe/types.py | 23 ----------------------- meta/lib/oeqa/selftest/cases/efibootpartition.py | 2 +- meta/lib/oeqa/selftest/cases/runqemu.py | 2 +- meta/lib/oeqa/selftest/cases/uki.py | 2 +- meta/lib/oeqa/targetcontrol.py | 2 +- 7 files changed, 29 insertions(+), 28 deletions(-)