[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openembedded-core
Subject:    Re: [OE-core] [PATCH 1/1] targetcontrol.py: make QEMU_USE_KVM = "1" work
From:       "Burton, Ross" <ross.burton () intel ! com>
Date:       2017-11-30 10:57:51
Message-ID: CAJTo0LYSpB_HSXqRKE_ytqEoDNfFdYhm4pJ4WJj534voMSX-UA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


There are two neater ways of doing this:

1) oe.types.boolean() which handles all the common aliases for true or
false.
2)bitbake typed variables.  Do QEMU_USE_KVM[type]="boolean" where it gets a
default value, and then use oe.data.typed_value('QEMU_USE_KVM', d) to get
the value.

Both ways move the actual value parsing to dedicated code so its less error
prone and more consistent.

Ross

On 14 November 2017 at 06:57, Robert Yang <liezhi.yang@windriver.com> wrote:

> It only could be set to "True", which was not common in oe, e.g.:
> * Works
> QEMU_USE_KVM = "True"
>
> * Didn't work, this would surprise user.
> QEMU_USE_KVM = "1"
>
> Make it work with both 1 and True now, the "True" is for compatibility.
>
> [YOCTO #12343]
>
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
>  meta/classes/testimage.bbclass | 2 +-
>  meta/lib/oeqa/targetcontrol.py | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.
> bbclass
> index 45bb2bd..66b4baf 100644
> --- a/meta/classes/testimage.bbclass
> +++ b/meta/classes/testimage.bbclass
> @@ -215,7 +215,7 @@ def testimage_main(d):
>      # Get use_kvm
>      qemu_use_kvm = d.getVar("QEMU_USE_KVM")
>      if qemu_use_kvm and \
> -       (qemu_use_kvm == 'True' and 'x86' in machine or \
> +       (qemu_use_kvm in ('True', '1') and 'x86' in machine or \
>          d.getVar('MACHINE') in qemu_use_kvm.split()):
>          kvm = True
>      else:
> diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.
> py
> index f63936c..1625569 100644
> --- a/meta/lib/oeqa/targetcontrol.py
> +++ b/meta/lib/oeqa/targetcontrol.py
> @@ -107,7 +107,7 @@ class QemuTarget(BaseTarget):
>          dump_dir = d.getVar("TESTIMAGE_DUMP_DIR")
>          qemu_use_kvm = d.getVar("QEMU_USE_KVM")
>          if qemu_use_kvm and \
> -           (qemu_use_kvm == "True" and "x86" in d.getVar("MACHINE") or \
> +           (qemu_use_kvm in ("True", "1") and "x86" in
> d.getVar("MACHINE") or \
>              d.getVar("MACHINE") in qemu_use_kvm.split()):
>              use_kvm = True
>          else:
> --
> 2.7.4
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>

[Attachment #5 (text/html)]

<div dir="ltr"><div class="gmail_extra">There are two neater ways of doing \
this:</div><br>1) oe.types.boolean() which handles all the common aliases for true or \
false.<div>2)bitbake typed variables.   Do QEMU_USE_KVM[type]=&quot;boolean&quot; \
where it gets a default value, and then use \
oe.data.typed_value(&#39;QEMU_USE_KVM&#39;, d) to get the \
value.</div><div><br></div><div>Both ways move the actual value parsing to dedicated \
code so its less error prone and more \
consistent.</div><div><br></div><div>Ross</div><div><br><div class="gmail_extra"><div \
class="gmail_quote">On 14 November 2017 at 06:57, Robert Yang <span dir="ltr">&lt;<a \
href="mailto:liezhi.yang@windriver.com" \
target="_blank">liezhi.yang@windriver.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">It \
                only could be set to &quot;True&quot;, which was not common in oe, \
                e.g.:<br>
* Works<br>
QEMU_USE_KVM = &quot;True&quot;<br>
<br>
* Didn&#39;t work, this would surprise user.<br>
QEMU_USE_KVM = &quot;1&quot;<br>
<br>
Make it work with both 1 and True now, the &quot;True&quot; is for compatibility.<br>
<br>
[YOCTO #12343]<br>
<br>
Signed-off-by: Robert Yang &lt;<a \
                href="mailto:liezhi.yang@windriver.com">liezhi.yang@windriver.com</a>&gt;<br>
                
---<br>
  meta/classes/testimage.bbclass | 2 +-<br>
  meta/lib/oeqa/targetcontrol.py | 2 +-<br>
  2 files changed, 2 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/meta/classes/testimage.<wbr>bbclass \
b/meta/classes/testimage.<wbr>bbclass<br> index 45bb2bd..66b4baf 100644<br>
--- a/meta/classes/testimage.<wbr>bbclass<br>
+++ b/meta/classes/testimage.<wbr>bbclass<br>
@@ -215,7 +215,7 @@ def testimage_main(d):<br>
        # Get use_kvm<br>
        qemu_use_kvm = d.getVar(&quot;QEMU_USE_KVM&quot;)<br>
        if qemu_use_kvm and \<br>
-           (qemu_use_kvm == &#39;True&#39; and &#39;x86&#39; in machine or \<br>
+           (qemu_use_kvm in (&#39;True&#39;, &#39;1&#39;) and &#39;x86&#39; in \
machine or \<br>  d.getVar(&#39;MACHINE&#39;) in qemu_use_kvm.split()):<br>
              kvm = True<br>
        else:<br>
diff --git a/meta/lib/oeqa/targetcontrol.<wbr>py \
b/meta/lib/oeqa/targetcontrol.<wbr>py<br> index f63936c..1625569 100644<br>
--- a/meta/lib/oeqa/targetcontrol.<wbr>py<br>
+++ b/meta/lib/oeqa/targetcontrol.<wbr>py<br>
@@ -107,7 +107,7 @@ class QemuTarget(BaseTarget):<br>
              dump_dir = d.getVar(&quot;TESTIMAGE_DUMP_DIR&quot;)<br>
              qemu_use_kvm = d.getVar(&quot;QEMU_USE_KVM&quot;)<br>
              if qemu_use_kvm and \<br>
-                 (qemu_use_kvm == &quot;True&quot; and &quot;x86&quot; in \
d.getVar(&quot;MACHINE&quot;) or \<br> +                 (qemu_use_kvm in \
(&quot;True&quot;, &quot;1&quot;) and &quot;x86&quot; in \
                d.getVar(&quot;MACHINE&quot;) or \<br>
                    d.getVar(&quot;MACHINE&quot;) in qemu_use_kvm.split()):<br>
                    use_kvm = True<br>
              else:<br>
<span class="gmail-HOEnZb"><font color="#888888">--<br>
2.7.4<br>
<br>
--<br>
______________________________<wbr>_________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.<wbr>openembedded.org</a><br>
 <a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" \
rel="noreferrer" target="_blank">http://lists.openembedded.org/<wbr>mailman/listinfo/openembedded-<wbr>core</a><br>
 </font></span></blockquote></div><br></div></div></div>



-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic