[1/1] testimage: fix boolean checking for QEMU_USE_KVM

Submitted by Qi.Chen@windriver.com on Dec. 4, 2018, 5:04 a.m. | Patch ID: 156883

Details

Message ID f7c5083f7a1f59bacdd55d166bb9fef20e578c8e.1543899860.git.Qi.Chen@windriver.com
State New
Headers show

Commit Message

Qi.Chen@windriver.com Dec. 4, 2018, 5:04 a.m.
If QEMU_USE_KVM is set to a list of machines, when doing testimage
for a machine outside the list, we will get the following error.

  Exception: ValueError: Invalid boolean value 'intel-corei7-64 intel-core2-32 qemux86 qemux86-64'

This is because oe.types.boolean raises error if the parameter
is not values like 'true', 'false', etc.

Fix the boolean checking to avoid the exception.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes/testimage.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 82cbb06..80e457b 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -231,7 +231,7 @@  def testimage_main(d):
     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):
+        qemu_use_kvm.lower() in ('yes', 'y', 'true', 't', '1') and 'x86' in machine):
         kvm = True
     else:
         kvm = False

Comments

Richard Purdie Dec. 4, 2018, 12:22 p.m.
On Tue, 2018-12-04 at 13:04 +0800, Chen Qi wrote:
> If QEMU_USE_KVM is set to a list of machines, when doing testimage
> for a machine outside the list, we will get the following error.
> 
>   Exception: ValueError: Invalid boolean value 'intel-corei7-64
> intel-core2-32 qemux86 qemux86-64'
> 
> This is because oe.types.boolean raises error if the parameter
> is not values like 'true', 'false', etc.
> 
> Fix the boolean checking to avoid the exception.
> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>  meta/classes/testimage.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes/testimage.bbclass
> b/meta/classes/testimage.bbclass
> index 82cbb06..80e457b 100644
> --- a/meta/classes/testimage.bbclass
> +++ b/meta/classes/testimage.bbclass
> @@ -231,7 +231,7 @@ def testimage_main(d):
>      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):
> +        qemu_use_kvm.lower() in ('yes', 'y', 'true', 't', '1') and
> 'x86' in machine):
>          kvm = True
>      else:
>          kvm = False

Personally, I think we should just drop support for listing the
machines in QEMU_USE_KVM and suggest people use overrides instead?

Cheers,

Richard