[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/2] tests/acceptance: Add PVH boot test

From: Wainer dos Santos Moschetta
Subject: Re: [PATCH 1/2] tests/acceptance: Add PVH boot test
Date: Mon, 9 Dec 2019 12:43:22 -0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 12/6/19 2:54 PM, Cleber Rosa wrote:
On Fri, Dec 06, 2019 at 09:00:11AM -0500, Wainer dos Santos Moschetta wrote:
QEMU 4.0 onward is able to boot an uncompressed kernel
image by using the x86/HVM direct boot ABI. It needs
Linux >= 4.21 built with CONFIG_PVH=y.

This introduces an acceptance test which checks an
uncompressed Linux kernel image boots properly.

Signed-off-by: Wainer dos Santos Moschetta <address@hidden>
  tests/acceptance/pvh.py | 48 +++++++++++++++++++++++++++++++++++++++++
  1 file changed, 48 insertions(+)
  create mode 100644 tests/acceptance/pvh.py

diff --git a/tests/acceptance/pvh.py b/tests/acceptance/pvh.py
new file mode 100644
index 0000000000..c68489c273
--- /dev/null
+++ b/tests/acceptance/pvh.py
@@ -0,0 +1,48 @@
+# Copyright (c) 2019 Red Hat, Inc.
+# Author:
+#  Wainer dos Santos Moschetta <address@hidden>
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+x86/HVM direct boot acceptance tests.
+from avocado.utils.kernel import KernelBuild
+from avocado_qemu import Test
+from avocado_qemu import wait_for_console_pattern
+class Pvh(Test):
+    """
+    Test suite for x86/HVM direct boot feature.
+    :avocado: tags=slow,arch=x86_64,machine=q35
+    """
+    def test_boot_vmlinux(self):
+        """
+        Boot uncompressed kernel image.
+        """
+        # QEMU can boot a vmlinux image for kernel >= 4.21 built
+        # with CONFIG_PVH=y
+        kernel_version = '5.4.1'
+        kbuild = KernelBuild(kernel_version, work_dir=self.workdir)
+        try:
+            kbuild.download()
+            kbuild.uncompress()
+            kbuild.configure(targets=['defconfig', 'kvmconfig'],
+                             extra_configs=['CONFIG_PVH=y'])
I'm aware of the reason why this uses APIs not fulfilled by
tests/requirements.txt, but, for the general public reviewing/testing
code with extra requirements, it's a good idea to bump the
requirements to a version that fulfills the requirement, and comment
out clearly on the temporary nature of the change (marking the patch).

Good idea, thanks for the tip.

For instance, for this requirement, we could have:

diff --git a/tests/requirements.txt b/tests/requirements.txt
index a2a587223a..5498d67bc1 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -1,4 +1,5 @@
  # Add Python module requirements, one per line, to be installed
  # in the tests/venv Python virtual environment. For more info,
  # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
+# [REMOVE ME] use post 73.0 Avocado containing the new kernel build APIs

This will not only help people to test it, but should also make
it work transparently on CI.

True. It could had helped me to check the missing packages on Travis to build the kernel. I'm ashamed to tell how I did it. :)

+            kbuild.build()
As stated in my response to the cover letter, I think we need to move
this elsewhere.  The *very* minimum is to have this in a setUp()
method, but we should strongly consider other solutions.

On the proposed implementation the kernel is built only once and only for this test case. If I move the code to setUp() it will attempt to build the vmlinux for every case even when not needed (suppose I add a 'boot not CONFIG_PVH vmlinux to check it properly handle error' case which uses distro's kernel). Unless I put a guard like 'do not build if already present' which IMHO is weird. In other words, IMHO setUp() should hold only code that is share-able across cases.

+        except:
+            self.cancel("Unable to build vanilla kernel %s" % kernel_version)
+        self.vm.set_machine('q35')
+        self.vm.set_console()
+        kernel_command_line = 'printk.time=0 console=ttyS0'
+        self.vm.add_args('-kernel', kbuild.vmlinux,
+                         '-append', kernel_command_line)
And just for being thorough (and purist? idealistic? Utopian? :), if
we stop and think about it, the following two lines are really what
this test is all about.  Everything else should be the test's setup.

I'm not arguing in favor of being radical and reject anything that is
not perfect, but just reminding ourselves (myself very much included)
of this general direction.

IMHO we should merge tests which are "good enough" then interactively improve them. At least they will run with some frequency and eventually catch regressions while infra bits are improved. Now, what's 'good enough' for an acceptance test? Perhaps a test that run consistently?

- Cleber.

+        self.vm.launch()
+        wait_for_console_pattern(self, 'Kernel command line: %s' %
+                                 kernel_command_line)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]