diff mbox series

[v3,2/4] tests/acceptance: boot_linux_console: Add boot Linux with kvm tests

Message ID 20200122012753.9846-3-wainersm@redhat.com (mailing list archive)
State New, archived
Headers show
Series Acceptance tests: boot Linux with KVM test | expand

Commit Message

Wainer dos Santos Moschetta Jan. 22, 2020, 1:27 a.m. UTC
Added boot Linux test cases that launch QEMU with kvm
enabled. Likewise it was added tests for tcg.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
---
 tests/acceptance/boot_linux_console.py | 88 ++++++++++++++++++++------
 1 file changed, 68 insertions(+), 20 deletions(-)

Comments

Andrew Jones Jan. 22, 2020, 9:02 a.m. UTC | #1
On Tue, Jan 21, 2020 at 10:27:51PM -0300, Wainer dos Santos Moschetta wrote:
> +    def test_aarch64_virt_kvm(self):
> +        """
> +        :avocado: tags=arch:aarch64
> +        :avocado: tags=machine:virt
> +        :avocado: tags=accel:kvm
> +        """
> +        self.do_test_aarch64_virt()
> +
> +    def test_aarch64_virt_tcg(self):
> +        """
> +        :avocado: tags=arch:aarch64
> +        :avocado: tags=machine:virt
> +        :avocado: tags=accel:tcg
> +        """
> +        self.do_test_aarch64_virt()
> +

Does do_test_aarch64_virt() add more machine parameters? Also, which cpu
type does it choose? The reason I ask is because aarch64 virt will fail to
run with KVM unless the appropriate gic version is specified (the
gic-version machine parameter). Also the cpu type must be 'host' or 'max'.
'max' is the better choice as it also works for tcg. gic-version also
takes 'max' allowing it to auto-select the appropriate version. So if it's
not already there somewhere, then please ensure aarch64 has these
additional parameters:

 machine:gic-version=max
 cpu:max

Thanks,
drew
Wainer dos Santos Moschetta Jan. 23, 2020, 9:47 p.m. UTC | #2
On 1/22/20 7:02 AM, Andrew Jones wrote:
> On Tue, Jan 21, 2020 at 10:27:51PM -0300, Wainer dos Santos Moschetta wrote:
>> +    def test_aarch64_virt_kvm(self):
>> +        """
>> +        :avocado: tags=arch:aarch64
>> +        :avocado: tags=machine:virt
>> +        :avocado: tags=accel:kvm
>> +        """
>> +        self.do_test_aarch64_virt()
>> +
>> +    def test_aarch64_virt_tcg(self):
>> +        """
>> +        :avocado: tags=arch:aarch64
>> +        :avocado: tags=machine:virt
>> +        :avocado: tags=accel:tcg
>> +        """
>> +        self.do_test_aarch64_virt()
>> +
> Does do_test_aarch64_virt() add more machine parameters? Also, which cpu
> type does it choose? The reason I ask is because aarch64 virt will fail to
> run with KVM unless the appropriate gic version is specified (the
> gic-version machine parameter). Also the cpu type must be 'host' or 'max'.
> 'max' is the better choice as it also works for tcg. gic-version also
> takes 'max' allowing it to auto-select the appropriate version. So if it's
> not already there somewhere, then please ensure aarch64 has these
> additional parameters:
>
>   machine:gic-version=max
>   cpu:max


The test was passing '-cpu cortex-a56', I replaced with '-cpu max'. 
Also, now, it passes the gic version as you pointed out. I will send 
those changes on a v4.

Other than that, I tried '-cpu max -machine virt' (without gic-version) 
and QEMU crashed:

[root@virtlab-arm03 build]# ./aarch64-softmmu/qemu-system-aarch64 -accel 
kvm -cpu max -machine virt -display none -vga none
qemu-system-aarch64: PMU: KVM_SET_DEVICE_ATTR: Invalid argument
qemu-system-aarch64: failed to set irq for PMU
Aborted (core dumped)

----

Should I expect it to crash or rather nicely fail?

Thanks !

- Wainer


