Skip to content

Commit 0a8b4fd

Browse files
committed
tests/functional: Convert the kvm_xen_guest avocado test
Use the serial console to execute the commands in the guest instead of using ssh since we don't have ssh support in the functional framework yet. Acked-by: David Woodhouse <[email protected]> Message-ID: <[email protected]> Signed-off-by: Thomas Huth <[email protected]>
1 parent d6430c1 commit 0a8b4fd

File tree

3 files changed

+55
-38
lines changed

3 files changed

+55
-38
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ S: Supported
489489
F: include/system/kvm_xen.h
490490
F: target/i386/kvm/xen*
491491
F: hw/i386/kvm/xen*
492-
F: tests/avocado/kvm_xen_guest.py
492+
F: tests/functional/test_x86_64_kvm_xen.py
493493

494494
Guest CPU Cores (other accelerators)
495495
------------------------------------

tests/functional/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ test_timeouts = {
4444
'riscv64_tuxrun' : 120,
4545
's390x_ccw_virtio' : 420,
4646
'sh4_tuxrun' : 240,
47+
'x86_64_kvm_xen' : 180,
4748
}
4849

4950
tests_generic_system = [
@@ -244,6 +245,7 @@ tests_x86_64_system_thorough = [
244245
'netdev_ethtool',
245246
'virtio_gpu',
246247
'x86_64_hotplug_cpu',
248+
'x86_64_kvm_xen',
247249
'x86_64_tuxrun',
248250
]
249251

tests/avocado/kvm_xen_guest.py renamed to tests/functional/test_x86_64_kvm_xen.py

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
#
13
# KVM Xen guest functional tests
24
#
35
# Copyright © 2021 Red Hat, Inc.
@@ -13,34 +15,28 @@
1315

1416
from qemu.machine import machine
1517

16-
from avocado_qemu import LinuxSSHMixIn
17-
from avocado_qemu import QemuSystemTest
18-
from avocado_qemu import wait_for_console_pattern
18+
from qemu_test import QemuSystemTest, Asset, exec_command_and_wait_for_pattern
19+
from qemu_test import wait_for_console_pattern
1920

20-
class KVMXenGuest(QemuSystemTest, LinuxSSHMixIn):
21-
"""
22-
:avocado: tags=arch:x86_64
23-
:avocado: tags=machine:q35
24-
:avocado: tags=accel:kvm
25-
:avocado: tags=kvm_xen_guest
26-
"""
21+
class KVMXenGuest(QemuSystemTest):
2722

28-
KERNEL_DEFAULT = 'printk.time=0 root=/dev/xvda console=ttyS0'
23+
KERNEL_DEFAULT = 'printk.time=0 root=/dev/xvda console=ttyS0 quiet'
2924

3025
kernel_path = None
3126
kernel_params = None
3227

3328
# Fetch assets from the kvm-xen-guest subdir of my shared test
3429
# images directory on fileserver.linaro.org where you can find
3530
# build instructions for how they where assembled.
36-
def get_asset(self, name, sha1):
37-
base_url = ('https://fileserver.linaro.org/s/'
38-
'kE4nCFLdQcoBF9t/download?'
39-
'path=%2Fkvm-xen-guest&files=' )
40-
url = base_url + name
41-
# use explicit name rather than failing to neatly parse the
42-
# URL into a unique one
43-
return self.fetch_asset(name=name, locations=(url), asset_hash=sha1)
31+
ASSET_KERNEL = Asset(
32+
('https://fileserver.linaro.org/s/kE4nCFLdQcoBF9t/download?'
33+
'path=%2Fkvm-xen-guest&files=bzImage'),
34+
'ec0ad7bb8c33c5982baee0a75505fe7dbf29d3ff5d44258204d6307c6fe0132a')
35+
36+
ASSET_ROOTFS = Asset(
37+
('https://fileserver.linaro.org/s/kE4nCFLdQcoBF9t/download?'
38+
'path=%2Fkvm-xen-guest&files=rootfs.ext4'),
39+
'b11045d649006c649c184e93339aaa41a8fe20a1a86620af70323252eb29e40b')
4440

4541
def common_vm_setup(self):
4642
# We also catch lack of KVM_XEN support if we fail to launch
@@ -51,10 +47,8 @@ def common_vm_setup(self):
5147
self.vm.add_args("-accel", "kvm,xen-version=0x4000a,kernel-irqchip=split")
5248
self.vm.add_args("-smp", "2")
5349

54-
self.kernel_path = self.get_asset("bzImage",
55-
"367962983d0d32109998a70b45dcee4672d0b045")
56-
self.rootfs = self.get_asset("rootfs.ext4",
57-
"f1478401ea4b3fa2ea196396be44315bab2bb5e4")
50+
self.kernel_path = self.ASSET_KERNEL.fetch()
51+
self.rootfs = self.ASSET_ROOTFS.fetch()
5852

5953
def run_and_check(self):
6054
self.vm.add_args('-kernel', self.kernel_path,
@@ -68,21 +62,22 @@ def run_and_check(self):
6862
self.vm.launch()
6963
except machine.VMLaunchFailure as e:
7064
if "Xen HVM guest support not present" in e.output:
71-
self.cancel("KVM Xen support is not present "
72-
"(need v5.12+ kernel with CONFIG_KVM_XEN)")
65+
self.skipTest("KVM Xen support is not present "
66+
"(need v5.12+ kernel with CONFIG_KVM_XEN)")
7367
elif "Property 'kvm-accel.xen-version' not found" in e.output:
74-
self.cancel("QEMU not built with CONFIG_XEN_EMU support")
68+
self.skipTest("QEMU not built with CONFIG_XEN_EMU support")
7569
else:
7670
raise e
7771

7872
self.log.info('VM launched, waiting for sshd')
7973
console_pattern = 'Starting dropbear sshd: OK'
8074
wait_for_console_pattern(self, console_pattern, 'Oops')
8175
self.log.info('sshd ready')
82-
self.ssh_connect('root', '', False)
8376

84-
self.ssh_command('cat /proc/cmdline')
85-
self.ssh_command('dmesg | grep -e "Grant table initialized"')
77+
exec_command_and_wait_for_pattern(self, 'cat /proc/cmdline', 'xen')
78+
exec_command_and_wait_for_pattern(self, 'dmesg | grep "Grant table"',
79+
'Grant table initialized')
80+
wait_for_console_pattern(self, '#', 'Oops')
8681

8782
def test_kvm_xen_guest(self):
8883
"""
@@ -94,7 +89,9 @@ def test_kvm_xen_guest(self):
9489
self.kernel_params = (self.KERNEL_DEFAULT +
9590
' xen_emul_unplug=ide-disks')
9691
self.run_and_check()
97-
self.ssh_command('grep xen-pirq.*msi /proc/interrupts')
92+
exec_command_and_wait_for_pattern(self,
93+
'grep xen-pirq.*msi /proc/interrupts',
94+
'virtio0-output')
9895

9996
def test_kvm_xen_guest_nomsi(self):
10097
"""
@@ -106,7 +103,9 @@ def test_kvm_xen_guest_nomsi(self):
106103
self.kernel_params = (self.KERNEL_DEFAULT +
107104
' xen_emul_unplug=ide-disks pci=nomsi')
108105
self.run_and_check()
109-
self.ssh_command('grep xen-pirq.* /proc/interrupts')
106+
exec_command_and_wait_for_pattern(self,
107+
'grep xen-pirq.* /proc/interrupts',
108+
'virtio0')
110109

111110
def test_kvm_xen_guest_noapic_nomsi(self):
112111
"""
@@ -118,7 +117,9 @@ def test_kvm_xen_guest_noapic_nomsi(self):
118117
self.kernel_params = (self.KERNEL_DEFAULT +
119118
' xen_emul_unplug=ide-disks noapic pci=nomsi')
120119
self.run_and_check()
121-
self.ssh_command('grep xen-pirq /proc/interrupts')
120+
exec_command_and_wait_for_pattern(self,
121+
'grep xen-pirq /proc/interrupts',
122+
'virtio0')
122123

123124
def test_kvm_xen_guest_vapic(self):
124125
"""
@@ -130,8 +131,13 @@ def test_kvm_xen_guest_vapic(self):
130131
self.kernel_params = (self.KERNEL_DEFAULT +
131132
' xen_emul_unplug=ide-disks')
132133
self.run_and_check()
133-
self.ssh_command('grep xen-pirq /proc/interrupts')
134-
self.ssh_command('grep PCI-MSI /proc/interrupts')
134+
exec_command_and_wait_for_pattern(self,
135+
'grep xen-pirq /proc/interrupts',
136+
'acpi')
137+
wait_for_console_pattern(self, '#')
138+
exec_command_and_wait_for_pattern(self,
139+
'grep PCI-MSI /proc/interrupts',
140+
'virtio0-output')
135141

136142
def test_kvm_xen_guest_novector(self):
137143
"""
@@ -143,7 +149,9 @@ def test_kvm_xen_guest_novector(self):
143149
' xen_emul_unplug=ide-disks' +
144150
' xen_no_vector_callback')
145151
self.run_and_check()
146-
self.ssh_command('grep xen-platform-pci /proc/interrupts')
152+
exec_command_and_wait_for_pattern(self,
153+
'grep xen-platform-pci /proc/interrupts',
154+
'fasteoi')
147155

148156
def test_kvm_xen_guest_novector_nomsi(self):
149157
"""
@@ -156,7 +164,9 @@ def test_kvm_xen_guest_novector_nomsi(self):
156164
' xen_emul_unplug=ide-disks pci=nomsi' +
157165
' xen_no_vector_callback')
158166
self.run_and_check()
159-
self.ssh_command('grep xen-platform-pci /proc/interrupts')
167+
exec_command_and_wait_for_pattern(self,
168+
'grep xen-platform-pci /proc/interrupts',
169+
'IO-APIC')
160170

161171
def test_kvm_xen_guest_novector_noapic(self):
162172
"""
@@ -168,4 +178,9 @@ def test_kvm_xen_guest_novector_noapic(self):
168178
' xen_emul_unplug=ide-disks' +
169179
' xen_no_vector_callback noapic')
170180
self.run_and_check()
171-
self.ssh_command('grep xen-platform-pci /proc/interrupts')
181+
exec_command_and_wait_for_pattern(self,
182+
'grep xen-platform-pci /proc/interrupts',
183+
'XT-PIC')
184+
185+
if __name__ == '__main__':
186+
QemuSystemTest.main()

0 commit comments

Comments
 (0)