diff mbox series

[v2,7/7] tests/avocado: add boot_xen tests

Message ID 20210211171945.18313-8-alex.bennee@linaro.org (mailing list archive)
State New
Headers show
Series Xen guest loader (to boot Xen+Kernel under TCG) | expand

Commit Message

Alex Bennée Feb. 11, 2021, 5:19 p.m. UTC
These tests make sure we can boot the Xen hypervisor with a Dom0
kernel using the guest-loader. We currently have to use a kernel I
built myself because there are issues using the Debian kernel images.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 MAINTAINERS                  |   1 +
 tests/acceptance/boot_xen.py | 117 +++++++++++++++++++++++++++++++++++
 2 files changed, 118 insertions(+)
 create mode 100644 tests/acceptance/boot_xen.py

Comments

Philippe Mathieu-Daudé Feb. 17, 2021, 2:31 p.m. UTC | #1
On 2/11/21 6:19 PM, Alex Bennée wrote:
> These tests make sure we can boot the Xen hypervisor with a Dom0
> kernel using the guest-loader. We currently have to use a kernel I
> built myself because there are issues using the Debian kernel images.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  MAINTAINERS                  |   1 +
>  tests/acceptance/boot_xen.py | 117 +++++++++++++++++++++++++++++++++++
>  2 files changed, 118 insertions(+)
>  create mode 100644 tests/acceptance/boot_xen.py

> diff --git a/tests/acceptance/boot_xen.py b/tests/acceptance/boot_xen.py
> new file mode 100644
> index 0000000000..8c7e091d40
> --- /dev/null
> +++ b/tests/acceptance/boot_xen.py
> @@ -0,0 +1,117 @@
> +# Functional test that boots a Xen hypervisor with a domU kernel and
> +# checks the console output is vaguely sane .
> +#
> +# Copyright (c) 2020 Linaro

2021?