>
> Thanks,
> drew
Andrew Jones Jan. 24, 2020, 7:54 a.m. UTC | #3
On Thu, Jan 23, 2020 at 07:47:19PM -0200, Wainer dos Santos Moschetta wrote:
> 
> On 1/22/20 7:02 AM, Andrew Jones wrote:
> > On Tue, Jan 21, 2020 at 10:27:51PM -0300, Wainer dos Santos Moschetta wrote:
> > > +    def test_aarch64_virt_kvm(self):
> > > +        """
> > > +        :avocado: tags=arch:aarch64
> > > +        :avocado: tags=machine:virt
> > > +        :avocado: tags=accel:kvm
> > > +        """
> > > +        self.do_test_aarch64_virt()
> > > +
> > > +    def test_aarch64_virt_tcg(self):
> > > +        """
> > > +        :avocado: tags=arch:aarch64
> > > +        :avocado: tags=machine:virt
> > > +        :avocado: tags=accel:tcg
> > > +        """
> > > +        self.do_test_aarch64_virt()
> > > +
> > Does do_test_aarch64_virt() add more machine parameters? Also, which cpu
> > type does it choose? The reason I ask is because aarch64 virt will fail to
> > run with KVM unless the appropriate gic version is specified (the
> > gic-version machine parameter). Also the cpu type must be 'host' or 'max'.
> > 'max' is the better choice as it also works for tcg. gic-version also
> > takes 'max' allowing it to auto-select the appropriate version. So if it's
> > not already there somewhere, then please ensure aarch64 has these
> > additional parameters:
> > 
> >   machine:gic-version=max
> >   cpu:max
> 
> 
> The test was passing '-cpu cortex-a56', I replaced with '-cpu max'. Also,
> now, it passes the gic version as you pointed out. I will send those changes
> on a v4.
> 
> Other than that, I tried '-cpu max -machine virt' (without gic-version) and
> QEMU crashed:
> 
> [root@virtlab-arm03 build]# ./aarch64-softmmu/qemu-system-aarch64 -accel kvm
> -cpu max -machine virt -display none -vga none
> qemu-system-aarch64: PMU: KVM_SET_DEVICE_ATTR: Invalid argument
> qemu-system-aarch64: failed to set irq for PMU
> Aborted (core dumped)
> 
> ----
> 
> Should I expect it to crash or rather nicely fail?

crash, unfortunately. I recall we once had a plan to send patches to
fail nicer, and to output a hint on how to resolve the issue, but I
guess that never happened...

Thanks,
drew
Philippe Mathieu-Daudé Jan. 24, 2020, 3:45 p.m. UTC | #4
On 1/22/20 2:27 AM, Wainer dos Santos Moschetta wrote:
> Added boot Linux test cases that launch QEMU with kvm
> enabled. Likewise it was added tests for tcg.
> 
> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
> ---
>   tests/acceptance/boot_linux_console.py | 88 ++++++++++++++++++++------
>   1 file changed, 68 insertions(+), 20 deletions(-)
> 
> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
> index e40b84651b..a36eae630c 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -51,11 +51,7 @@ class BootLinuxConsole(Test):
>           os.chdir(cwd)
>           return self.workdir + path
>   
> -    def test_x86_64_pc(self):
> -        """
> -        :avocado: tags=arch:x86_64
> -        :avocado: tags=machine:pc
> -        """
> +    def do_test_x86_64_pc(self):
>           kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
>                         '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
>                         '/vmlinuz')
> @@ -70,6 +66,22 @@ class BootLinuxConsole(Test):
>           console_pattern = 'Kernel command line: %s' % kernel_command_line
>           self.wait_for_console_pattern(console_pattern)
>   
> +    def test_x86_64_pc_kvm(self):
> +        """
> +        :avocado: tags=arch:x86_64
> +        :avocado: tags=machine:pc
> +        :avocado: tags=accel:kvm
> +        """
> +        self.do_test_x86_64_pc()
> +
> +    def test_x86_64_pc_tcg(self):
> +        """
> +        :avocado: tags=arch:x86_64
> +        :avocado: tags=machine:pc
> +        :avocado: tags=accel:tcg
> +        """
> +        self.do_test_x86_64_pc()
[...]
So you want to test a binary linked with multiple accelerators.

Isn't it possible to have something clever/simpler?

    def test_x86_64_pc(self):
        """
        :avocado: tags=arch:x86_64
        :avocado: tags=machine:pc
        :avocado: tags=accel:kvm
        :avocado: tags=accel:tcg
        """
        self.do_test_x86_64_pc()

And use a mux config?

Because else we are duplicating a lot of code, and there are various 
accelerators available:

$ git grep ACCEL_CLASS_NAME
accel/qtest.c:41:#define TYPE_QTEST_ACCEL ACCEL_CLASS_NAME("qtest")
accel/tcg/tcg-all.c:46:#define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg")
hw/xen/xen-common.c:200:#define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
include/sysemu/hvf.h:100:#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
include/sysemu/kvm_int.h:36:#define TYPE_KVM_ACCEL ACCEL_CLASS_NAME("kvm")
target/i386/hax-all.c:1127:    .name = ACCEL_CLASS_NAME("hax"),
target/i386/whpx-all.c:1533:    .name = ACCEL_CLASS_NAME("whpx"),

