Re: [OE-core] [PATCH 4/9] ovmf: deploy firmware in image directory

2017-01-09 Thread Patrick Ohly
On Mon, 2017-01-09 at 19:50 -0800, Ricardo Neri wrote:
> On Wed, 2017-01-04 at 11:01 +0100, Patrick Ohly wrote:
> > On Wed, 2016-12-28 at 13:38 -0800, Ricardo Neri wrote:
> > > >  do_install_class-target() {
> > > > -OVMF_DIR_SUFFIX="X64"
> > > > -if [ "${TARGET_ARCH}" != "x86_64" ] ; then
> > > > -OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization
> > > > -fi
> > > > +# Traditional location.
> > > >  install -d ${D}${datadir}/ovmf
> > > > +install -m 0755 ${WORKDIR}/ovmf/OVMF.fd 
> > > > ${D}${datadir}/ovmf/bios.bin
> > > 
> > > Now that I think about it. Installing here does not sever any purpose.
> > > Thus, I think this can be removed by perhaps doing do_install[noexec] =
> > > "1"
> > 
> > I was trying not to break traditional usage patterns. If we keep the
> > "bios" runqemu parameters, then we should also keep the bios.bin file.
> 
> I think OVMF is not a traditional recipe. There are two use cases to
> ponder. 1) a Yocto Project disk image wants to include OVMF along with
> qemu to run a VM from the YP image. 2) we want to run a YP image in a
> host system. I am not sure if someone is interested in 1) and I think
> your use case and LUV's is 2). I think that putting things in the deploy
> directory makes more sense because, as you said, these images will be
> written to. I reckon the the "bios" parameters in runqemu should look
> there. This is not a must for this patchset but something nice to have.

Okay, so let's remove that "traditional location" already in this patch
set. I still want to keep the "bios" parameters in runqemu (because they
might have some other uses), but for OVMF, the only supported approach
will be via the "ovmf" parameters and the deploy directory.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.



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


Re: [OE-core] [PATCH 4/9] ovmf: deploy firmware in image directory

2017-01-09 Thread Ricardo Neri
On Wed, 2017-01-04 at 11:01 +0100, Patrick Ohly wrote:
> On Wed, 2016-12-28 at 13:38 -0800, Ricardo Neri wrote:
> > >  do_install_class-target() {
> > > -OVMF_DIR_SUFFIX="X64"
> > > -if [ "${TARGET_ARCH}" != "x86_64" ] ; then
> > > -OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization
> > > -fi
> > > +# Traditional location.
> > >  install -d ${D}${datadir}/ovmf
> > > +install -m 0755 ${WORKDIR}/ovmf/OVMF.fd ${D}${datadir}/ovmf/bios.bin
> > 
> > Now that I think about it. Installing here does not sever any purpose.
> > Thus, I think this can be removed by perhaps doing do_install[noexec] =
> > "1"
> 
> I was trying not to break traditional usage patterns. If we keep the
> "bios" runqemu parameters, then we should also keep the bios.bin file.

I think OVMF is not a traditional recipe. There are two use cases to
ponder. 1) a Yocto Project disk image wants to include OVMF along with
qemu to run a VM from the YP image. 2) we want to run a YP image in a
host system. I am not sure if someone is interested in 1) and I think
your use case and LUV's is 2). I think that putting things in the deploy
directory makes more sense because, as you said, these images will be
written to. I reckon the the "bios" parameters in runqemu should look
there. This is not a must for this patchset but something nice to have.

Thanks and BR,
Ricardo

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


Re: [OE-core] [PATCH 4/9] ovmf: deploy firmware in image directory

