tests/boot_linux_console: add extra boot acceptance tests
v2 cover tests/boot_linux_console: add extra boot acceptance tests
Add acceptance tests for the microvm machine class, PVH, and the new qboot BIOS.
In the case of the test to boot an uncompressed kernel there didn't seem to be any suitable uncompressed kernel on https://archives.fedoraproject.org/
(there is a vmlinux in kernel-debuginfo but that RPM is 575M and caused timeouts when populating the Avocado cache when first run)
so I chose an RPM with kernels for Kata that is 14M.
(there was a discussion in [1] regarding testing PVH boot but it focussed more around building a vmlinux binary during testing).
[ What prompted these patches was the discovery that a 'pc' guest booting an uncompressed kernel (PVH) with a PCI netdev hangs (before we even get guest console output) when bios-microvm.bin (qboot) is supplied via -bios (no issue when using 'q35' or 'microvm' machine classes).
E.g. adding the following line to test_x86_64_pc_qboot_pvh() is enough to trigger a guest hang during startup:self.vm.add_args('-netdev', 'user,id=n1', '-device', 'virtio-net-pci,netdev=n1')
I bisected that issue to 176d2cda0dee [2] in 4.1 but haven't worked out yet how/why the "die-id" changes impact the qboot/PVH combination (the boot succeeds with any subset of those boot variables).
Is booting the 'pc' machine class with bios-microvm.bin something that QEMU officially supports or is qboot intended for microvm only? ]
Each test added here adds about 1.5s to the overall runtime.
I have run them through the Travis QEMU CI [3] and those acceptance tests pass.
v1 -> v2
Removed unnecessary qboot test for microvm in Patches 2 and 5 [Stefano] Added SeaBIOS test for microvm to Patch2
Fix path concatenation in Patch4 to use os.path for filesystem paths [Wanier] Added Patch6 to fix extract_from_deb() to use os.path for filesystem paths Used dictionary to store kernel info in Patch5 [Philippe]
Dropped patch with typo fix that has been queued separately
Added Stefano's R-b to the patches which have not significantly changed.
[1] https://patchew.org/QEMU/[email protected]/
[2] 176d2cda0dee ("i386/cpu: Consolidate die-id validity in smp context")
[3] https://travis-ci.org/merwick/qemu/builds/645487393
[4] https://github.com/wainersm/qemu/commit/8f705e98df90b436b0f4946331d441309c437f7b
Liam Merwick (6):
tests/boot_linux_console: add microvm acceptance test tests/boot_linux_console: add BIOS acceptance test travis.yml: install rpm2cpio for acceptance tests tests/boot_linux_console: add extract_from_rpm method tests/boot_linux_console: add PVH acceptance tests tests/boot_linux_console: use os.path for filesystem paths
.travis.yml | 1 + tests/acceptance/boot_linux_console.py | 114 ++++++++++++++++++++++++++++++--- 2 files changed, 106 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/6 tests/boot_linux_console: add microvm acceptance test
Refactor test_x86_64_pc() to test_x86_64_machine() so that separate functions which specify the Avocado tag of ':avocado: tags=machine:' as being either 'pc' or 'microvm' can be used to test booting a compressed kernel using either machine class.
--- tests/acceptance/boot_linux_console.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
tests/acceptance/boot_linux_console.py +17 -3
@@ -51,10 +51,10 @@ class BootLinuxConsole(Test): os.chdir(cwd) return self.workdir + path - def test_x86_64_pc(self): + def do_test_x86_64_machine(self): """ - :avocado: tags=arch:x86_64 - :avocado: tags=machine:pc + Common routine to boot an x86_64 guest. + Caller must specify tags=arch and tags=machine """ kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
@@ -70,6 +70,20 @@ class BootLinuxConsole(Test): console_pattern = 'Kernel command line: %s' % kernel_command_line self.wait_for_console_pattern(console_pattern) + def test_x86_64_pc(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:pc + """ + self.do_test_x86_64_machine() + + def test_x86_64_microvm(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:microvm + """ + self.do_test_x86_64_machine() + def test_mips_malta(self): """ :avocado: tags=arch:mips
Signature · 1 line
1.8.3.1
Re: [PATCH v2 1/6] tests/boot_linux_console: add microvm acceptance test
Quoted 41 lines · Liam Merwick
Refactor
test_x86_64_pc()totest_x86_64_machine()so that separate functions which specify the Avocado tag of ':avocado: tags=machine:' as being either 'pc' or 'microvm' can be used to test booting a compressed kernel using either machine class.Signed-off-by Liam Merwick <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>--- tests/acceptance/boot_linux_console.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)tests/acceptance/boot_linux_console.py +10
-3@@ -51,10 +51,10 @@ class BootLinuxConsole(Test): os.chdir(cwd) return self.workdir + path - def test_x86_64_pc(self): + def do_test_x86_64_machine(self): """ - :avocado: tags=arch:x86_64 - :avocado: tags=machine:pc + Common routine to boot an x86_64 guest. + Caller must specify tags=arch and tags=machine """ kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' '/linux/releases/29/Everything/x86_64/os/images/pxeboot'@@ -70,6 +70,20 @@ class BootLinuxConsole(Test): console_pattern = 'Kernel command line: %s' % kernel_command_line self.wait_for_console_pattern(console_pattern) + def test_x86_64_pc(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:pc + """ + self.do_test_x86_64_machine() +
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 89
Quoted 10 lines
tests/acceptance/boot_linux_console.py +7
-0+ def test_x86_64_microvm(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:microvm + """ + self.do_test_x86_64_machine() + def test_mips_malta(self): """ :avocado: tags=arch:mips
Re: [PATCH v2 1/6] tests/boot_linux_console: add microvm acceptance test
Hi Liam,
Quoted 46 lines · Philippe Mathieu-Daudé
Quoted 45 lines · Liam Merwick
Refactor
test_x86_64_pc()totest_x86_64_machine()so that separate functions which specify the Avocado tag of ':avocado: tags=machine:' as being either 'pc' or 'microvm' can be used to test booting a compressed kernel using either machine class.Signed-off-by Liam Merwick <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>---
tests/acceptance/boot_linux_console.py| 20 +++++++++++++++++---1 file changed, 17 insertions(+), 3 deletions(-)tests/acceptance/boot_linux_console.py +0
-0@@ -51,10 +51,10 @@ class BootLinuxConsole(Test): os.chdir(cwd)return self.workdir + path
- deftest_x86_64_pc(self):
+ defdo_test_x86_64_machine(self):
"""
- :avocado: tags=arch:x86_64
- :avocado: tags=machine:pc
+ Common routine to boot anx86_64guest.
+ Caller must specify tags=arch and tags=machine
"""
kernel_url= ('https://archives.fedoraproject.org/pub/archive/fedora''/linux/releases/29/Everything/x86_64/os/images/pxeboot'
tests/acceptance/boot_linux_console.py +0
-0@@ -70,6 +70,20 @@ class BootLinuxConsole(Test):
console_pattern= 'Kernel command line: %s' %kernel_command_lineself.wait_for_console_pattern(console_pattern)
+ deftest_x86_64_pc(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:pc
+ """
+self.do_test_x86_64_machine()
+
+ deftest_x86_64_microvm(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:microvm
+ """
+self.do_test_x86_64_machine()
Quoted 8 lines
Quoted 5 lines
+
deftest_mips_malta(self):
"""
:avocado: tags=arch:mipsReviewed-by Philippe Mathieu-Daudé <[email protected]>
Actually this breaks testing the distrib QEMU:
(1/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc: PASS (2.58 s)
(2/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_microvm:
Output: 'qemu-system-x86_64: -machine microvm: unsupported machine type\nUse -machine help to list supported machines\n'
ERROR: timed out (15.10 s)
Do you mind testing the series testing a machine is available?
https://www.mail-archive.com/[email protected]/msg675086.html
Re: [PATCH v2 1/6] tests/boot_linux_console: add microvm acceptance test
Quoted 57 lines · Philippe Mathieu-Daudé
Hi Liam,
Quoted 45 lines · Philippe Mathieu-Daudé
Quoted 44 lines · Liam Merwick
Refactor
test_x86_64_pc()totest_x86_64_machine()so that separate functions which specify the Avocado tag of ':avocado: tags=machine:' as being either 'pc' or 'microvm' can be used to test booting a compressed kernel using either machine class.Signed-off-by Liam Merwick <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>---
tests/acceptance/boot_linux_console.py| 20 +++++++++++++++++---1 file changed, 17 insertions(+), 3 deletions(-)tests/acceptance/boot_linux_console.py +0
-0@@ -51,10 +51,10 @@ class BootLinuxConsole(Test): os.chdir(cwd)return self.workdir + path
- deftest_x86_64_pc(self):
+ defdo_test_x86_64_machine(self):
"""
- :avocado: tags=arch:x86_64
- :avocado: tags=machine:pc
+ Common routine to boot anx86_64guest.
+ Caller must specify tags=arch and tags=machine
"""
kernel_url= ('https://archives.fedoraproject.org/pub/archive/fedora' '/linux/releases/29/Everything/x86_64/os/images/pxeboot'tests/acceptance/boot_linux_console.py +0
-0@@ -70,6 +70,20 @@ class BootLinuxConsole(Test):
console_pattern= 'Kernel command line: %s' %kernel_command_lineself.wait_for_console_pattern(console_pattern)
+ deftest_x86_64_pc(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:pc
+ """
+self.do_test_x86_64_machine()
+
+ deftest_x86_64_microvm(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:microvm
+ """
+self.do_test_x86_64_machine()Quoted 8 lines
Quoted 5 lines
+
deftest_mips_malta(self):
"""
:avocado: tags=arch:mipsReviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 1 line
Actually this breaks testing the distrib QEMU:
I happen to have a QEMU RPM installed - how do I override 'make check-acceptance' to pick up /usr/bin/qemu-system-x86_64 (and /usr/share/qemu/bios-microvm.bin - not sure that is a universal location for distros)? Overriding QTEST_QEMU_BINARY didn't seem to work for me - doesn't appear to apply to the check-acceptance rule.
Quoted 11 lines
(1/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc: PASS (2.58 s)
(2/2)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_microvm:Output: 'qemu-system-x86_64: -machine microvm: unsupported machine type\nUse -machine help to list supported machines\n'
ERROR: timed out (15.10 s)Do you mind testing the series testing a machine is available?
https://www.mail-archive.com/[email protected]/msg675086.html
Sure. I'll test/review those.
Regards,
Liam
Re: [PATCH v2 1/6] tests/boot_linux_console: add microvm acceptance test
Liam,
Sorry for the long time to reply it... comments below.
Quoted 58 lines · Liam Merwick
Quoted 57 lines · Philippe Mathieu-Daudé
Hi Liam,
Quoted 53 lines · Philippe Mathieu-Daudé
Quoted 45 lines · Liam Merwick
Refactor
test_x86_64_pc()totest_x86_64_machine()so that separate functions which specify the Avocado tag of ':avocado: tags=machine:' as being either 'pc' or 'microvm' can be used to test booting a compressed kernel using either machine class.Signed-off-by Liam Merwick <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>---
tests/acceptance/boot_linux_console.py| 20 +++++++++++++++++---1 file changed, 17 insertions(+), 3 deletions(-)tests/acceptance/boot_linux_console.py +0
-0@@ -51,10 +51,10 @@ class BootLinuxConsole(Test): os.chdir(cwd)return self.workdir + path
- deftest_x86_64_pc(self):
+ defdo_test_x86_64_machine(self):
"""
- :avocado: tags=arch:x86_64
- :avocado: tags=machine:pc
+ Common routine to boot anx86_64guest.
+ Caller must specify tags=arch and tags=machine
"""
kernel_url= ('https://archives.fedoraproject.org/pub/archive/fedora' '/linux/releases/29/Everything/x86_64/os/images/pxeboot'tests/acceptance/boot_linux_console.py +0
-0@@ -70,6 +70,20 @@ class BootLinuxConsole(Test):
console_pattern= 'Kernel command line: %s' %kernel_command_lineself.wait_for_console_pattern(console_pattern)
+ deftest_x86_64_pc(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:pc
+ """
+self.do_test_x86_64_machine()tests/acceptance/boot_linux_console.py +8
-0+ + def test_x86_64_microvm(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:microvm + """ + self.do_test_x86_64_machine() +Quoted 4 lines
def
test_mips_malta(self):
"""
:avocado: tags=arch:mipsReviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 4 lines
Quoted 1 line
Actually this breaks testing the distrib QEMU:
I happen to have a QEMU RPM installed - how do I override 'make check-acceptance' to pick up
/usr/bin/qemu-system-x86_64(and/usr/share/qemu/bios-microvm.bin- not sure that is a universal location for distros)? OverridingQTEST_QEMU_BINARYdidn't seem to work for me - doesn't appear to apply to the check-acceptance rule.
So far as I know you cannot override the QEMU path with make check-acceptance. If you still need to override then you need to evoke avocado manually. Suppose it is in the build directory, do:
$ make check-venv
$ ./tests/venv/bin/avocado run -p qemu_bin=/usr/bin/qemu-system-x86_64 -t arch:x86_64 tests/acceptance/boot_linux_console.py
The -p option on the command above is used to pass a test parameter. The underlying avocado_qemu framework used on the acceptance tests recognizes the 'qemu_bin' parameter, which in case of its absence the test setup searches for a suitable QEMU built on the current directory. The avocado_qemu doesn't have a parameter to indicate the path to the bios file, so there is no way to override it (well, not entirely true and I explain it on the patch 02 of this series).
Thanks!
- Wainer
Quoted 19 lines
Quoted 11 lines
(1/2) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc: PASS (2.58 s) (2/2) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_microvm:
Output: 'qemu-system-x86_64: -machine microvm: unsupported machine type\nUse -machine help to list supported machines\n'
ERROR: timed out (15.10 s)Do you mind testing the series testing a machine is available?
https://www.mail-archive.com/[email protected]/msg675086.htmlSure. I'll test/review those.
Regards,
Liam
PATCH v2 2/6 tests/boot_linux_console: add BIOS acceptance test
In reply to Liam MerwickAdd a test to use qboot with the 'pc' machine class and SeaBIOS with the 'microvm' machine class (since microvm uses qboot by default) by adding the '-bios' option via self.vm.add_args() before calling do_test_x86_64_machine().
--- tests/acceptance/boot_linux_console.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
tests/acceptance/boot_linux_console.py +16 -1
@@ -61,7 +61,6 @@ class BootLinuxConsole(Test): '/vmlinuz') kernel_hash = '23bebd2680757891cf7adedb033532163a792495' kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) - self.vm.set_console() kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' self.vm.add_args('-kernel', kernel_path,
@@ -77,6 +76,14 @@ class BootLinuxConsole(Test): """ self.do_test_x86_64_machine() + def test_x86_64_pc_qboot(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:pc + """ + self.vm.add_args('-bios', 'pc-bios/bios-microvm.bin') + self.do_test_x86_64_machine() + def test_x86_64_microvm(self): """ :avocado: tags=arch:x86_64
@@ -84,6 +91,14 @@ class BootLinuxConsole(Test): """ self.do_test_x86_64_machine() + def test_x86_64_microvm_seabios(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:microvm + """ + self.vm.add_args('-bios', 'pc-bios/bios.bin') + self.do_test_x86_64_machine() + def test_mips_malta(self): """ :avocado: tags=arch:mips
Signature · 1 line
1.8.3.1
Re: [PATCH v2 2/6] tests/boot_linux_console: add BIOS acceptance test
Quoted 24 lines · Liam Merwick
Add a test to use qboot with the 'pc' machine class and SeaBIOS with the 'microvm' machine class (since microvm uses qboot by default) by adding the '-bios' option via
self.vm.add_args()before callingdo_test_x86_64_machine().Signed-off-by Liam Merwick <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>--- tests/acceptance/boot_linux_console.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)tests/acceptance/boot_linux_console.py +0
-1@@ -61,7 +61,6 @@ class BootLinuxConsole(Test): '/vmlinuz') kernel_hash = '23bebd2680757891cf7adedb033532163a792495' kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) - self.vm.set_console() kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' self.vm.add_args('-kernel', kernel_path,
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 84
Quoted 9 lines
tests/acceptance/boot_linux_console.py +6
-0@@ -77,6 +76,14 @@ class BootLinuxConsole(Test): """ self.do_test_x86_64_machine() + def test_x86_64_pc_qboot(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:pc + """ + self.vm.add_args('-bios', 'pc-bios/bios-microvm.bin')
This breaks running once QEMU is installed:
(2/4)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc_qboot:
qemu: could not load PC BIOS 'pc-bios/bios-microvm.bin'
ERROR: [Errno 104] Connection reset by peer (0.08 s)
Cleber, Wainer, what path should we use?
Quoted 21 lines
tests/acceptance/boot_linux_console.py +10
-0+ self.do_test_x86_64_machine() + def test_x86_64_microvm(self): """ :avocado: tags=arch:x86_64@@ -84,6 +91,14 @@ class BootLinuxConsole(Test): """ self.do_test_x86_64_machine() + def test_x86_64_microvm_seabios(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:microvm + """ + self.vm.add_args('-bios', 'pc-bios/bios.bin') + self.do_test_x86_64_machine() + def test_mips_malta(self): """ :avocado: tags=arch:mips
Re: [PATCH v2 2/6] tests/boot_linux_console: add BIOS acceptance test
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Liam Merwick
Add a test to use qboot with the 'pc' machine class and SeaBIOS with the 'microvm' machine class (since microvm uses qboot by default) by adding the '-bios' option via
self.vm.add_args()before callingdo_test_x86_64_machine().Signed-off-by Liam Merwick <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>---
tests/acceptance/boot_linux_console.py| 17 ++++++++++++++++-1 file changed, 16 insertions(+), 1 deletion(-)tests/acceptance/boot_linux_console.py +0
-0@@ -61,7 +61,6 @@ class BootLinuxConsole(Test): '/vmlinuz')
kernel_hash= '23bebd2680757891cf7adedb033532163a792495'kernel_path=self.fetch_asset(kernel_url, asset_hash=kernel_hash)-
self.vm.set_console()
kernel_command_line= self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' self.vm.add_args('-kernel',kernel_path,tests/acceptance/boot_linux_console.py +0
-0@@ -77,6 +76,14 @@ class BootLinuxConsole(Test):
Quoted 8 lines
Quoted 8 lines
"""
self.do_test_x86_64_machine()
+ deftest_x86_64_pc_qboot(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:pc
+ """
+self.vm.add_args('-bios', 'pc-bios/bios-microvm.bin')
The test boots QEMU with bios file from $PWD/pc-bios/bios-microvm.bin. If you want to get (optionally) the file from an installed QEMU you could use Avocado test parameters [1]. Here goes an example:
self.vm.add_args('-bios', self.params.get('bios_microvm', default='pc-bios/bios-microvm.bin'))
Then you evoke avocado as:
$ avocado run -p bios_microvm=/usr/share/qemu/bios-microvm.bin (...)
[1] https://avocado-framework.readthedocs.io/en/75.1/guides/writer/chapters/parameters.html
Quoted 9 lines
Quoted 1 line
This breaks running once QEMU is installed:
(2/4) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc_qboot:
qemu: could not load PC BIOS 'pc-bios/bios-microvm.bin'
ERROR: [Errno 104] Connection reset by peer (0.08 s)Cleber, Wainer, what path should we use?
Philippe, above answers your question?
Thanks,
- Wainer
Quoted 23 lines
Quoted 22 lines
+
self.do_test_x86_64_machine()
+
deftest_x86_64_microvm(self):
"""
:avocado: tags=arch:x86_64tests/acceptance/boot_linux_console.py +0
-0@@ -84,6 +91,14 @@ class BootLinuxConsole(Test):"""
self.do_test_x86_64_machine()
+ deftest_x86_64_microvm_seabios(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:microvm
+ """
+self.vm.add_args('-bios', 'pc-bios/bios.bin')+self.do_test_x86_64_machine()
+
deftest_mips_malta(self):
"""
:avocado: tags=arch:mips
Re: [PATCH v2 2/6] tests/boot_linux_console: add BIOS acceptance test
Quoted 38 lines · Wainer dos Santos Moschetta
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Liam Merwick
Add a test to use qboot with the 'pc' machine class and SeaBIOS with the 'microvm' machine class (since microvm uses qboot by default) by adding the '-bios' option via
self.vm.add_args()before callingdo_test_x86_64_machine().Signed-off-by Liam Merwick <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>---
tests/acceptance/boot_linux_console.py| 17 ++++++++++++++++-1 file changed, 16 insertions(+), 1 deletion(-)tests/acceptance/boot_linux_console.py +0
-0@@ -61,7 +61,6 @@ class BootLinuxConsole(Test): '/vmlinuz')
kernel_hash= '23bebd2680757891cf7adedb033532163a792495'kernel_path=self.fetch_asset(kernel_url, asset_hash=kernel_hash)-
self.vm.set_console()
kernel_command_line= self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' self.vm.add_args('-kernel',kernel_path,tests/acceptance/boot_linux_console.py +0
-0@@ -77,6 +76,14 @@ class BootLinuxConsole(Test):Quoted 8 lines
Quoted 8 lines
"""
self.do_test_x86_64_machine()
+ deftest_x86_64_pc_qboot(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:pc
+ """
+self.vm.add_args('-bios', 'pc-bios/bios-microvm.bin')The test boots QEMU with bios file from $PWD/pc-bios/bios-microvm.bin. If you want to get (optionally) the file from an installed QEMU you could use Avocado test parameters [1]. Here goes an example:
Quoted 9 lines
self.vm.add_args('-bios', self.params.get('bios_microvm', default='pc-bios/bios-microvm.bin'))Then you evoke avocado as:
$ avocado run -p bios_microvm=/usr/share/qemu/bios-microvm.bin (...)[1] https://avocado-framework.readthedocs.io/en/75.1/guides/writer/chapters/parameters.html
Thanks Wainer - that works well for my patches.
Regards,
Liam
Quoted 43 lines
Quoted 11 lines
Quoted 2 lines
This breaks running once QEMU is installed:
(2/4) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc_qboot:
qemu: could not load PC BIOS 'pc-bios/bios-microvm.bin'
ERROR: [Errno 104] Connection reset by peer (0.08 s)Cleber, Wainer, what path should we use?
Philippe, above answers your question?
Thanks,
- Wainer
Quoted 23 lines
Quoted 22 lines
+
self.do_test_x86_64_machine()
+
deftest_x86_64_microvm(self):
"""
:avocado: tags=arch:x86_64tests/acceptance/boot_linux_console.py +0
-0@@ -84,6 +91,14 @@ class BootLinuxConsole(Test):"""
self.do_test_x86_64_machine()
+ deftest_x86_64_microvm_seabios(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:microvm
+ """
+self.vm.add_args('-bios', 'pc-bios/bios.bin')+self.do_test_x86_64_machine()
+
deftest_mips_malta(self):
"""
:avocado: tags=arch:mips
PATCH v2 3/6 travis.yml: install rpm2cpio for acceptance tests
In reply to Liam MerwickThe extract_from_rpm() method added for the PVH acceptance tests needs rpm2cpio to extract a vmlinux binary from an RPM.
--- .travis.yml | 1 + 1 file changed, 1 insertion(+)
.travis.yml +1 -0
@@ -323,6 +323,7 @@ matrix: - python3-pil - python3-pip - python3.5-venv + - rpm2cpio - tesseract-ocr - tesseract-ocr-eng
Signature · 1 line
1.8.3.1
Re: [PATCH v2 3/6] travis.yml: install rpm2cpio for acceptance tests
Quoted 15 lines · Liam Merwick
The
extract_from_rpm()method added for the PVH acceptance tests needs rpm2cpio to extract a vmlinux binary from an RPM.Signed-off-by Liam Merwick <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>--- .travis.yml | 1 + 1 file changed, 1 insertion(+).travis.yml +0
-0
.travis.yml matrix: · line 329
Quoted 7 lines
.travis.yml +1
-0@@ -323,6 +323,7 @@ matrix: - python3-pil - python3-pip - python3.5-venv + - rpm2cpio - tesseract-ocr - tesseract-ocr-eng
PATCH v2 4/6 tests/boot_linux_console: add extract_from_rpm method
In reply to Liam MerwickAdd a method to extract a specified file from an RPM to the test's working directory and return the path to the extracted file.
--- tests/acceptance/boot_linux_console.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tests/acceptance/boot_linux_console.py +16 -0
@@ -51,6 +51,22 @@ class BootLinuxConsole(Test): os.chdir(cwd) return self.workdir + path + def extract_from_rpm(self, rpm, path): + """ + Extracts a file from an RPM package into the test workdir. + + :param rpm: path to the rpm archive + :param path: path within the rpm archive of the file to be extracted + needs to be a relative path (starting with './') because + cpio(1), which is used to extract the file, expects that. + :returns: path of the extracted file + """ + cwd = os.getcwd() + os.chdir(self.workdir) + process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True) + os.chdir(cwd) + return os.path.normpath(os.path.join(self.workdir, path)) + def do_test_x86_64_machine(self): """ Common routine to boot an x86_64 guest.
Signature · 1 line
1.8.3.1
Re: [PATCH v2 4/6] tests/boot_linux_console: add extract_from_rpm method
Quoted 28 lines · Liam Merwick
Add a method to extract a specified file from an RPM to the test's working directory and return the path to the extracted file.
Signed-off-by Liam Merwick <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- tests/acceptance/boot_linux_console.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)tests/acceptance/boot_linux_console.py +9
-0@@ -51,6 +51,22 @@ class BootLinuxConsole(Test): os.chdir(cwd) return self.workdir + path + def extract_from_rpm(self, rpm, path): + """ + Extracts a file from an RPM package into the test workdir. + + :param rpm: path to the rpm archive + :param path: path within the rpm archive of the file to be extracted + needs to be a relative path (starting with './') because + cpio(1), which is used to extract the file, expects that. + :returns: path of the extracted file
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 72
Quoted 10 lines
tests/acceptance/boot_linux_console.py +7
-0+ """ + cwd = os.getcwd() + os.chdir(self.workdir) + process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True) + os.chdir(cwd) + return os.path.normpath(os.path.join(self.workdir, path)) + def do_test_x86_64_machine(self): """ Common routine to boot an x86_64 guest.
PATCH v2 5/6 tests/boot_linux_console: add PVH acceptance tests
In reply to Liam MerwickAdd tests to boot an uncompressed kernel using the x86/HVM direct boot ABI. The vmlinux binary is obtained from a small RPM for Kata containers and extracted using the new extract_from_rpm() method.
--- tests/acceptance/boot_linux_console.py | 60 ++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 7 deletions(-)
tests/acceptance/boot_linux_console.py +53 -7
@@ -67,16 +67,40 @@ class BootLinuxConsole(Test): os.chdir(cwd) return os.path.normpath(os.path.join(self.workdir, path)) - def do_test_x86_64_machine(self): + def do_test_x86_64_machine(self, kernel_type='bzImage'): """ Common routine to boot an x86_64 guest. Caller must specify tags=arch and tags=machine - """ - kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' - '/linux/releases/29/Everything/x86_64/os/images/pxeboot' - '/vmlinuz') - kernel_hash = '23bebd2680757891cf7adedb033532163a792495' - kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) + :param kernel: specify kernel type to be downloaded and booted: + compressed = 'bzImage', uncompressed = 'vmlinux' + """ + + KERNEL_PATH_INFO = { + 'bzImage': { + 'type': 'file', + 'url': 'https://archives.fedoraproject.org/' + 'pub/archive/fedora/linux/releases/29/Everything/' + 'x86_64/os/images/pxeboot/vmlinuz', + 'hash': '23bebd2680757891cf7adedb033532163a792495' + }, + 'vmlinux': { + 'type': 'rpm', + 'url': 'https://yum.oracle.com/' + 'repo/OracleLinux/OL7/olcne/x86_64/getPackage/' + 'kernel-uek-container-4.14.35-1902.6.6.1.el7.x86_64.rpm', + 'file': './usr/share/kata-containers/' + 'vmlinux-4.14.35-1902.6.6.1.el7.container', + 'hash': '4c781711a9d32dcb8e81da2b397cb98926744e23' + } + } + + k = KERNEL_PATH_INFO[kernel_type] + if k['type'] is 'file': + kernel_path = self.fetch_asset(k['url'], asset_hash=k['hash']) + else: + assert k['type'] is 'rpm' + rpm_path = self.fetch_asset(k['url'], asset_hash=k['hash']) + kernel_path = self.extract_from_rpm(rpm_path, k['file']) self.vm.set_console() kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' self.vm.add_args('-kernel', kernel_path,
@@ -100,6 +124,21 @@ class BootLinuxConsole(Test): self.vm.add_args('-bios', 'pc-bios/bios-microvm.bin') self.do_test_x86_64_machine() + def test_x86_64_pc_pvh(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:pc + """ + self.do_test_x86_64_machine(kernel_type='vmlinux') + + def test_x86_64_pc_qboot_pvh(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:pc + """ + self.vm.add_args('-bios', 'pc-bios/bios-microvm.bin') + self.do_test_x86_64_machine(kernel_type='vmlinux') + def test_x86_64_microvm(self): """ :avocado: tags=arch:x86_64
@@ -115,6 +154,13 @@ class BootLinuxConsole(Test): self.vm.add_args('-bios', 'pc-bios/bios.bin') self.do_test_x86_64_machine() + def test_x86_64_microvm_pvh(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:microvm + """ + self.do_test_x86_64_machine(kernel_type='vmlinux') + def test_mips_malta(self): """ :avocado: tags=arch:mips
Signature · 1 line
1.8.3.1
Re: [PATCH v2 5/6] tests/boot_linux_console: add PVH acceptance tests
Quoted 62 lines · Liam Merwick
Add tests to boot an uncompressed kernel using the x86/HVM direct boot ABI. The vmlinux binary is obtained from a small RPM for Kata containers and extracted using the new
extract_from_rpm()method.Signed-off-by Liam Merwick <[email protected]>--- tests/acceptance/boot_linux_console.py | 60 ++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 7 deletions(-)tests/acceptance/boot_linux_console.py +31
-7@@ -67,16 +67,40 @@ class BootLinuxConsole(Test): os.chdir(cwd) return os.path.normpath(os.path.join(self.workdir, path)) - def do_test_x86_64_machine(self): + def do_test_x86_64_machine(self, kernel_type='bzImage'): """ Common routine to boot an x86_64 guest. Caller must specify tags=arch and tags=machine - """ - kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' - '/linux/releases/29/Everything/x86_64/os/images/pxeboot' - '/vmlinuz') - kernel_hash = '23bebd2680757891cf7adedb033532163a792495' - kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) + :param kernel: specify kernel type to be downloaded and booted: + compressed = 'bzImage', uncompressed = 'vmlinux' + """ + + KERNEL_PATH_INFO = { + 'bzImage': { + 'type': 'file', + 'url': 'https://archives.fedoraproject.org/' + 'pub/archive/fedora/linux/releases/29/Everything/' + 'x86_64/os/images/pxeboot/vmlinuz', + 'hash': '23bebd2680757891cf7adedb033532163a792495' + }, + 'vmlinux': { + 'type': 'rpm', + 'url': 'https://yum.oracle.com/' + 'repo/OracleLinux/OL7/olcne/x86_64/getPackage/' + 'kernel-uek-container-4.14.35-1902.6.6.1.el7.x86_64.rpm', + 'file': './usr/share/kata-containers/' + 'vmlinux-4.14.35-1902.6.6.1.el7.container', + 'hash': '4c781711a9d32dcb8e81da2b397cb98926744e23' + } + } + + k = KERNEL_PATH_INFO[kernel_type] + if k['type'] is 'file': + kernel_path = self.fetch_asset(k['url'], asset_hash=k['hash']) + else: + assert k['type'] is 'rpm' + rpm_path = self.fetch_asset(k['url'], asset_hash=k['hash']) + kernel_path = self.extract_from_rpm(rpm_path, k['file']) self.vm.set_console() kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' self.vm.add_args('-kernel', kernel_path,
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 132
Quoted 9 lines
tests/acceptance/boot_linux_console.py +6
-0@@ -100,6 +124,21 @@ class BootLinuxConsole(Test): self.vm.add_args('-bios', 'pc-bios/bios-microvm.bin') self.do_test_x86_64_machine() + def test_x86_64_pc_pvh(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:pc + """ + self.do_test_x86_64_machine(kernel_type='vmlinux')
This test doesn't pass with my distrib QEMU, it gets killed after using 100% of a core during 1min30:
(3/7)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_x86_64_pc_pvh:
INTERRUPTED: Test interrupted by SIGTERM (90.32 s)
I see PVH was introduced in QEMU v4.2, so with these patches:
https://www.mail-archive.com/[email protected]/msg675077.html
https://www.mail-archive.com/[email protected]/msg675075.html
You could use:
:avocado: tags=version-min:4.2
Do you mind reviewing them?
Quoted 27 lines
tests/acceptance/boot_linux_console.py +16
-0+ + def test_x86_64_pc_qboot_pvh(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:pc + """ + self.vm.add_args('-bios', 'pc-bios/bios-microvm.bin') + self.do_test_x86_64_machine(kernel_type='vmlinux') + def test_x86_64_microvm(self): """ :avocado: tags=arch:x86_64@@ -115,6 +154,13 @@ class BootLinuxConsole(Test): self.vm.add_args('-bios', 'pc-bios/bios.bin') self.do_test_x86_64_machine() + def test_x86_64_microvm_pvh(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:microvm + """ + self.do_test_x86_64_machine(kernel_type='vmlinux') + def test_mips_malta(self): """ :avocado: tags=arch:mips
PATCH v2 6/6 tests/boot_linux_console: use os.path for filesystem paths
In reply to Liam MerwickChange extract_from_deb() to use os.path routines to manipulate the filesystem path returned when extracting a file.
--- tests/acceptance/boot_linux_console.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tests/acceptance/boot_linux_console.py +6 -1
@@ -49,7 +49,12 @@ class BootLinuxConsole(Test): process.run("ar x %s %s" % (deb, file_path)) archive.extract(file_path, self.workdir) os.chdir(cwd) - return self.workdir + path + # Return complete path to extracted file. Because callers to + # extract_from_deb() specify 'path' with a leading slash, it is + # necessary to use os.path.relpath() as otherwise os.path.join() + # interprets it as an absolute path and drops the self.workdir part. + return os.path.normpath(os.path.join(self.workdir, + os.path.relpath(path, '/'))) def extract_from_rpm(self, rpm, path): """
Signature · 1 line
1.8.3.1
Re: [PATCH v2 6/6] tests/boot_linux_console: use os.path for filesystem paths
Quoted 18 lines · Liam Merwick
Change
extract_from_deb()to use os.path routines to manipulate the filesystem path returned when extracting a file.Suggested-by Wainer dos Santos Moschetta <[email protected]>Signed-off-by Liam Merwick <[email protected]>--- tests/acceptance/boot_linux_console.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/acceptance/boot_linux_console.py +0
-0@@ -49,7 +49,12 @@ class BootLinuxConsole(Test): process.run("ar x %s %s" % (deb, file_path)) archive.extract(file_path, self.workdir) os.chdir(cwd)
tests/acceptance/boot_linux_console.py class BootLinuxConsole(Test): · line 60
Quoted 10 lines
tests/acceptance/boot_linux_console.py +6
-1- return self.workdir + path + # Return complete path to extracted file. Because callers to + # extract_from_deb() specify 'path' with a leading slash, it is + # necessary to use os.path.relpath() as otherwise os.path.join() + # interprets it as an absolute path and drops the self.workdir part. + return os.path.normpath(os.path.join(self.workdir, + os.path.relpath(path, '/'))) def extract_from_rpm(self, rpm, path): """
Quoted 53 lines · Liam Merwick
Add acceptance tests for the microvm machine class, PVH, and the new qboot BIOS.
In the case of the test to boot an uncompressed kernel there didn't seem to be any suitable uncompressed kernel on https://archives.fedoraproject.org/
(there is a vmlinux in kernel-debuginfo but that RPM is 575M and caused timeouts when populating the Avocado cache when first run)
so I chose an RPM with kernels for Kata that is 14M.
(there was a discussion in [1] regarding testing PVH boot but it focussed more around building a vmlinux binary during testing).[ What prompted these patches was the discovery that a 'pc' guest booting an uncompressed kernel (PVH) with a PCI netdev hangs (before we even get guest console output) when bios-microvm.bin (qboot) is supplied via -bios (no issue when using 'q35' or 'microvm' machine classes).
E.g. adding the following line to
test_x86_64_pc_qboot_pvh()is enough to trigger a guest hang during startup:self.vm.add_args('-netdev', 'user,id=n1', '-device', 'virtio-net-pci,netdev=n1')I bisected that issue to
176d2cda0dee[2] in 4.1 but haven't worked out yet how/why the "die-id" changes impact the qboot/PVH combination (the boot succeeds with any subset of those boot variables).Is booting the 'pc' machine class with bios-microvm.bin something that QEMU officially supports or is qboot intended for microvm only? ]
Each test added here adds about 1.5s to the overall runtime.
I have run them through the Travis QEMU CI [3] and those acceptance tests pass.v1 -> v2
Removed unnecessary qboot test for microvm in Patches 2 and 5 [Stefano] Added SeaBIOS test for microvm to Patch2
Fix path concatenation in Patch4 to use os.path for filesystem paths [Wanier] Added Patch6 to fixextract_from_deb()to use os.path for filesystem paths Used dictionary to store kernel info in Patch5 [Philippe]
Dropped patch with typo fix that has been queued separately
Added Stefano's R-b to the patches which have not significantly changed.[1] https://patchew.org/QEMU/[email protected]/
[2]176d2cda0dee("i386/cpu: Consolidate die-id validity in smp context")
[3] https://travis-ci.org/merwick/qemu/builds/645487393
[4] https://github.com/wainersm/qemu/commit/8f705e98df90b436b0f4946331d441309c437f7bLiam Merwick (6):
tests/boot_linux_console: add microvm acceptance test tests/boot_linux_console: add BIOS acceptance test travis.yml: install rpm2cpio for acceptance tests tests/boot_linux_console: addextract_from_rpmmethod tests/boot_linux_console: add PVH acceptance tests tests/boot_linux_console: use os.path for filesystem paths
Quoted 3 lines
.travis.yml | 1 + tests/acceptance/boot_linux_console.py | 114 ++++++++++++++++++++++++++++++--- 2 files changed, 106 insertions(+), 9 deletions(-)
Patches 3, 4 and 6 applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next