[1/1] oeqa: drop support of listing machines in QEMU_USE_KVM

Submitted by Qi.Chen@windriver.com on Dec. 6, 2018, 6:30 a.m. | Patch ID: 156951

Details

Message ID 4e980624cf550689a95a3847a3dc1103975b1d8c.1544066027.git.Qi.Chen@windriver.com
State New
Headers show

Commit Message

Qi.Chen@windriver.com Dec. 6, 2018, 6:30 a.m.
We want QEMU_USE_KVM to only set to some boolean value, with possible
MACHINE override. Drop the support of listing machines in this variable,
and give users error message if they still do so.

Error message below is an example.

ERROR: core-image-minimal-1.0-r0 do_testimage: Invalid boolean value 'intel-corei7-64 intel-core2-32 qemux86 qemux86-64'
QEMU_USE_KVM needs to be set to a boolean value. It no longer supports accepting a list of machines.
  e.g.
  QEMU_USE_KVM_qemux86-64 = '1'
ERROR: core-image-minimal-1.0-r0 do_testimage: Function failed: do_testimage

QB_CPU_KVM is also checked to determine whether to enable kvm.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/testimage.bbclass | 12 +++++++-----
 meta/lib/oeqa/targetcontrol.py | 12 +++++++-----
 2 files changed, 14 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 82cbb06..3353d133 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -229,11 +229,13 @@  def testimage_main(d):
 
     # 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:
+    try:
+        kvm = oe.types.boolean(qemu_use_kvm)
+    except ValueError as e:
+        bb.fatal("%s\nQEMU_USE_KVM needs to be set to a boolean value. It no longer supports accepting a list of machines.\n"
+                 "  e.g.\n"
+                 "  QEMU_USE_KVM_qemux86-64 = '1'" % e)
+    if kvm and not d.getVar('QB_CPU_KVM'):
         kvm = False
 
     slirp = False
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index 59a9c35..d21823b 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -108,11 +108,13 @@  class QemuTarget(BaseTarget):
         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:
+        try:
+            use_kvm = oe.types.boolean(qemu_use_kvm)
+        except ValueError as e:
+            bb.fatal("%s\nQEMU_USE_KVM needs to be set to a boolean value. It no longer supports accepting a list of machines.\n"
+                     "  e.g.\n"
+                     "  QEMU_USE_KVM_qemux86-64 = '1'" % e)
+        if use_kvm and not d.getVar('QB_CPU_KVM'):
             use_kvm = False
 
         # Log QemuRunner log output to a file

Comments

Richard Purdie Dec. 7, 2018, 11:02 a.m.
On Thu, 2018-12-06 at 14:30 +0800, Chen Qi wrote:
> We want QEMU_USE_KVM to only set to some boolean value, with possible
> MACHINE override. Drop the support of listing machines in this variable,
> and give users error message if they still do so.
> 
> Error message below is an example.
> 
> ERROR: core-image-minimal-1.0-r0 do_testimage: Invalid boolean value 'intel-corei7-64 intel-core2-32 qemux86 qemux86-64'
> QEMU_USE_KVM needs to be set to a boolean value. It no longer supports accepting a list of machines.
>   e.g.
>   QEMU_USE_KVM_qemux86-64 = '1'
> ERROR: core-image-minimal-1.0-r0 do_testimage: Function failed: do_testimage
> 
> QB_CPU_KVM is also checked to determine whether to enable kvm.
> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>  meta/classes/testimage.bbclass | 12 +++++++-----
>  meta/lib/oeqa/targetcontrol.py | 12 +++++++-----
>  2 files changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
> index 82cbb06..3353d133 100644
> --- a/meta/classes/testimage.bbclass
> +++ b/meta/classes/testimage.bbclass
> @@ -229,11 +229,13 @@ def testimage_main(d):
>  
>      # 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:
> +    try:
> +        kvm = oe.types.boolean(qemu_use_kvm)
> +    except ValueError as e:
> +        bb.fatal("%s\nQEMU_USE_KVM needs to be set to a boolean value. It no longer supports accepting a list of machines.\n"
> +                 "  e.g.\n"
> +                 "  QEMU_USE_KVM_qemux86-64 = '1'" % e)
> +    if kvm and not d.getVar('QB_CPU_KVM'):
>          kvm = False
>  
>      slirp = False
> diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
> index 59a9c35..d21823b 100644
> --- a/meta/lib/oeqa/targetcontrol.py
> +++ b/meta/lib/oeqa/targetcontrol.py
> @@ -108,11 +108,13 @@ class QemuTarget(BaseTarget):
>          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:
> +        try:
> +            use_kvm = oe.types.boolean(qemu_use_kvm)
> +        except ValueError as e:
> +            bb.fatal("%s\nQEMU_USE_KVM needs to be set to a boolean value. It no longer supports accepting a list of machines.\n"
> +                     "  e.g.\n"
> +                     "  QEMU_USE_KVM_qemux86-64 = '1'" % e)
> +        if use_kvm and not d.getVar('QB_CPU_KVM'):
>              use_kvm = False
>  
>          # Log QemuRunner log output to a file