And also pending:
target/i386/nvmm-all.c:   .name = ACCEL_CLASS_NAME("nvmm"),
https://www.mail-archive.com/qemu-devel@nongnu.org/msg668697.html
Thomas Huth Jan. 24, 2020, 3:47 p.m. UTC | #5
On 24/01/2020 16.45, Philippe Mathieu-Daudé wrote:
> On 1/22/20 2:27 AM, Wainer dos Santos Moschetta wrote:
>> Added boot Linux test cases that launch QEMU with kvm
>> enabled. Likewise it was added tests for tcg.
>>
>> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
>> ---
>>   tests/acceptance/boot_linux_console.py | 88 ++++++++++++++++++++------
>>   1 file changed, 68 insertions(+), 20 deletions(-)
>>
>> diff --git a/tests/acceptance/boot_linux_console.py
>> b/tests/acceptance/boot_linux_console.py
>> index e40b84651b..a36eae630c 100644
>> --- a/tests/acceptance/boot_linux_console.py
>> +++ b/tests/acceptance/boot_linux_console.py
>> @@ -51,11 +51,7 @@ class BootLinuxConsole(Test):
>>           os.chdir(cwd)
>>           return self.workdir + path
>>   -    def test_x86_64_pc(self):
>> -        """
>> -        :avocado: tags=arch:x86_64
>> -        :avocado: tags=machine:pc
>> -        """
>> +    def do_test_x86_64_pc(self):
>>           kernel_url =
>> ('https://archives.fedoraproject.org/pub/archive/fedora'
>>                        
>> '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
>>                         '/vmlinuz')
>> @@ -70,6 +66,22 @@ class BootLinuxConsole(Test):
>>           console_pattern = 'Kernel command line: %s' %
>> kernel_command_line
>>           self.wait_for_console_pattern(console_pattern)
>>   +    def test_x86_64_pc_kvm(self):
>> +        """
>> +        :avocado: tags=arch:x86_64
>> +        :avocado: tags=machine:pc
>> +        :avocado: tags=accel:kvm
>> +        """
>> +        self.do_test_x86_64_pc()
>> +
>> +    def test_x86_64_pc_tcg(self):
>> +        """
>> +        :avocado: tags=arch:x86_64
>> +        :avocado: tags=machine:pc
>> +        :avocado: tags=accel:tcg
>> +        """
>> +        self.do_test_x86_64_pc()
> [...]
> So you want to test a binary linked with multiple accelerators.
> 
> Isn't it possible to have something clever/simpler?
> 
>    def test_x86_64_pc(self):
>        """
>        :avocado: tags=arch:x86_64
>        :avocado: tags=machine:pc
>        :avocado: tags=accel:kvm
>        :avocado: tags=accel:tcg
>        """
>        self.do_test_x86_64_pc()
> 
> And use a mux config?
> 
> Because else we are duplicating a lot of code, and there are various
> accelerators available:
> 
> $ git grep ACCEL_CLASS_NAME
> accel/qtest.c:41:#define TYPE_QTEST_ACCEL ACCEL_CLASS_NAME("qtest")
> accel/tcg/tcg-all.c:46:#define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg")
> hw/xen/xen-common.c:200:#define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> include/sysemu/hvf.h:100:#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
> include/sysemu/kvm_int.h:36:#define TYPE_KVM_ACCEL ACCEL_CLASS_NAME("kvm")
> target/i386/hax-all.c:1127:    .name = ACCEL_CLASS_NAME("hax"),
> target/i386/whpx-all.c:1533:    .name = ACCEL_CLASS_NAME("whpx"),
> 
> And also pending:
> target/i386/nvmm-all.c:   .name = ACCEL_CLASS_NAME("nvmm"),
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg668697.html

Is anybody running any of these in a CI environment?

 Thomas