2017-01-04 Thread Patrick Ohly
On Wed, 2016-12-28 at 13:38 -0800, Ricardo Neri wrote:
> >  do_install_class-target() {
> > -OVMF_DIR_SUFFIX="X64"
> > -if [ "${TARGET_ARCH}" != "x86_64" ] ; then
> > -OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization
> > -fi
> > +# Traditional location.
> >  install -d ${D}${datadir}/ovmf
> > +install -m 0755 ${WORKDIR}/ovmf/OVMF.fd ${D}${datadir}/ovmf/bios.bin
> 
> Now that I think about it. Installing here does not sever any purpose.
> Thus, I think this can be removed by perhaps doing do_install[noexec] =
> "1"

I was trying not to break traditional usage patterns. If we keep the
"bios" runqemu parameters, then we should also keep the bios.bin file.

> > +}
> >  
> > -FIXED_GCCVER=$(fixup_target_tools ${GCC_VER})
> > -build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}"
> > -install -m 0755 ${build_dir}/FV/OVMF.fd \
> > -   ${D}${datadir}/ovmf/bios.bin
> > +inherit deploy
> 
> I am not sure if there is a right way for inheriting in bitbake.
> However, a quick grep -n inherit reveals that the majority of the
> recipes put their inheritances towards the top of the recipe.

Agreed, that seems to be more common, although there are also examples
where "inherit deploy" is directly in front of "do_deploy". I chose the
latter because it was a more localized change, but will change it in
rev2.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.



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


Re: [OE-core] [PATCH 4/9] ovmf: deploy firmware in image directory

2016-12-28 Thread Ricardo Neri
On Wed, 2016-12-28 at 13:38 -0800, Ricardo Neri wrote:
> >  do_install_class-target() {
> > -OVMF_DIR_SUFFIX="X64"
> > -if [ "${TARGET_ARCH}" != "x86_64" ] ; then
> > -OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization
> > -fi
> > +# Traditional location.
> >  install -d ${D}${datadir}/ovmf
> > +install -m 0755 ${WORKDIR}/ovmf/OVMF.fd
> ${D}${datadir}/ovmf/bios.bin
> 
> Now that I think about it. Installing here does not sever any purpose.
> Thus, I think this can be removed by perhaps doing do_install[noexec]
> =
> "1"

I take back this. I seems that scripts/runqemu does look for OVMF in
STAGING_DIR_HOST/NATIVE. Perhaps this can be changed how that you are
also updating runqemu.

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


Re: [OE-core] [PATCH 4/9] ovmf: deploy firmware in image directory

2016-12-28 Thread Ricardo Neri
On Wed, 2016-12-21 at 14:11 +0100, Patrick Ohly wrote:
> When used with '-drive if=pflash', qemu will store UEFI variables
> inside the firmware image file. That is unexpected for a file located in
> the sysroot, which should be read-only, while it is normal for image
> files in the deploy/images directory. Therefore that directory is a
> better place for use with runqemu.
> 
> The name was chose so that "runqemu ovmf" can be used as shorthand for
> "runqemu /ovmf.qcow2" by treating "ovmf" as the base name
> of the BIOS file. "ovmf_secboot.qcow2" is meant to be used for the
> Secure Boot enabled BIOS. qcow2 is used because it is needed for
> "savevm" snapshots of a virtual machine.
> 
> Alternatively, OVMF_CODE.fd (read-only) and OVMF_VARS.fd (read/write)
> could be used. That would then allow updating the firmware of an
> existing machine without wiping out the variables set
> earlier. Configuring that in qemu would be more complicated, so for
> now the simpler approach with combined code and variable store is
> used.
> 
> Signed-off-by: Patrick Ohly 
> ---
>  meta/recipes-core/ovmf/ovmf_git.bb | 33 +++--
>  1 file changed, 23 insertions(+), 10 deletions(-)
> 
> diff --git a/meta/recipes-core/ovmf/ovmf_git.bb 
> b/meta/recipes-core/ovmf/ovmf_git.bb
> index 13b583b..d0441d1 100644
> --- a/meta/recipes-core/ovmf/ovmf_git.bb
> +++ b/meta/recipes-core/ovmf/ovmf_git.bb
> @@ -16,7 +16,7 @@ PARALLEL_MAKE = ""
>  
>  S = "${WORKDIR}/git"
>  
> -DEPENDS_class-native="util-linux-native iasl-native ossp-uuid-native"
> +DEPENDS_class-native="util-linux-native iasl-native ossp-uuid-native 
> qemu-native"
>  
>  DEPENDS_class-target="ovmf-native"
>  
> @@ -97,9 +97,20 @@ do_compile_class-target() {
>  OVMF_ARCH="IA32"
>  fi
>  
> +# ${WORKDIR}/ovmf is a well-known location where do_install and
> +# do_deploy will be able to find the files.
> +rm -rf ${WORKDIR}/ovmf
> +mkdir ${WORKDIR}/ovmf
> +OVMF_DIR_SUFFIX="X64"
> +if [ "${TARGET_ARCH}" != "x86_64" ] ; then
> +OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization
> +fi
>  FIXED_GCCVER=$(fixup_target_tools ${GCC_VER})
> -echo FIXED_GCCVER is ${FIXED_GCCVER}
> +bbnote FIXED_GCCVER is ${FIXED_GCCVER}
> +build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}"
> +
>  ${S}/OvmfPkg/build.sh -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER}
> +ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/OVMF.fd
>  }
>  
>  do_install_class-native() {
> @@ -108,16 +119,18 @@ do_install_class-native() {
>  }
>  
>  do_install_class-target() {
> -OVMF_DIR_SUFFIX="X64"
> -if [ "${TARGET_ARCH}" != "x86_64" ] ; then
> -OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization
> -fi
> +# Traditional location.
>  install -d ${D}${datadir}/ovmf
> +install -m 0755 ${WORKDIR}/ovmf/OVMF.fd ${D}${datadir}/ovmf/bios.bin

Now that I think about it. Installing here does not sever any purpose.
Thus, I think this can be removed by perhaps doing do_install[noexec] =
"1"

> +}
>  
> -FIXED_GCCVER=$(fixup_target_tools ${GCC_VER})
> -build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}"
> -install -m 0755 ${build_dir}/FV/OVMF.fd \
> - ${D}${datadir}/ovmf/bios.bin
> +inherit deploy

