diff mbox series

[4/9] automation: Add Arm containers to containerize script

Message ID 20220922134058.1410-5-michal.orzel@amd.com (mailing list archive)
State Superseded
Headers show
Series GitLab CI cleanup & improvements for Arm | expand

Commit Message

Orzel, Michal Sept. 22, 2022, 1:40 p.m. UTC
Script automation/scripts/containerize makes it easy to build Xen within
predefined containers from gitlab container registry. However, it is
currently not possible to use it with Arm containers because they are not
listed in the script. Populate the necessary entries.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
---
 automation/scripts/containerize | 3 +++
 1 file changed, 3 insertions(+)

Comments

Stefano Stabellini Sept. 22, 2022, 10:03 p.m. UTC | #1
On Thu, 22 Sep 2022, Michal Orzel wrote:
> Script automation/scripts/containerize makes it easy to build Xen within
> predefined containers from gitlab container registry. However, it is
> currently not possible to use it with Arm containers because they are not
> listed in the script. Populate the necessary entries.
> 
> Signed-off-by: Michal Orzel <michal.orzel@amd.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  automation/scripts/containerize | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/automation/scripts/containerize b/automation/scripts/containerize
> index 9d4beca4fa4b..0f4645c4cccb 100755
> --- a/automation/scripts/containerize
> +++ b/automation/scripts/containerize
> @@ -25,6 +25,7 @@ die() {
>  BASE="registry.gitlab.com/xen-project/xen"
>  case "_${CONTAINER}" in
>      _alpine) CONTAINER="${BASE}/alpine:3.12" ;;
> +    _alpine-arm64v8) CONTAINER="${BASE}/alpine:3.12-arm64v8" ;;
>      _archlinux|_arch) CONTAINER="${BASE}/archlinux:current" ;;
>      _riscv64) CONTAINER="${BASE}/archlinux:riscv64" ;;
>      _centos7) CONTAINER="${BASE}/centos:7" ;;
> @@ -35,6 +36,8 @@ case "_${CONTAINER}" in
>      _stretch|_) CONTAINER="${BASE}/debian:stretch" ;;
>      _buster-gcc-ibt) CONTAINER="${BASE}/debian:buster-gcc-ibt" ;;
>      _unstable|_) CONTAINER="${BASE}/debian:unstable" ;;
> +    _unstable-arm32-gcc) CONTAINER="${BASE}/debian:unstable-arm32-gcc" ;;
> +    _unstable-arm64v8) CONTAINER="${BASE}/debian:unstable-arm64v8" ;;
>      _trusty) CONTAINER="${BASE}/ubuntu:trusty" ;;
>      _xenial) CONTAINER="${BASE}/ubuntu:xenial" ;;
>      _opensuse-leap|_leap) CONTAINER="${BASE}/suse:opensuse-leap" ;;
> -- 
> 2.25.1
>
Anthony PERARD Sept. 23, 2022, 1:56 p.m. UTC | #2
On Thu, Sep 22, 2022 at 03:40:53PM +0200, Michal Orzel wrote:
> Script automation/scripts/containerize makes it easy to build Xen within
> predefined containers from gitlab container registry. However, it is
> currently not possible to use it with Arm containers because they are not
> listed in the script. Populate the necessary entries.

FYI, those entry are just helper/shortcut/aliases, you can use any
arbitrary container with the script, it just more annoying.

Your patch here allows to write:
    CONTAINER=unstable-arm64v8 automation/scripts/containerize
but you could write the following instead, for the same result:
    CONTAINER=registry.gitlab.com/xen-project/xen/debian:unstable-arm64v8 automation/scripts/containerize

I wonder if the script could select the right container base on the
architecture of the host, because "alpine" and "alpine-arm64v8" will not
both work on the same machine. It might be nice to just choose "alpine"
and the script would select the x86 or arm container automagically. Just
an idea, no need to do anything about it.

(patch is fine otherwise, just the patch description is a bit
misleading)