Unfortunately this still isn't going to work quite as I mentioned.

We've about to add an aarch64 server to our autobuilder infrastructure.
We need that to use kvm for arm targets but not x86 ones yet have x86
targets use kvm on x86 hardware too.

I appreciate that isn't how the code works now but we may as well fix
this properly once and for all.

Cheers,

Richard
Qi.Chen@windriver.com Dec. 10, 2018, 2:17 a.m.
On 12/07/2018 07:02 PM, Richard Purdie wrote:
> On Thu, 2018-12-06 at 14:30 +0800, Chen Qi wrote:
>> We want QEMU_USE_KVM to only set to some boolean value, with possible
>> MACHINE override. Drop the support of listing machines in this variable,
>> and give users error message if they still do so.
>>
>> Error message below is an example.
>>
>> ERROR: core-image-minimal-1.0-r0 do_testimage: Invalid boolean value 'intel-corei7-64 intel-core2-32 qemux86 qemux86-64'
>> QEMU_USE_KVM needs to be set to a boolean value. It no longer supports accepting a list of machines.
>>    e.g.
>>    QEMU_USE_KVM_qemux86-64 = '1'
>> ERROR: core-image-minimal-1.0-r0 do_testimage: Function failed: do_testimage
>>
>> QB_CPU_KVM is also checked to determine whether to enable kvm.
>>
>> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
>> ---
>>   meta/classes/testimage.bbclass | 12 +++++++-----
>>   meta/lib/oeqa/targetcontrol.py | 12 +++++++-----
>>   2 files changed, 14 insertions(+), 10 deletions(-)
>>
>> diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
>> index 82cbb06..3353d133 100644
>> --- a/meta/classes/testimage.bbclass
>> +++ b/meta/classes/testimage.bbclass
>> @@ -229,11 +229,13 @@ def testimage_main(d):
>>   
>>       # 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:
>> +    try:
>> +        kvm = oe.types.boolean(qemu_use_kvm)
>> +    except ValueError as e:
>> +        bb.fatal("%s\nQEMU_USE_KVM needs to be set to a boolean value. It no longer supports accepting a list of machines.\n"
>> +                 "  e.g.\n"
>> +                 "  QEMU_USE_KVM_qemux86-64 = '1'" % e)
>> +    if kvm and not d.getVar('QB_CPU_KVM'):
>>           kvm = False
>>   
>>       slirp = False
>> diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
>> index 59a9c35..d21823b 100644
>> --- a/meta/lib/oeqa/targetcontrol.py
>> +++ b/meta/lib/oeqa/targetcontrol.py
>> @@ -108,11 +108,13 @@ class QemuTarget(BaseTarget):
>>           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:
>> +        try:
>> +            use_kvm = oe.types.boolean(qemu_use_kvm)
>> +        except ValueError as e:
>> +            bb.fatal("%s\nQEMU_USE_KVM needs to be set to a boolean value. It no longer supports accepting a list of machines.\n"
>> +                     "  e.g.\n"
>> +                     "  QEMU_USE_KVM_qemux86-64 = '1'" % e)
>> +        if use_kvm and not d.getVar('QB_CPU_KVM'):
>>               use_kvm = False
>>   
>>           # Log QemuRunner log output to a file
> Unfortunately this still isn't going to work quite as I mentioned.
>
> We've about to add an aarch64 server to our autobuilder infrastructure.
> We need that to use kvm for arm targets but not x86 ones yet have x86
> targets use kvm on x86 hardware too.
>
> I appreciate that isn't how the code works now but we may as well fix
> this properly once and for all.
>
> Cheers,
>
> Richard
>
>
>

How about setting QB_CPU_KVM to something like 
${@bb.utils.contains('BUILD_ARCH', 'x86_64', '-cpu core2duo', '', d)}?
In this way, we are actually doing BUILD_ARCH and TARGET_ARCH match 
manually, as we are setting QB_CPU_KVM in different conf files like 
qemuboot-x86.inc, qemuboot-intel.inc, which contain target information 
in their names.
When aarch64 server is supported, qemuarm and qemuarm64's configuration 
files could also be modified to add QB_CPU_KVM.

I'm thinking about a general matching function to check BUILD_ARCH and 
TARGET_ARCH, and getting rid of QB_CPU_KVM. But when checking 
qemuboot-intel.inc, I found the '-cpu' option is not the same when 
enabling and disabling kvm.
QB_CPU_intel-core2-32 = "-cpu coreduo"
QB_CPU_KVM_intel-core2-32 = "-cpu kvm32"

So it seems QB_CPU_KVM is still needed. One step further, if it's still 
needed, we could set it properly, doing arch matching manually.

Best Regards,
Chen Qi