I am not sure if there is a right way for inheriting in bitbake.
However, a quick grep -n inherit reveals that the majority of the
recipes put their inheritances towards the top of the recipe.

Thanks and BR,
Ricardo
> +do_deploy() {
> +}
> +do_deploy_class-target() {
> +# For use with "runqemu ovmf".
> +qemu-img convert -f raw -O qcow2 ${WORKDIR}/ovmf/OVMF.fd 
> ${DEPLOYDIR}/ovmf.qcow2
>  }
> +addtask do_deploy after do_compile before do_build
>  
>  BBCLASSEXTEND = "native"


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


Re: [OE-core] [PATCH 4/9] ovmf: deploy firmware in image directory

2016-12-27 Thread Ricardo Neri
On Wed, 2016-12-21 at 14:11 +0100, Patrick Ohly wrote:
> When used with '-drive if=pflash', qemu will store UEFI variables
> inside the firmware image file. That is unexpected for a file located
> in
> the sysroot, which should be read-only, while it is normal for image
> files in the deploy/images directory. Therefore that directory is a
> better place for use with runqemu.
> 
> The name was chose so that "runqemu ovmf" can be used as shorthand for
> "runqemu /ovmf.qcow2" by treating "ovmf" as the base name
> of the BIOS file. "ovmf_secboot.qcow2" is meant to be used for the
> Secure Boot enabled BIOS. qcow2 is used because it is needed for
> "savevm" snapshots of a virtual machine.
> 
> Alternatively, OVMF_CODE.fd (read-only) and OVMF_VARS.fd (read/write)
> could be used. That would then allow updating the firmware of an
> existing machine without wiping out the variables set
> earlier. Configuring that in qemu would be more complicated, so for
> now the simpler approach with combined code and variable store is
> used.

This looks good to me!

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


[OE-core] [PATCH 4/9] ovmf: deploy firmware in image directory

