Skip to content

Commit 1ada452

Browse files
committed
Merge tag 'pull-request-2025-01-02' of https://gitlab.com/thuth/qemu into staging
* Update year in copyright statements * Convert the VNC test to the functional framework * Improve and update the ppc64_hv functional test * Fix broken rx_gdbsim and arm_quanta_gsj functional tests # -----BEGIN PGP SIGNATURE----- # # iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmd2alsRHHRodXRoQHJl # ZGhhdC5jb20ACgkQLtnXdP5wLbW+phAAhIWX1KlU6nHh6GUKmEgDmvFKn+eE4NlJ # BP97GUI5jsYAXgq1jqVsSw2xWzjNXVSUGq/J0jPjZElz+iAJWortCef9Ga46A9eS # qx7MjeNsLiTnaJZwLDtu6w4f9t1vdNnyBIZULV9whevn/GMF4MO4s2aBCTbIG0xT # 9HBbuVgAaz3Ga+ZWEt9kYt4OsTbWIdmLTDpKiti2qteP0WR7Hyqgztd828JSHk3R # a98jSdNgObXODacOcis2e0kr5+C1eEYjqggkxeFao1ZXdbn95MFYT1q+WBofVYPR # fnHmGkIUaJixXApd6DCo2oou99aO8nW/Y6zkj8vraQaSCqCi7NhEmuguN55apyLJ # uwzMneECZ8Yf0kOAmRT6u0BqHEXqHXaHj9YzJ6fBxKol0WVfjkCyUQ4Ozke/xFQ9 # XeVAXIus/D42OPoO2buERt+Be99TMYUV5RCIoSah2D0pwI65CyQXSpb++mah9SUI # qrUtn58Z6fcnNGrzScv0c4ZjfNwxm8Rk7hMdThCiy2PDkcYu4L5tm4TPGRm2kzG3 # MNQXEjtVHc2nQmwEZA0piBhEDoWXvcGaps9E8SlQ+MGaXqCsK11eTC6rQY1rI+ZV # 1XOXenJ2O77SCacZZb2UZk2WleTjcOsaZAMniRM7oML4zOYgCZbYq+zNdoMoTQ6E # t/2V8B24SrQ= # =9Hki # -----END PGP SIGNATURE----- # gpg: Signature made Thu 02 Jan 2025 05:28:43 EST # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "[email protected]" # gpg: Good signature from "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [unknown] # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * tag 'pull-request-2025-01-02' of https://gitlab.com/thuth/qemu: tests/functional/test_arm_quanta_gsj: Fix broken test tests/functional/test_rx_gdbsim: Use stable URL for test_linux_sash tests/functional/test_ppc64_hv: Update to Alpine 3.21.0 tests/functional/test_ppc64_hv: Update repo management tests/functional/test_ppc64_hv: Simplify console handling tests/functional: Extract the find_free_ports() function into a helper file tests/functional/test_vnc: Remove the test_no_vnc test tests/functional/test_vnc: Do not use a hard-coded VNC port tests/functional: Convert the vnc test docs: update copyright date to the year 2025 Signed-off-by: Stefan Hajnoczi <[email protected]>
2 parents 8b70d7f + c5efe54 commit 1ada452

File tree

8 files changed

+108
-75
lines changed

8 files changed

+108
-75
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
# General information about the project.
8989
project = u'QEMU'
90-
copyright = u'2024, The QEMU Project Developers'
90+
copyright = u'2025, The QEMU Project Developers'
9191
author = u'The QEMU Project Developers'
9292

9393
# The version info for the project you're documenting, acts as replacement for

include/qemu/help-texts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define QEMU_HELP_TEXTS_H
33

44
/* Copyright string for -version arguments, About dialogs, etc */
5-
#define QEMU_COPYRIGHT "Copyright (c) 2003-2024 " \
5+
#define QEMU_COPYRIGHT "Copyright (c) 2003-2025 " \
66
"Fabrice Bellard and the QEMU Project developers"
77

88
/* Bug reporting information for --help arguments, About dialogs, etc */

tests/functional/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ tests_x86_64_system_quick = [
224224
'pc_cpu_hotplug_props',
225225
'virtio_version',
226226
'x86_cpu_model_versions',
227+
'vnc',
227228
]
228229

