1
+ #!/usr/bin/env python3
2
+ #
1
3
# KVM Xen guest functional tests
2
4
#
3
5
# Copyright © 2021 Red Hat, Inc.
13
15
14
16
from qemu .machine import machine
15
17
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
19
20
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 ):
27
22
28
- KERNEL_DEFAULT = 'printk.time=0 root=/dev/xvda console=ttyS0'
23
+ KERNEL_DEFAULT = 'printk.time=0 root=/dev/xvda console=ttyS0 quiet '
29
24
30
25
kernel_path = None
31
26
kernel_params = None
32
27
33
28
# Fetch assets from the kvm-xen-guest subdir of my shared test
34
29
# images directory on fileserver.linaro.org where you can find
35
30
# 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' )
44
40
45
41
def common_vm_setup (self ):
46
42
# We also catch lack of KVM_XEN support if we fail to launch
@@ -51,10 +47,8 @@ def common_vm_setup(self):
51
47
self .vm .add_args ("-accel" , "kvm,xen-version=0x4000a,kernel-irqchip=split" )
52
48
self .vm .add_args ("-smp" , "2" )
53
49
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 ()
58
52
59
53
def run_and_check (self ):
60
54
self .vm .add_args ('-kernel' , self .kernel_path ,
@@ -68,21 +62,22 @@ def run_and_check(self):
68
62
self .vm .launch ()
69
63
except machine .VMLaunchFailure as e :
70
64
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)" )
73
67
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" )
75
69
else :
76
70
raise e
77
71
78
72
self .log .info ('VM launched, waiting for sshd' )
79
73
console_pattern = 'Starting dropbear sshd: OK'
80
74
wait_for_console_pattern (self , console_pattern , 'Oops' )
81
75
self .log .info ('sshd ready' )
82
- self .ssh_connect ('root' , '' , False )
83
76
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' )
86
81
87
82
def test_kvm_xen_guest (self ):
88
83
"""
@@ -94,7 +89,9 @@ def test_kvm_xen_guest(self):
94
89
self .kernel_params = (self .KERNEL_DEFAULT +
95
90
' xen_emul_unplug=ide-disks' )
96
91
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' )
98
95
99
96
def test_kvm_xen_guest_nomsi (self ):
100
97
"""
@@ -106,7 +103,9 @@ def test_kvm_xen_guest_nomsi(self):
106
103
self .kernel_params = (self .KERNEL_DEFAULT +
107
104
' xen_emul_unplug=ide-disks pci=nomsi' )
108
105
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' )
110
109
111
110
def test_kvm_xen_guest_noapic_nomsi (self ):
112
111
"""
@@ -118,7 +117,9 @@ def test_kvm_xen_guest_noapic_nomsi(self):
118
117
self .kernel_params = (self .KERNEL_DEFAULT +
119
118
' xen_emul_unplug=ide-disks noapic pci=nomsi' )
120
119
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' )
122
123
123
124
def test_kvm_xen_guest_vapic (self ):
124
125
"""
@@ -130,8 +131,13 @@ def test_kvm_xen_guest_vapic(self):
130
131
self .kernel_params = (self .KERNEL_DEFAULT +
131
132
' xen_emul_unplug=ide-disks' )
132
133
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' )
135
141
136
142
def test_kvm_xen_guest_novector (self ):
137
143
"""
@@ -143,7 +149,9 @@ def test_kvm_xen_guest_novector(self):
143
149
' xen_emul_unplug=ide-disks' +
144
150
' xen_no_vector_callback' )
145
151
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' )
147
155
148
156
def test_kvm_xen_guest_novector_nomsi (self ):
149
157
"""
@@ -156,7 +164,9 @@ def test_kvm_xen_guest_novector_nomsi(self):
156
164
' xen_emul_unplug=ide-disks pci=nomsi' +
157
165
' xen_no_vector_callback' )
158
166
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' )
160
170
161
171
def test_kvm_xen_guest_novector_noapic (self ):
162
172
"""
@@ -168,4 +178,9 @@ def test_kvm_xen_guest_novector_noapic(self):
168
178
' xen_emul_unplug=ide-disks' +
169
179
' xen_no_vector_callback noapic' )
170
180
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