Wainer dos Santos Moschetta Feb. 4, 2020, 9:25 p.m. UTC | #6
On 1/24/20 1:45 PM, Philippe Mathieu-Daudé wrote:
> On 1/22/20 2:27 AM, Wainer dos Santos Moschetta wrote:
>> Added boot Linux test cases that launch QEMU with kvm
>> enabled. Likewise it was added tests for tcg.
>>
>> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
>> ---
>>   tests/acceptance/boot_linux_console.py | 88 ++++++++++++++++++++------
>>   1 file changed, 68 insertions(+), 20 deletions(-)
>>
>> diff --git a/tests/acceptance/boot_linux_console.py 
>> b/tests/acceptance/boot_linux_console.py
>> index e40b84651b..a36eae630c 100644
>> --- a/tests/acceptance/boot_linux_console.py
>> +++ b/tests/acceptance/boot_linux_console.py
>> @@ -51,11 +51,7 @@ class BootLinuxConsole(Test):
>>           os.chdir(cwd)
>>           return self.workdir + path
>>   -    def test_x86_64_pc(self):
>> -        """
>> -        :avocado: tags=arch:x86_64
>> -        :avocado: tags=machine:pc
>> -        """
>> +    def do_test_x86_64_pc(self):
>>           kernel_url = 
>> ('https://archives.fedoraproject.org/pub/archive/fedora'
>> '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
>>                         '/vmlinuz')
>> @@ -70,6 +66,22 @@ class BootLinuxConsole(Test):
>>           console_pattern = 'Kernel command line: %s' % 
>> kernel_command_line
>>           self.wait_for_console_pattern(console_pattern)
>>   +    def test_x86_64_pc_kvm(self):
>> +        """
>> +        :avocado: tags=arch:x86_64
>> +        :avocado: tags=machine:pc
>> +        :avocado: tags=accel:kvm
>> +        """
>> +        self.do_test_x86_64_pc()
>> +
>> +    def test_x86_64_pc_tcg(self):
>> +        """
>> +        :avocado: tags=arch:x86_64
>> +        :avocado: tags=machine:pc
>> +        :avocado: tags=accel:tcg
>> +        """
>> +        self.do_test_x86_64_pc()
> [...]
> So you want to test a binary linked with multiple accelerators.
>
> Isn't it possible to have something clever/simpler?


It is feasible using Avocado's CIT [1] or PICT [2] plug-ins. This work 
is suggested by Cleber in [3] and I've it on my radar for future work.

But, for the moment, I would like to have those simple boot with KVM 
tests merged so that they are executed in our Travis CI.

[1] 
https://avocado-framework.readthedocs.io/en/75.1/plugins/optional/varianter_cit.html

[2] 
https://avocado-framework.readthedocs.io/en/75.1/plugins/optional/varianter_pict.html

[3] 
https://trello.com/c/1wvzcxHY/105-create-cit-parameter-for-acceptance-tests

>
>
>    def test_x86_64_pc(self):
>        """
>        :avocado: tags=arch:x86_64
>        :avocado: tags=machine:pc
>        :avocado: tags=accel:kvm
>        :avocado: tags=accel:tcg
>        """
>        self.do_test_x86_64_pc()
>
> And use a mux config?
>
> Because else we are duplicating a lot of code, and there are various 
> accelerators available:
>
> $ git grep ACCEL_CLASS_NAME
> accel/qtest.c:41:#define TYPE_QTEST_ACCEL ACCEL_CLASS_NAME("qtest")
> accel/tcg/tcg-all.c:46:#define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg")
> hw/xen/xen-common.c:200:#define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> include/sysemu/hvf.h:100:#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
> include/sysemu/kvm_int.h:36:#define TYPE_KVM_ACCEL 
> ACCEL_CLASS_NAME("kvm")
> target/i386/hax-all.c:1127:    .name = ACCEL_CLASS_NAME("hax"),
> target/i386/whpx-all.c:1533:    .name = ACCEL_CLASS_NAME("whpx"),

Unfortunately I don't have enough time, resources and knowledge to work 
on accelerators other than kvm and tcg. I appreciate if others could 
contribute here, and I'm happy to review the patches.

Another point is how those tests could be ran on our CI.

Thanks for bringing those points!

- Wainer

>
>
> And also pending:
> target/i386/nvmm-all.c:   .name = ACCEL_CLASS_NAME("nvmm"),
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg668697.html
>
diff mbox series

Patch

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index e40b84651b..a36eae630c 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -51,11 +51,7 @@  class BootLinuxConsole(Test):
         os.chdir(cwd)
         return self.workdir + path
 
-    def test_x86_64_pc(self):
-        """
-        :avocado: tags=arch:x86_64
-        :avocado: tags=machine:pc
-        """
+    def do_test_x86_64_pc(self):
         kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
                       '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
                       '/vmlinuz')
@@ -70,6 +66,22 @@  class BootLinuxConsole(Test):
         console_pattern = 'Kernel command line: %s' % kernel_command_line
         self.wait_for_console_pattern(console_pattern)
 