229230
tests_x86_64_system_thorough = [

tests/functional/qemu_test/ports.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Simple functional tests for VNC functionality
4+
#
5+
# Copyright 2018, 2024 Red Hat, Inc.
6+
#
7+
# This work is licensed under the terms of the GNU GPL, version 2 or
8+
# later. See the COPYING file in the top-level directory.
9+
10+
import fcntl
11+
import os
12+
import socket
13+
import sys
14+
import tempfile
15+
16+
from .config import BUILD_DIR
17+
from typing import List
18+
19+
class Ports():
20+
21+
PORTS_ADDR = '127.0.0.1'
22+
PORTS_RANGE_SIZE = 1024
23+
PORTS_START = 49152 + ((os.getpid() * PORTS_RANGE_SIZE) % 16384)
24+
PORTS_END = PORTS_START + PORTS_RANGE_SIZE
25+
26+
def __enter__(self):
27+
lock_file = os.path.join(BUILD_DIR, "tests", "functional", "port_lock")
28+
self.lock_fh = os.open(lock_file, os.O_CREAT)
29+
fcntl.flock(self.lock_fh, fcntl.LOCK_EX)
30+
return self
31+
32+
def __exit__(self, exc_type, exc_value, traceback):
33+
fcntl.flock(self.lock_fh, fcntl.LOCK_UN)
34+
os.close(self.lock_fh)
35+
36+
def check_bind(self, port: int) -> bool:
37+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
38+
try:
39+
sock.bind((self.PORTS_ADDR, port))
40+
except OSError:
41+
return False
42+
43+
return True
44+
45+
def find_free_ports(self, count: int) -> List[int]:
46+
result = []
47+
for port in range(self.PORTS_START, self.PORTS_END):
48+
if self.check_bind(port):
49+
result.append(port)
50+
if len(result) >= count:
51+
break
52+
assert len(result) == count
53+
return result
54+
55+
def find_free_port(self) -> int:
56+
return self.find_free_ports(1)[0]

tests/functional/test_arm_quanta_gsj.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class EmcraftSf2Machine(LinuxKernelTest):
3535
@skipUnless(os.getenv('QEMU_TEST_TIMEOUT_EXPECTED'), 'Test might timeout')
3636
def test_arm_quanta_gsj(self):
3737
self.set_machine('quanta-gsj')
38-
image_path = self.uncompress(ASSET_IMAGE, 'obmc.mtd', format='gz')
38+
image_path = self.uncompress(self.ASSET_IMAGE, format='gz')
3939

4040
self.vm.set_console()
4141
drive_args = 'file=' + image_path + ',if=mtd,bus=0,unit=0'

tests/functional/test_ppc64_hv.py

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from qemu_test import QemuSystemTest, Asset
1313
from qemu_test import wait_for_console_pattern, exec_command
1414
from qemu_test import skipIfMissingCommands, skipBigDataTest
15+
from qemu_test import exec_command_and_wait_for_pattern
1516
import os
1617
import time
1718
import subprocess
@@ -34,9 +35,9 @@ class HypervisorTest(QemuSystemTest):
3435
good_message = 'VFS: Cannot open root device'
3536

3637
ASSET_ISO = Asset(
37-
('https://dl-cdn.alpinelinux.org/alpine/v3.18/'
38-
'releases/ppc64le/alpine-standard-3.18.4-ppc64le.iso'),
39-
'c26b8d3e17c2f3f0fed02b4b1296589c2390e6d5548610099af75300edd7b3ff')
38+
('https://dl-cdn.alpinelinux.org/alpine/v3.21/'
39+
'releases/ppc64le/alpine-standard-3.21.0-ppc64le.iso'),
40+
'7651ab4e3027604535c0b36e86c901b4695bf8fe97b908f5b48590f6baae8f30')
4041