Otherwise:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Cleber Rosa Feb. 17, 2021, 8:46 p.m. UTC | #2
On Thu, Feb 11, 2021 at 05:19:45PM +0000, Alex Bennée wrote:
> These tests make sure we can boot the Xen hypervisor with a Dom0
> kernel using the guest-loader. We currently have to use a kernel I
> built myself because there are issues using the Debian kernel images.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  MAINTAINERS                  |   1 +
>  tests/acceptance/boot_xen.py | 117 +++++++++++++++++++++++++++++++++++
>  2 files changed, 118 insertions(+)
>  create mode 100644 tests/acceptance/boot_xen.py
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 853f174fcf..537ca7a6f3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1998,6 +1998,7 @@ M: Alex Bennée <alex.bennee@linaro.org>
>  S: Maintained
>  F: hw/core/guest-loader.c
>  F: docs/system/guest-loader.rst
> +F: tests/acceptance/boot_xen.py
>  
>  Intel Hexadecimal Object File Loader
>  M: Su Hang <suhang16@mails.ucas.ac.cn>
> diff --git a/tests/acceptance/boot_xen.py b/tests/acceptance/boot_xen.py
> new file mode 100644
> index 0000000000..8c7e091d40
> --- /dev/null
> +++ b/tests/acceptance/boot_xen.py
> @@ -0,0 +1,117 @@
> +# Functional test that boots a Xen hypervisor with a domU kernel and
> +# checks the console output is vaguely sane .
> +#
> +# Copyright (c) 2020 Linaro
> +#
> +# Author:
> +#  Alex Bennée <alex.bennee@linaro.org>
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2 or
> +# later.  See the COPYING file in the top-level directory.
> +
> +import os
> +
> +from avocado import skipIf
> +from avocado_qemu import wait_for_console_pattern
> +from boot_linux_console import LinuxKernelTest
> +
> +
> +class BootXenBase(LinuxKernelTest):
> +    """
> +    Boots a Xen hypervisor with a Linux DomU kernel.
> +    """
> +
> +    timeout = 90
> +    XEN_COMMON_COMMAND_LINE = 'dom0_mem=128M loglvl=all guest_loglvl=all'
> +
> +    def fetch_guest_kernel(self):
> +        # Using my own built kernel - which works
> +        kernel_url = ('https://fileserver.linaro.org/'
> +                      's/JSsewXGZ6mqxPr5/download?path=%2F&files='
> +                      'linux-5.9.9-arm64-ajb')
> +        kernel_sha1 = '4f92bc4b9f88d5ab792fa7a43a68555d344e1b83'
> +        kernel_path = self.fetch_asset(kernel_url,
> +                                       asset_hash=kernel_sha1)
> +
> +        return kernel_path
> +
> +    def launch_xen(self, xen_path):
> +        """
> +        Launch Xen with a dom0 guest kernel
> +        """
> +        self.log.info("launch with xen_path: %s", xen_path)
> +        kernel_path = self.fetch_guest_kernel()
> +
> +        self.vm.set_console()
> +
> +        xen_command_line = self.XEN_COMMON_COMMAND_LINE
> +        self.vm.add_args('-machine', 'virtualization=on',
> +                         '-cpu', 'cortex-a57',
> +                         '-m', '768',
> +                         '-kernel', xen_path,
> +                         '-append', xen_command_line,
> +                         '-device',
> +                         "guest-loader,addr=0x47000000,kernel=%s,bootargs=console=hvc0"

Nitpick/OCD: single quotes to match all other args?

> +                         % (kernel_path))
> +
> +        self.vm.launch()
> +
> +        console_pattern = 'VFS: Cannot open root device'
> +        wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:")
> +
> +
> +class BootXen(BootXenBase):
> +
> +    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
> +    def test_arm64_xen_411_and_dom0(self):
> +        """
> +        :avocado: tags=arch:aarch64
> +        :avocado: tags=accel:tcg
> +        :avocado: tags=cpu:cortex-a57
> +        :avocado: tags=machine:virt
> +        """
> +        xen_url = ('https://deb.debian.org/debian/'
> +                   'pool/main/x/xen/'
> +                   'xen-hypervisor-4.11-arm64_4.11.4+37-g3263f257ca-1_arm64.deb')
> +        xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a'

