oeqa: Fix for QEMU_USE_KVM
v2 cover oeqa: Fix for QEMU_USE_KVM
* V2:
- Fix RP's comments:
Enable KVM if the target arch matches build arch.
* V1:
- Initial version
// Robert
The following changes since commit c22b0bf66a28324da66caf0660f171cc279a1f2b:
cmake-native: Set --parallel for configure (2019-01-03 21:14:47 +0000)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib rbt/kvm
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=rbt/kvm
Robert Yang (3):
oeqa: Fix for QEMU_USE_KVM oeqa/manual/bsp-qemu.json: Update for QEMU_USE_KVM oeqa/selftest/runqemu: Enable kvm when QEMU_USE_KVM is set
meta/classes/testimage.bbclass | 8 +------- meta/lib/oe/types.py | 24 ++++++++++++++++++++++++ meta/lib/oeqa/manual/bsp-qemu.json | 4 ++-- meta/lib/oeqa/selftest/cases/runqemu.py | 5 +++++ meta/lib/oeqa/targetcontrol.py | 8 +------- 5 files changed, 33 insertions(+), 16 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/3 oeqa: Fix for QEMU_USE_KVM
Fixed:
MACHINE = "qemux86"QEMU_USE_KVM = "qemux86"IMAGE_CLASSES += "testimage"
$ oe-selftest -r runqemu.RunqemuTests.test_boot_rootfs
[snip]
File "/buildarea1/lyang1/poky/meta/lib/oe/types.py", line 122, in boolean
raise ValueError("Invalid boolean value '%s'" % value)
ValueError: Invalid boolean value 'qemux86'
Now QEMU_USE_KVM can only be boolean, can not contain MACHINE any more, kvm will be enabled if target_arch == build_arch or both of them are x86 archs.
--- meta/classes/testimage.bbclass | 8 +------- meta/lib/oe/types.py | 24 ++++++++++++++++++++++++ meta/lib/oeqa/targetcontrol.py | 8 +------- 3 files changed, 26 insertions(+), 14 deletions(-)
meta/classes/testimage.bbclass +1 -7
@@ -231,13 +231,7 @@ def testimage_main(d): boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT")) # Get use_kvm - qemu_use_kvm = d.getVar("QEMU_USE_KVM") - if qemu_use_kvm and \ - (d.getVar('MACHINE') in qemu_use_kvm.split() or \ - oe.types.boolean(qemu_use_kvm) and 'x86' in machine): - kvm = True - else: - kvm = False + kvm = oe.types.qemu_use_kvm(d.getVar('QEMU_USE_KVM'), d.getVar('TARGET_ARCH')) slirp = False if d.getVar("QEMU_USE_SLIRP"):
meta/lib/oe/types.py +24 -0
@@ -156,3 +156,27 @@ 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) or arch == 'ia64': + 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 +
meta/lib/oeqa/targetcontrol.py +1 -7
@@ -107,13 +107,7 @@ class QemuTarget(BaseTarget): dump_target_cmds = d.getVar("testimage_dump_target") dump_host_cmds = d.getVar("testimage_dump_host") dump_dir = d.getVar("TESTIMAGE_DUMP_DIR") - qemu_use_kvm = d.getVar("QEMU_USE_KVM") - if qemu_use_kvm and \ - (oe.types.boolean(qemu_use_kvm) and "x86" in d.getVar("MACHINE") or \ - d.getVar("MACHINE") in qemu_use_kvm.split()): - use_kvm = True - else: - use_kvm = False + use_kvm = oe.types.qemu_use_kvm(d.getVar('QEMU_USE_KVM'), d.getVar('TARGET_ARCH')) # Log QemuRunner log output to a file import oe.path
Signature · 1 line
2.7.4
Quoted 18 lines · Robert Yang
Fixed:
MACHINE = "qemux86"QEMU_USE_KVM= "qemux86"IMAGE_CLASSES+= "testimage"$ oe-selftest -r runqemu.RunqemuTests.test_boot_rootfs[snip]
File "/buildarea1/lyang1/poky/meta/lib/oe/types.py", line 122, in
boolean
raiseValueError("Invalid boolean value '%s'" % value)
ValueError: Invalid boolean value 'qemux86'Now
QEMU_USE_KVMcan only be boolean, can not contain MACHINE any more, kvm
will be enabled iftarget_arch==build_archor both of them are x86 archs.
[...]
Quoted 7 lines
meta/lib/oe/types.py +5
-0+def is_x86(arch): + """ + Check whether arch is x86 or x86_64 + """ + if arch.startswith('x86_') or re.match('i.*86', arch) or arch =='ia64':
+ return True
Thanks, I've queued this for testing. I did remove the ia64 test here as ia64 is itanium which can't do x86 KVM from what I know.
We may also need to add something for arm == aarch64 comparisons, I'm not 100% sure what is supproted. I've cc'd Jon on that...
Cheers,
Richard
PATCH v2 2/3 oeqa/manual/bsp-qemu.json: Update for QEMU_USE_KVM
In reply to Robert YangNow QEMU_USE_KVM can only be boolean, can not contain MACHINE any more.
--- meta/lib/oeqa/manual/bsp-qemu.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/lib/oeqa/manual/bsp-qemu.json +2 -2
@@ -10,7 +10,7 @@ ], "execution": { "1": { - "action": "Build a kernel with KVM enabled \n\nIn Local.conf add \n\nQEMU_USE_KVM = \"${@ 'intel-corei7-64 intel-core2-32 qemux86 qemux86-64' if os.access('/dev/kvm', os.R_OK|os.W_OK) else '' }\" \n\n ", + "action": "Build a kernel with KVM enabled \n\nIn Local.conf add \n\nQEMU_USE_KVM = \"${@ '1' if os.access('/dev/kvm', os.R_OK|os.W_OK) else '0' }\" \n\n ", "expected_results": "" }, "2": {
@@ -219,4 +219,4 @@ "summary": "check_bash_in_image" } } -] +]
Signature · 1 line
2.7.4
PATCH v2 3/3 oeqa/selftest/runqemu: Enable kvm when QEMU_USE_KVM is set
In reply to Robert Yang--- meta/lib/oeqa/selftest/cases/runqemu.py | 5 +++++ 1 file changed, 5 insertions(+)
meta/lib/oeqa/selftest/cases/runqemu.py +5 -0
@@ -5,6 +5,7 @@ import re import tempfile import time +import oe.types from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import bitbake, runqemu, get_bb_var, runCmd from oeqa.core.decorator.oeid import OETestID
@@ -22,6 +23,10 @@ class RunqemuTests(OESelftestTestCase): self.fstypes = "ext4 iso hddimg wic.vmdk wic.qcow2 wic.vdi" self.cmd_common = "runqemu nographic" + kvm = oe.types.qemu_use_kvm(get_bb_var('QEMU_USE_KVM'), 'x86_64') + if kvm: + self.cmd_common += " kvm" + self.write_config( """ MACHINE = "%s"
Signature · 1 line
2.7.4