4142
def extract_from_iso(self, iso, path):
4243
"""
@@ -73,31 +74,29 @@ def do_start_alpine(self):
7374
"id=drive0,read-only=true")
7475

7576
self.vm.launch()
76-
wait_for_console_pattern(self, 'Welcome to Alpine Linux 3.18')
77-
exec_command(self, 'root')
77+
ps1='localhost:~#'
7878
wait_for_console_pattern(self, 'localhost login:')
79-
wait_for_console_pattern(self, 'You may change this message by editing /etc/motd.')
79+
exec_command_and_wait_for_pattern(self, 'root', ps1)
8080
# If the time is wrong, SSL certificates can fail.
81-
exec_command(self, 'date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"'))
82-
exec_command(self, 'setup-alpine -qe')
83-
wait_for_console_pattern(self, 'Updating repository indexes... done.')
81+
exec_command_and_wait_for_pattern(self, 'date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"'), ps1)
82+
ps1='alpine:~#'
83+
exec_command_and_wait_for_pattern(self, 'setup-alpine -qe', ps1)
84+
exec_command_and_wait_for_pattern(self, 'setup-apkrepos -c1', ps1)
85+
exec_command_and_wait_for_pattern(self, 'apk update', ps1)
86+
# Could upgrade here but it usually should not be necessary
87+
# exec_command_and_wait_for_pattern(self, 'apk upgrade --available', ps1)
8488

8589
def do_stop_alpine(self):
86-
exec_command(self, 'poweroff')
90+
exec_command(self, 'echo "TEST ME"')
8791
wait_for_console_pattern(self, 'alpine:~#')
92+
exec_command(self, 'poweroff')
93+
wait_for_console_pattern(self, 'reboot: Power down')
8894
self.vm.wait()
8995

9096
def do_setup_kvm(self):
91-
exec_command(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/main > /etc/apk/repositories')
92-
wait_for_console_pattern(self, 'alpine:~#')
93-
exec_command(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/community >> /etc/apk/repositories')
94-
wait_for_console_pattern(self, 'alpine:~#')
95-
exec_command(self, 'apk update')
96-
wait_for_console_pattern(self, 'alpine:~#')
97-
exec_command(self, 'apk add qemu-system-ppc64')
98-
wait_for_console_pattern(self, 'alpine:~#')
99-
exec_command(self, 'modprobe kvm-hv')
100-
wait_for_console_pattern(self, 'alpine:~#')
97+
ps1='alpine:~#'
98+
exec_command_and_wait_for_pattern(self, 'apk add qemu-system-ppc64', ps1)
99+
exec_command_and_wait_for_pattern(self, 'modprobe kvm-hv', ps1)
101100

102101
# This uses the host's block device as the source file for guest block
103102
# device for install media. This is a bit hacky but allows reuse of the
@@ -115,16 +114,13 @@ def do_test_kvm(self, hpt=False):
115114
'-initrd /media/nvme0n1/boot/initramfs-lts '
116115
'-kernel /media/nvme0n1/boot/vmlinuz-lts '
117116
'-append \'usbcore.nousb ' + append + '\'')
118-
# Alpine 3.18 kernel seems to crash in XHCI USB driver.
119-
wait_for_console_pattern(self, 'Welcome to Alpine Linux 3.18')
120-
exec_command(self, 'root')
117+
# Alpine 3.21 kernel seems to crash in XHCI USB driver.
118+
ps1='localhost:~#'
121119
wait_for_console_pattern(self, 'localhost login:')
122-
wait_for_console_pattern(self, 'You may change this message by editing /etc/motd.')
123-
exec_command(self, 'poweroff >& /dev/null')
124-
wait_for_console_pattern(self, 'localhost:~#')
120+
exec_command_and_wait_for_pattern(self, 'root', ps1)
121+
exec_command(self, 'poweroff')
125122
wait_for_console_pattern(self, 'reboot: Power down')
126-
time.sleep(1)
127-
exec_command(self, '')
123+
# Now wait for the host's prompt to come back
128124
wait_for_console_pattern(self, 'alpine:~#')
129125

130126
def test_hv_pseries(self):

tests/functional/test_rx_gdbsim.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ class RxGdbSimMachine(QemuSystemTest):
2121
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
2222

2323
ASSET_UBOOT = Asset(
24-
'https://acc.dl.osdn.jp/users/23/23888/u-boot.bin.gz',
25-
'7146567d669e91dbac166384b29aeba1715beb844c8551e904b86831bfd9d046')
24+
('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/'
25+
'u-boot.bin'),
26+
'dd7dd4220cccf7aeb32227b26233bf39600db05c3f8e26005bcc2bf6c927207d')
2627
ASSET_DTB = Asset(
27-
'https://acc.dl.osdn.jp/users/23/23887/rx-virt.dtb',
28+
('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/'
29+
'rx-gdbsim.dtb'),
2830
'aa278d9c1907a4501741d7ee57e7f65c02dd1b3e0323b33c6d4247f1b32cf29a')
2931
ASSET_KERNEL = Asset(
30-
'http://acc.dl.osdn.jp/users/23/23845/zImage',
32+
('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/'
33+
'zImage'),
3134
'baa43205e74a7220ed8482188c5e9ce497226712abb7f4e7e4f825ce19ff9656')
3235

3336
def test_uboot(self):
@@ -36,7 +39,7 @@ def test_uboot(self):
3639
"""
3740
self.set_machine('gdbsim-r5f562n8')
3841