Cheers,
Orzel, Michal Sept. 23, 2022, 4:54 p.m. UTC | #3
Hi Anthony,

On 23/09/2022 15:56, Anthony PERARD wrote:
> 
> 
> On Thu, Sep 22, 2022 at 03:40:53PM +0200, Michal Orzel wrote:
>> Script automation/scripts/containerize makes it easy to build Xen within
>> predefined containers from gitlab container registry. However, it is
>> currently not possible to use it with Arm containers because they are not
>> listed in the script. Populate the necessary entries.
> 
> FYI, those entry are just helper/shortcut/aliases, you can use any
> arbitrary container with the script, it just more annoying.
> 
> Your patch here allows to write:
>     CONTAINER=unstable-arm64v8 automation/scripts/containerize
> but you could write the following instead, for the same result:
>     CONTAINER=registry.gitlab.com/xen-project/xen/debian:unstable-arm64v8 automation/scripts/containerize
> 
> I wonder if the script could select the right container base on the
> architecture of the host, because "alpine" and "alpine-arm64v8" will not
> both work on the same machine. It might be nice to just choose "alpine"
> and the script would select the x86 or arm container automagically. Just
> an idea, no need to do anything about it.
I'm not in favor of adding the automatic selection based on the host.
The reason is that on x86 you can run both x86 and e.g. Arm containers.
You just need to use register qemu-user-static [1] to perform emulation.
This is something widely used and I use that to test Arm images/containers on x86 host.
So you can run both alpine and alpine-arm64v8 on the same machine.

> 
> (patch is fine otherwise, just the patch description is a bit
> misleading)
> 
> Cheers,
> 
> --
> Anthony PERARD

~Michal

[1] https://github.com/multiarch/qemu-user-static
Stefano Stabellini Sept. 23, 2022, 10:23 p.m. UTC | #4
On Fri, 23 Sep 2022, Michal Orzel wrote:
> Hi Anthony,
> 
> On 23/09/2022 15:56, Anthony PERARD wrote:
> > 
> > 
> > On Thu, Sep 22, 2022 at 03:40:53PM +0200, Michal Orzel wrote:
> >> Script automation/scripts/containerize makes it easy to build Xen within
> >> predefined containers from gitlab container registry. However, it is
> >> currently not possible to use it with Arm containers because they are not
> >> listed in the script. Populate the necessary entries.
> > 
> > FYI, those entry are just helper/shortcut/aliases, you can use any
> > arbitrary container with the script, it just more annoying.
> > 
> > Your patch here allows to write:
> >     CONTAINER=unstable-arm64v8 automation/scripts/containerize
> > but you could write the following instead, for the same result:
> >     CONTAINER=registry.gitlab.com/xen-project/xen/debian:unstable-arm64v8 automation/scripts/containerize
> > 
> > I wonder if the script could select the right container base on the
> > architecture of the host, because "alpine" and "alpine-arm64v8" will not
> > both work on the same machine. It might be nice to just choose "alpine"
> > and the script would select the x86 or arm container automagically. Just
> > an idea, no need to do anything about it.
> I'm not in favor of adding the automatic selection based on the host.
> The reason is that on x86 you can run both x86 and e.g. Arm containers.
> You just need to use register qemu-user-static [1] to perform emulation.
> This is something widely used and I use that to test Arm images/containers on x86 host.
> So you can run both alpine and alpine-arm64v8 on the same machine.

Yeah and modern Docker sets up qemu-user-static automatically without
the user having to do anything. Anthony, you can try it yourself: you
should be able to just:

  docker run -it registry.gitlab.com/xen-project/xen/debian:unstable-arm64v8