This URL is already giving 404s because of a new pacakge.  I found
this to work (but yeah, won't probably last long):

        xen_url = ('http://deb.debian.org/debian/'
                   'pool/main/x/xen/'
                   'xen-hypervisor-4.11-arm64_4.11.4+57-g41a822c392-2_arm64.deb')
        xen_sha1 = 'b5a6810fc67fd50fa36afdfdfe88ce3153dd3a55'

> +        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
> +        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.11-arm64")
> +
> +        self.launch_xen(xen_path)
> +
> +    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
> +    def test_arm64_xen_414_and_dom0(self):
> +        """
> +        :avocado: tags=arch:aarch64
> +        :avocado: tags=accel:tcg
> +        :avocado: tags=cpu:cortex-a57
> +        :avocado: tags=machine:virt
> +        """
> +        xen_url = ('https://deb.debian.org/debian/'
> +                   'pool/main/x/xen/'
> +                   'xen-hypervisor-4.14-arm64_4.14.0+80-gd101b417b7-1_arm64.deb')
> +        xen_sha1 = 'b9d209dd689ed2b393e625303a225badefec1160'

Likewise here:

        xen_url = ('https://deb.debian.org/debian/'
                   'pool/main/x/xen/'
                   'xen-hypervisor-4.14-arm64_4.14.0+88-g1d1d1f5391-2_arm64.deb')
        xen_sha1 = 'f316049beaadd50482644e4955c4cdd63e3a07d5'

> +        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
> +        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.14-arm64")
> +
> +        self.launch_xen(xen_path)
> +
> +    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
> +    def test_arm64_xen_415_and_dom0(self):
> +        """
> +        :avocado: tags=arch:aarch64
> +        :avocado: tags=accel:tcg
> +        :avocado: tags=cpu:cortex-a57
> +        :avocado: tags=machine:virt
> +        """
> +
> +        xen_url = ('https://fileserver.linaro.org/'
> +                   's/JSsewXGZ6mqxPr5/download'
> +                   '?path=%2F&files=xen-upstream-4.15-unstable.deb')
> +        xen_sha1 = 'fc191172b85cf355abb95d275a24cc0f6d6579d8'
> +        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
> +        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.15-unstable")
> +
> +        self.launch_xen(xen_path)
> -- 
> 2.20.1
> 
> 

With those changes,

Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Alex Bennée Feb. 17, 2021, 10:22 p.m. UTC | #3
Cleber Rosa <crosa@redhat.com> writes:

> On Thu, Feb 11, 2021 at 05:19:45PM +0000, Alex Bennée wrote:
>> These tests make sure we can boot the Xen hypervisor with a Dom0
>> kernel using the guest-loader. We currently have to use a kernel I
>> built myself because there are issues using the Debian kernel images.
>> 
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  MAINTAINERS                  |   1 +
>>  tests/acceptance/boot_xen.py | 117 +++++++++++++++++++++++++++++++++++
>>  2 files changed, 118 insertions(+)
>>  create mode 100644 tests/acceptance/boot_xen.py
>> 
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 853f174fcf..537ca7a6f3 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -1998,6 +1998,7 @@ M: Alex Bennée <alex.bennee@linaro.org>
>>  S: Maintained
>>  F: hw/core/guest-loader.c
>>  F: docs/system/guest-loader.rst
>> +F: tests/acceptance/boot_xen.py
>>  
>>  Intel Hexadecimal Object File Loader
>>  M: Su Hang <suhang16@mails.ucas.ac.cn>
>> diff --git a/tests/acceptance/boot_xen.py b/tests/acceptance/boot_xen.py
>> new file mode 100644
>> index 0000000000..8c7e091d40
>> --- /dev/null
>> +++ b/tests/acceptance/boot_xen.py
>> @@ -0,0 +1,117 @@
>> +# Functional test that boots a Xen hypervisor with a domU kernel and
>> +# checks the console output is vaguely sane .
>> +#
>> +# Copyright (c) 2020 Linaro
>> +#
>> +# Author:
>> +#  Alex Bennée <alex.bennee@linaro.org>
>> +#
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +#
>> +# This work is licensed under the terms of the GNU GPL, version 2 or
>> +# later.  See the COPYING file in the top-level directory.
>> +
>> +import os
>> +
>> +from avocado import skipIf
>> +from avocado_qemu import wait_for_console_pattern
>> +from boot_linux_console import LinuxKernelTest
>> +
>> +
>> +class BootXenBase(LinuxKernelTest):
>> +    """
>> +    Boots a Xen hypervisor with a Linux DomU kernel.
>> +    """
>> +
>> +    timeout = 90
>> +    XEN_COMMON_COMMAND_LINE = 'dom0_mem=128M loglvl=all guest_loglvl=all'
>> +
>> +    def fetch_guest_kernel(self):
>> +        # Using my own built kernel - which works
>> +        kernel_url = ('https://fileserver.linaro.org/'
>> +                      's/JSsewXGZ6mqxPr5/download?path=%2F&files='
>> +                      'linux-5.9.9-arm64-ajb')
>> +        kernel_sha1 = '4f92bc4b9f88d5ab792fa7a43a68555d344e1b83'
>> +        kernel_path = self.fetch_asset(kernel_url,
>> +                                       asset_hash=kernel_sha1)
>> +
>> +        return kernel_path
>> +
>> +    def launch_xen(self, xen_path):
>> +        """
>> +        Launch Xen with a dom0 guest kernel
>> +        """
>> +        self.log.info("launch with xen_path: %s", xen_path)
>> +        kernel_path = self.fetch_guest_kernel()
>> +
>> +        self.vm.set_console()
>> +
>> +        xen_command_line = self.XEN_COMMON_COMMAND_LINE
>> +        self.vm.add_args('-machine', 'virtualization=on',
>> +                         '-cpu', 'cortex-a57',
>> +                         '-m', '768',
>> +                         '-kernel', xen_path,
>> +                         '-append', xen_command_line,
>> +                         '-device',
>> +                         "guest-loader,addr=0x47000000,kernel=%s,bootargs=console=hvc0"
>
> Nitpick/OCD: single quotes to match all other args?
>
>> +                         % (kernel_path))
>> +
>> +        self.vm.launch()
>> +
>> +        console_pattern = 'VFS: Cannot open root device'
>> +        wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:")
>> +
>> +
>> +class BootXen(BootXenBase):
>> +
>> +    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
>> +    def test_arm64_xen_411_and_dom0(self):
>> +        """
>> +        :avocado: tags=arch:aarch64
>> +        :avocado: tags=accel:tcg
>> +        :avocado: tags=cpu:cortex-a57
>> +        :avocado: tags=machine:virt
>> +        """
>> +        xen_url = ('https://deb.debian.org/debian/'
>> +                   'pool/main/x/xen/'
>> +                   'xen-hypervisor-4.11-arm64_4.11.4+37-g3263f257ca-1_arm64.deb')
>> +        xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a'
>
> This URL is already giving 404s because of a new pacakge.  I found
> this to work (but yeah, won't probably last long):
>
>         xen_url = ('http://deb.debian.org/debian/'
>                    'pool/main/x/xen/'
>                    'xen-hypervisor-4.11-arm64_4.11.4+57-g41a822c392-2_arm64.deb')
>         xen_sha1 = 'b5a6810fc67fd50fa36afdfdfe88ce3153dd3a55'

I think the solution is to use archive links here. There is a snapshot
archive of sid (we've used it in the past) but I suspect there isn't an
archive of old stable packages for a reason.

>
>> +        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
>> +        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.11-arm64")
>> +
>> +        self.launch_xen(xen_path)
>> +
>> +    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
>> +    def test_arm64_xen_414_and_dom0(self):
>> +        """
>> +        :avocado: tags=arch:aarch64
>> +        :avocado: tags=accel:tcg
>> +        :avocado: tags=cpu:cortex-a57
>> +        :avocado: tags=machine:virt
>> +        """
>> +        xen_url = ('https://deb.debian.org/debian/'
>> +                   'pool/main/x/xen/'
>> +                   'xen-hypervisor-4.14-arm64_4.14.0+80-gd101b417b7-1_arm64.deb')
>> +        xen_sha1 = 'b9d209dd689ed2b393e625303a225badefec1160'
>
> Likewise here:
>
>         xen_url = ('https://deb.debian.org/debian/'
>                    'pool/main/x/xen/'
>                    'xen-hypervisor-4.14-arm64_4.14.0+88-g1d1d1f5391-2_arm64.deb')
>         xen_sha1 = 'f316049beaadd50482644e4955c4cdd63e3a07d5'
>
>> +        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
>> +        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.14-arm64")
>> +
>> +        self.launch_xen(xen_path)
>> +
>> +    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
>> +    def test_arm64_xen_415_and_dom0(self):
>> +        """
>> +        :avocado: tags=arch:aarch64
>> +        :avocado: tags=accel:tcg
>> +        :avocado: tags=cpu:cortex-a57
>> +        :avocado: tags=machine:virt
>> +        """
>> +
>> +        xen_url = ('https://fileserver.linaro.org/'
>> +                   's/JSsewXGZ6mqxPr5/download'
>> +                   '?path=%2F&files=xen-upstream-4.15-unstable.deb')
>> +        xen_sha1 = 'fc191172b85cf355abb95d275a24cc0f6d6579d8'
>> +        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
>> +        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.15-unstable")
>> +
>> +        self.launch_xen(xen_path)
>> -- 
>> 2.20.1
>> 
>> 
>
> With those changes,
>
> Reviewed-by: Cleber Rosa <crosa@redhat.com>
> Tested-by: Cleber Rosa <crosa@redhat.com>
Philippe Mathieu-Daudé Feb. 18, 2021, 9:43 a.m. UTC | #4
On 2/17/21 9:46 PM, Cleber Rosa wrote:
> On Thu, Feb 11, 2021 at 05:19:45PM +0000, Alex Bennée wrote:
>> These tests make sure we can boot the Xen hypervisor with a Dom0
>> kernel using the guest-loader. We currently have to use a kernel I
>> built myself because there are issues using the Debian kernel images.
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  MAINTAINERS                  |   1 +
>>  tests/acceptance/boot_xen.py | 117 +++++++++++++++++++++++++++++++++++
>>  2 files changed, 118 insertions(+)
>>  create mode 100644 tests/acceptance/boot_xen.py

>> +class BootXen(BootXenBase):
>> +
>> +    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
>> +    def test_arm64_xen_411_and_dom0(self):
>> +        """
>> +        :avocado: tags=arch:aarch64
>> +        :avocado: tags=accel:tcg
>> +        :avocado: tags=cpu:cortex-a57
>> +        :avocado: tags=machine:virt
>> +        """
>> +        xen_url = ('https://deb.debian.org/debian/'
>> +                   'pool/main/x/xen/'
>> +                   'xen-hypervisor-4.11-arm64_4.11.4+37-g3263f257ca-1_arm64.deb')
>> +        xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a'
> 
> This URL is already giving 404s because of a new pacakge.  I found
> this to work (but yeah, won't probably last long):
> 
>         xen_url = ('http://deb.debian.org/debian/'
>                    'pool/main/x/xen/'
>                    'xen-hypervisor-4.11-arm64_4.11.4+57-g41a822c392-2_arm64.deb')
>         xen_sha1 = 'b5a6810fc67fd50fa36afdfdfe88ce3153dd3a55'

This is not the same package version... Please understand the developer
has to download the Debian package sources, check again the set of
downstream changes between 37 and 57. Each distrib number might contain
multiple downstream patches. Then the testing has to be done again,
often enabling tracing or doing single-stepping in gdb. This has a
cost in productivity. This is why I insist I prefer to use archived
well tested artifacts, rather than changing package URL randomly.

>> +        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
>> +        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.11-arm64")
>> +
>> +        self.launch_xen(xen_path)
>> +
>> +    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
>> +    def test_arm64_xen_414_and_dom0(self):
>> +        """
>> +        :avocado: tags=arch:aarch64
>> +        :avocado: tags=accel:tcg
>> +        :avocado: tags=cpu:cortex-a57
>> +        :avocado: tags=machine:virt
>> +        """
>> +        xen_url = ('https://deb.debian.org/debian/'
>> +                   'pool/main/x/xen/'
>> +                   'xen-hypervisor-4.14-arm64_4.14.0+80-gd101b417b7-1_arm64.deb')
>> +        xen_sha1 = 'b9d209dd689ed2b393e625303a225badefec1160'
> 
> Likewise here:
> 
>         xen_url = ('https://deb.debian.org/debian/'
>                    'pool/main/x/xen/'
>                    'xen-hypervisor-4.14-arm64_4.14.0+88-g1d1d1f5391-2_arm64.deb')
>         xen_sha1 = 'f316049beaadd50482644e4955c4cdd63e3a07d5'

Likewise not the same package version.

Regards,

Phil.
Cleber Rosa Feb. 18, 2021, 3:15 p.m. UTC | #5
On Wed, Feb 17, 2021 at 10:22:50PM +0000, Alex Bennée wrote:
> 
> I think the solution is to use archive links here. There is a snapshot
> archive of sid (we've used it in the past) but I suspect there isn't an
> archive of old stable packages for a reason.
>

If the packages you need are available on archives (which I wasn't
aware of), then without a doubt it is the best solution.

I assume you're going to look into that (I'll keep an eye on the list
about it).

Regards,
- Cleber.
Cleber Rosa Feb. 18, 2021, 3:22 p.m. UTC | #6
On Thu, Feb 18, 2021 at 10:43:54AM +0100, Philippe Mathieu-Daudé wrote:
> On 2/17/21 9:46 PM, Cleber Rosa wrote:
> > On Thu, Feb 11, 2021 at 05:19:45PM +0000, Alex Bennée wrote:
> >> These tests make sure we can boot the Xen hypervisor with a Dom0
> >> kernel using the guest-loader. We currently have to use a kernel I
> >> built myself because there are issues using the Debian kernel images.
> >>
> >> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> >> ---
> >>  MAINTAINERS                  |   1 +
> >>  tests/acceptance/boot_xen.py | 117 +++++++++++++++++++++++++++++++++++
> >>  2 files changed, 118 insertions(+)
> >>  create mode 100644 tests/acceptance/boot_xen.py
> 
> >> +class BootXen(BootXenBase):
> >> +
> >> +    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
> >> +    def test_arm64_xen_411_and_dom0(self):
> >> +        """
> >> +        :avocado: tags=arch:aarch64
> >> +        :avocado: tags=accel:tcg
> >> +        :avocado: tags=cpu:cortex-a57
> >> +        :avocado: tags=machine:virt
> >> +        """
> >> +        xen_url = ('https://deb.debian.org/debian/'
> >> +                   'pool/main/x/xen/'
> >> +                   'xen-hypervisor-4.11-arm64_4.11.4+37-g3263f257ca-1_arm64.deb')
> >> +        xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a'
> > 
> > This URL is already giving 404s because of a new pacakge.  I found
> > this to work (but yeah, won't probably last long):
> > 
> >         xen_url = ('http://deb.debian.org/debian/'
> >                    'pool/main/x/xen/'
> >                    'xen-hypervisor-4.11-arm64_4.11.4+57-g41a822c392-2_arm64.deb')
> >         xen_sha1 = 'b5a6810fc67fd50fa36afdfdfe88ce3153dd3a55'
> 
> This is not the same package version... Please understand the developer
> has to download the Debian package sources, check again the set of
> downstream changes between 37 and 57. Each distrib number might contain
> multiple downstream patches. Then the testing has to be done again,
> often enabling tracing or doing single-stepping in gdb. This has a
> cost in productivity. This is why I insist I prefer to use archived
> well tested artifacts, rather than changing package URL randomly.
>

I understand it's not the same version... but from my different and
limited PoV it was the obvious thing to suggest during a review.  Of
course using stable archived versions is much better (I believe Alex
will look into that for these packages).

Best,
- Cleber.
diff mbox series

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index 853f174fcf..537ca7a6f3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1998,6 +1998,7 @@  M: Alex Bennée <alex.bennee@linaro.org>
 S: Maintained
 F: hw/core/guest-loader.c
 F: docs/system/guest-loader.rst
+F: tests/acceptance/boot_xen.py
 
 Intel Hexadecimal Object File Loader
 M: Su Hang <suhang16@mails.ucas.ac.cn>
diff --git a/tests/acceptance/boot_xen.py b/tests/acceptance/boot_xen.py
new file mode 100644
index 0000000000..8c7e091d40
--- /dev/null
+++ b/tests/acceptance/boot_xen.py
@@ -0,0 +1,117 @@ 
+# Functional test that boots a Xen hypervisor with a domU kernel and
+# checks the console output is vaguely sane .
+#
+# Copyright (c) 2020 Linaro
+#
+# Author:
+#  Alex Bennée <alex.bennee@linaro.org>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+
+import os
+
+from avocado import skipIf
+from avocado_qemu import wait_for_console_pattern
+from boot_linux_console import LinuxKernelTest
+
+
+class BootXenBase(LinuxKernelTest):
+    """
+    Boots a Xen hypervisor with a Linux DomU kernel.
+    """
+
+    timeout = 90
+    XEN_COMMON_COMMAND_LINE = 'dom0_mem=128M loglvl=all guest_loglvl=all'
+
+    def fetch_guest_kernel(self):
+        # Using my own built kernel - which works
+        kernel_url = ('https://fileserver.linaro.org/'
+                      's/JSsewXGZ6mqxPr5/download?path=%2F&files='
+                      'linux-5.9.9-arm64-ajb')
+        kernel_sha1 = '4f92bc4b9f88d5ab792fa7a43a68555d344e1b83'
+        kernel_path = self.fetch_asset(kernel_url,
+                                       asset_hash=kernel_sha1)
+
+        return kernel_path
+
+    def launch_xen(self, xen_path):
+        """
+        Launch Xen with a dom0 guest kernel
+        """
+        self.log.info("launch with xen_path: %s", xen_path)
+        kernel_path = self.fetch_guest_kernel()
+
+        self.vm.set_console()
+
+        xen_command_line = self.XEN_COMMON_COMMAND_LINE
+        self.vm.add_args('-machine', 'virtualization=on',
+                         '-cpu', 'cortex-a57',
+                         '-m', '768',
+                         '-kernel', xen_path,
+                         '-append', xen_command_line,
+                         '-device',
+                         "guest-loader,addr=0x47000000,kernel=%s,bootargs=console=hvc0"
+                         % (kernel_path))
+
+        self.vm.launch()
+
+        console_pattern = 'VFS: Cannot open root device'
+        wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:")
+
+
+class BootXen(BootXenBase):
+
+    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
+    def test_arm64_xen_411_and_dom0(self):
+        """
+        :avocado: tags=arch:aarch64
+        :avocado: tags=accel:tcg
+        :avocado: tags=cpu:cortex-a57
+        :avocado: tags=machine:virt
+        """
+        xen_url = ('https://deb.debian.org/debian/'
+                   'pool/main/x/xen/'
+                   'xen-hypervisor-4.11-arm64_4.11.4+37-g3263f257ca-1_arm64.deb')
+        xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a'
+        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
+        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.11-arm64")
+
+        self.launch_xen(xen_path)
+
+    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
+    def test_arm64_xen_414_and_dom0(self):
+        """
+        :avocado: tags=arch:aarch64
+        :avocado: tags=accel:tcg
+        :avocado: tags=cpu:cortex-a57
+        :avocado: tags=machine:virt
+        """
+        xen_url = ('https://deb.debian.org/debian/'
+                   'pool/main/x/xen/'
+                   'xen-hypervisor-4.14-arm64_4.14.0+80-gd101b417b7-1_arm64.deb')
+        xen_sha1 = 'b9d209dd689ed2b393e625303a225badefec1160'
+        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
+        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.14-arm64")
+
+        self.launch_xen(xen_path)
+
+    @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
+    def test_arm64_xen_415_and_dom0(self):
+        """
+        :avocado: tags=arch:aarch64
+        :avocado: tags=accel:tcg
+        :avocado: tags=cpu:cortex-a57
+        :avocado: tags=machine:virt
+        """
+
+        xen_url = ('https://fileserver.linaro.org/'
+                   's/JSsewXGZ6mqxPr5/download'
+                   '?path=%2F&files=xen-upstream-4.15-unstable.deb')
+        xen_sha1 = 'fc191172b85cf355abb95d275a24cc0f6d6579d8'
+        xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1)
+        xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.15-unstable")
+
+        self.launch_xen(xen_path)