39-
uboot_path = self.uncompress(self.ASSET_UBOOT)
42+
uboot_path = self.ASSET_UBOOT.fetch()
4043

4144
self.vm.set_console()
4245
self.vm.add_args('-bios', uboot_path,
Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
#
13
# Simple functional tests for VNC functionality
24
#
35
# Copyright (c) 2018 Red Hat, Inc.
@@ -11,23 +13,10 @@
1113
import socket
1214
from typing import List
1315

14-
from avocado_qemu import QemuSystemTest
15-
16+
from qemu_test import QemuSystemTest
17+
from qemu_test.ports import Ports
1618

1719
VNC_ADDR = '127.0.0.1'
18-
VNC_PORT_START = 32768
19-
VNC_PORT_END = VNC_PORT_START + 1024
20-
21-
22-
def check_bind(port: int) -> bool:
23-
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
24-
try:
25-
sock.bind((VNC_ADDR, port))
26-
except OSError:
27-
return False
28-
29-
return True
30-
3120

3221
def check_connect(port: int) -> bool:
3322
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
@@ -38,27 +27,7 @@ def check_connect(port: int) -> bool:
3827

3928
return True
4029

41-
42-
def find_free_ports(count: int) -> List[int]:
43-
result = []
44-
for port in range(VNC_PORT_START, VNC_PORT_END):
45-
if check_bind(port):
46-
result.append(port)
47-
if len(result) >= count:
48-
break
49-
assert len(result) == count
50-
return result
51-
52-
5330
class Vnc(QemuSystemTest):
54-
"""
55-
:avocado: tags=vnc,quick
56-
:avocado: tags=machine:none
57-
"""
58-
def test_no_vnc(self):
59-
self.vm.add_args('-nodefaults', '-S')
60-
self.vm.launch()
61-
self.assertFalse(self.vm.qmp('query-vnc')['return']['enabled'])
6231

6332
def test_no_vnc_change_password(self):
6433
self.vm.add_args('-nodefaults', '-S')
@@ -73,7 +42,7 @@ def test_no_vnc_change_password(self):
7342
'Could not set password')
7443

7544
def test_change_password_requires_a_password(self):
76-
self.vm.add_args('-nodefaults', '-S', '-vnc', ':0')
45+
self.vm.add_args('-nodefaults', '-S', '-vnc', ':1,to=999')
7746
self.vm.launch()
7847
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
7948
set_password_response = self.vm.qmp('change-vnc-password',
@@ -85,14 +54,13 @@ def test_change_password_requires_a_password(self):
8554
'Could not set password')
8655

8756
def test_change_password(self):
88-
self.vm.add_args('-nodefaults', '-S', '-vnc', ':0,password=on')
57+
self.vm.add_args('-nodefaults', '-S', '-vnc', ':1,to=999,password=on')
8958
self.vm.launch()
9059
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
9160
self.vm.cmd('change-vnc-password',
9261
password='new_password')
9362

94-
def test_change_listen(self):
95-
a, b, c = find_free_ports(3)
63+
def do_test_change_listen(self, a, b, c):
9664
self.assertFalse(check_connect(a))
9765
self.assertFalse(check_connect(b))
9866
self.assertFalse(check_connect(c))
@@ -113,3 +81,12 @@ def test_change_listen(self):
11381
self.assertFalse(check_connect(a))
11482
self.assertTrue(check_connect(b))
11583
self.assertTrue(check_connect(c))
84+
85+
def test_change_listen(self):
86+
with Ports() as ports:
87+
a, b, c = ports.find_free_ports(3)
88+
self.do_test_change_listen(a, b, c)
89+
90+
91+
if __name__ == '__main__':
92+
QemuSystemTest.main()

0 commit comments

Comments
 (0)