on your x86 host if you have a docker new enough
Anthony PERARD Sept. 26, 2022, 1:33 p.m. UTC | #5
On Fri, Sep 23, 2022 at 03:23:26PM -0700, Stefano Stabellini wrote:
> On Fri, 23 Sep 2022, Michal Orzel wrote:
> > Hi Anthony,
> > 
> > On 23/09/2022 15:56, Anthony PERARD wrote:
> > > 
> > > 
> > > On Thu, Sep 22, 2022 at 03:40:53PM +0200, Michal Orzel wrote:
> > >> Script automation/scripts/containerize makes it easy to build Xen within
> > >> predefined containers from gitlab container registry. However, it is
> > >> currently not possible to use it with Arm containers because they are not
> > >> listed in the script. Populate the necessary entries.
> > > 
> > > FYI, those entry are just helper/shortcut/aliases, you can use any
> > > arbitrary container with the script, it just more annoying.
> > > 
> > > Your patch here allows to write:
> > >     CONTAINER=unstable-arm64v8 automation/scripts/containerize
> > > but you could write the following instead, for the same result:
> > >     CONTAINER=registry.gitlab.com/xen-project/xen/debian:unstable-arm64v8 automation/scripts/containerize
> > > 
> > > I wonder if the script could select the right container base on the
> > > architecture of the host, because "alpine" and "alpine-arm64v8" will not
> > > both work on the same machine. It might be nice to just choose "alpine"
> > > and the script would select the x86 or arm container automagically. Just
> > > an idea, no need to do anything about it.
> > I'm not in favor of adding the automatic selection based on the host.
> > The reason is that on x86 you can run both x86 and e.g. Arm containers.
> > You just need to use register qemu-user-static [1] to perform emulation.
> > This is something widely used and I use that to test Arm images/containers on x86 host.
> > So you can run both alpine and alpine-arm64v8 on the same machine.
> 
> Yeah and modern Docker sets up qemu-user-static automatically without
> the user having to do anything. Anthony, you can try it yourself: you
> should be able to just:
> 
>   docker run -it registry.gitlab.com/xen-project/xen/debian:unstable-arm64v8
> 
> on your x86 host if you have a docker new enough

No, it isn't so easy, there is at least one step that might be needed,
actually having qemu-user-static on the machine.

But thanks to both of you, I've learned about qemu-user-static, and that
it isn't necessarily complicated to setup. It is actually very easy to
setup once we know what to look for, I've just had to install a packaged
called "qemu-user-static" and that's all that was needed for the above
command line to work. Installing that package worked on two different
Linux distribution for me (on a derivative of Debian stable and on Arch
Linux) so it's likely to work in many cases, at least on x86.

Cheers,
diff mbox series

Patch

diff --git a/automation/scripts/containerize b/automation/scripts/containerize
index 9d4beca4fa4b..0f4645c4cccb 100755
--- a/automation/scripts/containerize
+++ b/automation/scripts/containerize
@@ -25,6 +25,7 @@  die() {
 BASE="registry.gitlab.com/xen-project/xen"
 case "_${CONTAINER}" in
     _alpine) CONTAINER="${BASE}/alpine:3.12" ;;
+    _alpine-arm64v8) CONTAINER="${BASE}/alpine:3.12-arm64v8" ;;
     _archlinux|_arch) CONTAINER="${BASE}/archlinux:current" ;;
     _riscv64) CONTAINER="${BASE}/archlinux:riscv64" ;;
     _centos7) CONTAINER="${BASE}/centos:7" ;;
@@ -35,6 +36,8 @@  case "_${CONTAINER}" in
     _stretch|_) CONTAINER="${BASE}/debian:stretch" ;;
     _buster-gcc-ibt) CONTAINER="${BASE}/debian:buster-gcc-ibt" ;;
     _unstable|_) CONTAINER="${BASE}/debian:unstable" ;;
+    _unstable-arm32-gcc) CONTAINER="${BASE}/debian:unstable-arm32-gcc" ;;
+    _unstable-arm64v8) CONTAINER="${BASE}/debian:unstable-arm64v8" ;;
     _trusty) CONTAINER="${BASE}/ubuntu:trusty" ;;
     _xenial) CONTAINER="${BASE}/ubuntu:xenial" ;;
     _opensuse-leap|_leap) CONTAINER="${BASE}/suse:opensuse-leap" ;;