All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] oeqa: Fix for QEMU_USE_KVM
@ 2019-01-04  7:15 Robert Yang
  2019-01-04  7:15 ` [PATCH v2 1/3] " Robert Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Robert Yang @ 2019-01-04  7:15 UTC (permalink / raw)
  To: openembedded-core

* 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(-)

-- 
2.7.4



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] oeqa: Fix for QEMU_USE_KVM
  2019-01-04  7:15 [PATCH v2 0/3] oeqa: Fix for QEMU_USE_KVM Robert Yang
@ 2019-01-04  7:15 ` Robert Yang
  2019-01-07 15:24   ` Richard Purdie
  2019-01-04  7:15 ` [PATCH v2 2/3] oeqa/manual/bsp-qemu.json: Update " Robert Yang
  2019-01-04  7:15 ` [PATCH v2 3/3] oeqa/selftest/runqemu: Enable kvm when QEMU_USE_KVM is set Robert Yang
  2 siblings, 1 reply; 5+ messages in thread
From: Robert Yang @ 2019-01-04  7:15 UTC (permalink / raw)
  To: openembedded-core

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.

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

diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 3c2209a..73cd375 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -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"):
diff --git a/meta/lib/oe/types.py b/meta/lib/oe/types.py
index f401713..b9462e0 100644
--- a/meta/lib/oe/types.py
+++ b/meta/lib/oe/types.py
@@ -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
+
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index 59a9c35..288e747 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('TARGET_ARCH'))
 
         # Log QemuRunner log output to a file
         import oe.path
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] oeqa/manual/bsp-qemu.json: Update for QEMU_USE_KVM
  2019-01-04  7:15 [PATCH v2 0/3] oeqa: Fix for QEMU_USE_KVM Robert Yang
  2019-01-04  7:15 ` [PATCH v2 1/3] " Robert Yang
@ 2019-01-04  7:15 ` Robert Yang
  2019-01-04  7:15 ` [PATCH v2 3/3] oeqa/selftest/runqemu: Enable kvm when QEMU_USE_KVM is set Robert Yang
  2 siblings, 0 replies; 5+ messages in thread
From: Robert Yang @ 2019-01-04  7:15 UTC (permalink / raw)
  To: openembedded-core

Now QEMU_USE_KVM can only be boolean, can not contain MACHINE any more.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/lib/oeqa/manual/bsp-qemu.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/lib/oeqa/manual/bsp-qemu.json b/meta/lib/oeqa/manual/bsp-qemu.json
index 1260af4..cf51b6a 100644
--- a/meta/lib/oeqa/manual/bsp-qemu.json
+++ b/meta/lib/oeqa/manual/bsp-qemu.json
@@ -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"
     }
   }
-]
\ No newline at end of file
+]
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] oeqa/selftest/runqemu: Enable kvm when QEMU_USE_KVM is set
  2019-01-04  7:15 [PATCH v2 0/3] oeqa: Fix for QEMU_USE_KVM Robert Yang
  2019-01-04  7:15 ` [PATCH v2 1/3] " Robert Yang
  2019-01-04  7:15 ` [PATCH v2 2/3] oeqa/manual/bsp-qemu.json: Update " Robert Yang
@ 2019-01-04  7:15 ` Robert Yang
  2 siblings, 0 replies; 5+ messages in thread
From: Robert Yang @ 2019-01-04  7:15 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/lib/oeqa/selftest/cases/runqemu.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/runqemu.py b/meta/lib/oeqa/selftest/cases/runqemu.py
index 4e35bb9..f69d470 100644
--- a/meta/lib/oeqa/selftest/cases/runqemu.py
+++ b/meta/lib/oeqa/selftest/cases/runqemu.py
@@ -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"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/3] oeqa: Fix for QEMU_USE_KVM
  2019-01-04  7:15 ` [PATCH v2 1/3] " Robert Yang
@ 2019-01-07 15:24   ` Richard Purdie
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Purdie @ 2019-01-07 15:24 UTC (permalink / raw)
  To: Robert Yang, openembedded-core; +Cc: Jon Mason

On Fri, 2019-01-04 at 15:15 +0800, Robert Yang wrote:
> 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.
> 
[...]
> +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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-07 15:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-04  7:15 [PATCH v2 0/3] oeqa: Fix for QEMU_USE_KVM Robert Yang
2019-01-04  7:15 ` [PATCH v2 1/3] " Robert Yang
2019-01-07 15:24   ` Richard Purdie
2019-01-04  7:15 ` [PATCH v2 2/3] oeqa/manual/bsp-qemu.json: Update " Robert Yang
2019-01-04  7:15 ` [PATCH v2 3/3] oeqa/selftest/runqemu: Enable kvm when QEMU_USE_KVM is set Robert Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.