+    def test_x86_64_pc_kvm(self):
+        """
+        :avocado: tags=arch:x86_64
+        :avocado: tags=machine:pc
+        :avocado: tags=accel:kvm
+        """
+        self.do_test_x86_64_pc()
+
+    def test_x86_64_pc_tcg(self):
+        """
+        :avocado: tags=arch:x86_64
+        :avocado: tags=machine:pc
+        :avocado: tags=accel:tcg
+        """
+        self.do_test_x86_64_pc()
+
     def test_mips_malta(self):
         """
         :avocado: tags=arch:mips
@@ -258,11 +270,7 @@  class BootLinuxConsole(Test):
         kernel_hash = '18d1c68f2e23429e266ca39ba5349ccd0aeb7180'
         self.do_test_mips_malta32el_nanomips(kernel_url, kernel_hash)
 
-    def test_aarch64_virt(self):
-        """
-        :avocado: tags=arch:aarch64
-        :avocado: tags=machine:virt
-        """
+    def do_test_aarch64_virt(self):
         kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora'
                       '/linux/releases/29/Everything/aarch64/os/images/pxeboot'
                       '/vmlinuz')
@@ -279,6 +287,22 @@  class BootLinuxConsole(Test):
         console_pattern = 'Kernel command line: %s' % kernel_command_line
         self.wait_for_console_pattern(console_pattern)
 
+    def test_aarch64_virt_kvm(self):
+        """
+        :avocado: tags=arch:aarch64
+        :avocado: tags=machine:virt
+        :avocado: tags=accel:kvm
+        """
+        self.do_test_aarch64_virt()
+
+    def test_aarch64_virt_tcg(self):
+        """
+        :avocado: tags=arch:aarch64
+        :avocado: tags=machine:virt
+        :avocado: tags=accel:tcg
+        """
+        self.do_test_aarch64_virt()
+
     def test_arm_virt(self):
         """
         :avocado: tags=arch:arm
@@ -485,11 +509,7 @@  class BootLinuxConsole(Test):
         exec_command_and_wait_for_pattern(self, 'reboot',
                                                 'reboot: Restarting system')
 
-    def test_s390x_s390_ccw_virtio(self):
-        """
-        :avocado: tags=arch:s390x
-        :avocado: tags=machine:s390-ccw-virtio
-        """
+    def do_test_s390x_s390_ccw_virtio(self):
         kernel_url = ('https://archives.fedoraproject.org/pub/archive'
                       '/fedora-secondary/releases/29/Everything/s390x/os/images'
                       '/kernel.img')
@@ -505,6 +525,22 @@  class BootLinuxConsole(Test):
         console_pattern = 'Kernel command line: %s' % kernel_command_line
         self.wait_for_console_pattern(console_pattern)
 
+    def test_s390x_s390_ccw_virtio_kvm(self):
+        """
+        :avocado: tags=arch:s390x
+        :avocado: tags=machine:s390-ccw-virtio
+        :avocado: tags=accel:kvm
+        """
+        self.do_test_s390x_s390_ccw_virtio()
+
+    def test_s390x_s390_ccw_virtio_tcg(self):
+        """
+        :avocado: tags=arch:s390x
+        :avocado: tags=machine:s390-ccw-virtio
+        :avocado: tags=accel:tcg
+        """
+        self.do_test_s390x_s390_ccw_virtio()
+
     def test_alpha_clipper(self):
         """
         :avocado: tags=arch:alpha
@@ -526,11 +562,7 @@  class BootLinuxConsole(Test):
         console_pattern = 'Kernel command line: %s' % kernel_command_line
         self.wait_for_console_pattern(console_pattern)
 
-    def test_ppc64_pseries(self):
-        """
-        :avocado: tags=arch:ppc64
-        :avocado: tags=machine:pseries
-        """
+    def do_test_ppc64_pseries(self):
         kernel_url = ('https://archives.fedoraproject.org/pub/archive'
                       '/fedora-secondary/releases/29/Everything/ppc64le/os'
                       '/ppc/ppc64/vmlinuz')
@@ -545,6 +577,22 @@  class BootLinuxConsole(Test):
         console_pattern = 'Kernel command line: %s' % kernel_command_line
         self.wait_for_console_pattern(console_pattern)
 
+    def test_ppc64le_pseries_kvm(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:pseries
+        :avocado: tags=accel:kvm
+        """
+        self.do_test_ppc64_pseries()
+
+    def test_ppc64le_pseries_tcg(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:pseries
+        :avocado: tags=accel:tcg
+        """
+        self.do_test_ppc64_pseries()
+
     def test_m68k_q800(self):
         """
         :avocado: tags=arch:m68k