2016-12-21 Thread Patrick Ohly
When used with '-drive if=pflash', qemu will store UEFI variables
inside the firmware image file. That is unexpected for a file located in
the sysroot, which should be read-only, while it is normal for image
files in the deploy/images directory. Therefore that directory is a
better place for use with runqemu.

The name was chose so that "runqemu ovmf" can be used as shorthand for
"runqemu /ovmf.qcow2" by treating "ovmf" as the base name
of the BIOS file. "ovmf_secboot.qcow2" is meant to be used for the
Secure Boot enabled BIOS. qcow2 is used because it is needed for
"savevm" snapshots of a virtual machine.

Alternatively, OVMF_CODE.fd (read-only) and OVMF_VARS.fd (read/write)
could be used. That would then allow updating the firmware of an
existing machine without wiping out the variables set
earlier. Configuring that in qemu would be more complicated, so for
now the simpler approach with combined code and variable store is
used.

Signed-off-by: Patrick Ohly 
---
 meta/recipes-core/ovmf/ovmf_git.bb | 33 +++--
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/meta/recipes-core/ovmf/ovmf_git.bb 
b/meta/recipes-core/ovmf/ovmf_git.bb
index 13b583b..d0441d1 100644
--- a/meta/recipes-core/ovmf/ovmf_git.bb
+++ b/meta/recipes-core/ovmf/ovmf_git.bb
@@ -16,7 +16,7 @@ PARALLEL_MAKE = ""
 
 S = "${WORKDIR}/git"
 
-DEPENDS_class-native="util-linux-native iasl-native ossp-uuid-native"
+DEPENDS_class-native="util-linux-native iasl-native ossp-uuid-native 
qemu-native"
 
 DEPENDS_class-target="ovmf-native"
 
@@ -97,9 +97,20 @@ do_compile_class-target() {
 OVMF_ARCH="IA32"
 fi
 
+# ${WORKDIR}/ovmf is a well-known location where do_install and
+# do_deploy will be able to find the files.
+rm -rf ${WORKDIR}/ovmf
+mkdir ${WORKDIR}/ovmf
+OVMF_DIR_SUFFIX="X64"
+if [ "${TARGET_ARCH}" != "x86_64" ] ; then
+OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization
+fi
 FIXED_GCCVER=$(fixup_target_tools ${GCC_VER})
-echo FIXED_GCCVER is ${FIXED_GCCVER}
+bbnote FIXED_GCCVER is ${FIXED_GCCVER}
+build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}"
+
 ${S}/OvmfPkg/build.sh -a $OVMF_ARCH -b RELEASE -t ${FIXED_GCCVER}
+ln ${build_dir}/FV/OVMF.fd ${WORKDIR}/ovmf/OVMF.fd
 }
 
 do_install_class-native() {
@@ -108,16 +119,18 @@ do_install_class-native() {
 }
 
 do_install_class-target() {
-OVMF_DIR_SUFFIX="X64"
-if [ "${TARGET_ARCH}" != "x86_64" ] ; then
-OVMF_DIR_SUFFIX="Ia32" # Note the different capitalization
-fi
+# Traditional location.
 install -d ${D}${datadir}/ovmf
+install -m 0755 ${WORKDIR}/ovmf/OVMF.fd ${D}${datadir}/ovmf/bios.bin
+}
 
-FIXED_GCCVER=$(fixup_target_tools ${GCC_VER})
-build_dir="${S}/Build/Ovmf$OVMF_DIR_SUFFIX/RELEASE_${FIXED_GCCVER}"
-install -m 0755 ${build_dir}/FV/OVMF.fd \
-   ${D}${datadir}/ovmf/bios.bin
+inherit deploy
+do_deploy() {
+}
+do_deploy_class-target() {
+# For use with "runqemu ovmf".
+qemu-img convert -f raw -O qcow2 ${WORKDIR}/ovmf/OVMF.fd 
${DEPLOYDIR}/ovmf.qcow2
 }
+addtask do_deploy after do_compile before do_build
 
 BBCLASSEXTEND = "native"
-- 
2.1.4

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