[OE-core] [PATCH 1/2] oeqa: Fix for QEMU_USE_KVM

Robert Yang liezhi.yang at windriver.com
Thu Jan 3 08:04:59 UTC 2019


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'

Signed-off-by: Robert Yang <liezhi.yang at windriver.com>
---
 meta/classes/testimage.bbclass |  8 +-------
 meta/lib/oe/types.py           | 18 ++++++++++++++++++
 meta/lib/oeqa/targetcontrol.py |  8 +-------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index e8fa4a3..82aef9f 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -230,13 +230,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('MACHINE'))
 
     slirp = False
     if d.getVar("QEMU_USE_SLIRP"):
diff --git a/meta/lib/oe/types.py b/meta/lib/oe/types.py
index f401713..a153f2c 100644
--- a/meta/lib/oe/types.py
+++ b/meta/lib/oe/types.py
@@ -156,3 +156,21 @@ def path(value, relativeto='', normalize='true', mustexist='false'):
                 raise ValueError("{0}: {1}".format(value, os.strerror(errno.ENOENT)))
 
     return value
+
+def qemu_use_kvm(kvm, machine):
+    """
+    kvm can be:
+    - bool: 0, yes, ...
+    - MACHINEs: qemux86 qemux86-64 ...
+    """
+    use_kvm = False
+    if kvm:
+        kvm_boolean = False
+        try:
+            kvm_boolean = boolean(kvm)
+        except ValueError:
+            pass
+        if (kvm_boolean and "x86" in machine) or (machine in kvm.split()):
+            use_kvm = True
+    return use_kvm
+
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index 59a9c35..980d6a2 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -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('MACHINE'))
 
         # Log QemuRunner log output to a file
         import oe.path
-- 
2.7.4



More information about the Openembedded-core mailing list