Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] oeqa: Fix for QEMU_USE_KVM
@ 2019-01-03  8:04 Robert Yang
  2019-01-03  8:04 ` [PATCH 1/2] " Robert Yang
  2019-01-03  8:05 ` [PATCH 2/2] oeqa/selftest/runqemu: enable kvm when QEMU_USE_KVM is set Robert Yang
  0 siblings, 2 replies; 5+ messages in thread
From: Robert Yang @ 2019-01-03  8:04 UTC (permalink / raw)
  To: openembedded-core

The following changes since commit caa776bdcf8ea34c857f45970370bf771075f4bc:

  testimage.bbclass: remove boot parameter systemd.log_target (2018-12-27 22:50:01 +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 (2):
  oeqa: Fix 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                    | 18 ++++++++++++++++++
 meta/lib/oeqa/selftest/cases/runqemu.py |  5 +++++
 meta/lib/oeqa/targetcontrol.py          |  8 +-------
 4 files changed, 25 insertions(+), 14 deletions(-)

-- 
2.7.4



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

* [PATCH 1/2] oeqa: Fix for QEMU_USE_KVM
  2019-01-03  8:04 [PATCH 0/2] oeqa: Fix for QEMU_USE_KVM Robert Yang
@ 2019-01-03  8:04 ` Robert Yang
  2019-01-03 22:33   ` Richard Purdie
  2019-01-03  8:05 ` [PATCH 2/2] oeqa/selftest/runqemu: enable kvm when QEMU_USE_KVM is set Robert Yang
  1 sibling, 1 reply; 5+ messages in thread
From: Robert Yang @ 2019-01-03  8:04 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'

Signed-off-by: Robert Yang <liezhi.yang@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



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

* [PATCH 2/2] oeqa/selftest/runqemu: enable kvm when QEMU_USE_KVM is set
  2019-01-03  8:04 [PATCH 0/2] oeqa: Fix for QEMU_USE_KVM Robert Yang
  2019-01-03  8:04 ` [PATCH 1/2] " Robert Yang
@ 2019-01-03  8:05 ` Robert Yang
  1 sibling, 0 replies; 5+ messages in thread
From: Robert Yang @ 2019-01-03  8:05 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..0b664b4 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'), self.machine)
+        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 1/2] oeqa: Fix for QEMU_USE_KVM
  2019-01-03  8:04 ` [PATCH 1/2] " Robert Yang
@ 2019-01-03 22:33   ` Richard Purdie
  2019-01-04  7:03     ` Robert Yang
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Purdie @ 2019-01-03 22:33 UTC (permalink / raw)
  To: Robert Yang, openembedded-core

On Thu, 2019-01-03 at 16:04 +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'
> 
> Signed-off-by: Robert Yang <liezhi.yang@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


There have been a few patches related to this floating around. I'd like
to fix this once and for all but we don't have a patch which quite gets
this to where it needs to be.

I'd suggest we:

a) drop the approach of having MACHINE in the variable and simply have
it either set to enabled or disabled

b) only enable KVM if the target arch matches the host arch


For b) I'd like to cover the case where qemuarm64 is being run on an
aarch64 server.

This way we'd automatically enable KVM where the arch matches rather
than needing to code it for each MACHINE.

Does that make sense?

Cheers,

Richard





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

* Re: [PATCH 1/2] oeqa: Fix for QEMU_USE_KVM
  2019-01-03 22:33   ` Richard Purdie
@ 2019-01-04  7:03     ` Robert Yang
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Yang @ 2019-01-04  7:03 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core



On 1/4/19 6:33 AM, Richard Purdie wrote:
> On Thu, 2019-01-03 at 16:04 +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'
>>
>> Signed-off-by: Robert Yang <liezhi.yang@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
> 
> 
> There have been a few patches related to this floating around. I'd like
> to fix this once and for all but we don't have a patch which quite gets
> this to where it needs to be.
> 
> I'd suggest we:
> 
> a) drop the approach of having MACHINE in the variable and simply have
> it either set to enabled or disabled
> 
> b) only enable KVM if the target arch matches the host arch
> 
> 
> For b) I'd like to cover the case where qemuarm64 is being run on an
> aarch64 server.
> 
> This way we'd automatically enable KVM where the arch matches rather
> than needing to code it for each MACHINE.
> 
> Does that make sense?

Thanks, that make sense, I've sent a v2 for it:

[OE-core] [PATCH v2 0/3] oeqa: Fix for QEMU_USE_KVM

// Robert

> 
> Cheers,
> 
> Richard
> 
> 
> 
> 


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

end of thread, other threads:[~2019-01-04  6:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-03  8:04 [PATCH 0/2] oeqa: Fix for QEMU_USE_KVM Robert Yang
2019-01-03  8:04 ` [PATCH 1/2] " Robert Yang
2019-01-03 22:33   ` Richard Purdie
2019-01-04  7:03     ` Robert Yang
2019-01-03  8:05 ` [PATCH 2/2] oeqa/selftest/runqemu: enable kvm when QEMU_USE_KVM is set Robert Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox