s390x and test patches 2025-01-21
Subsystems (2)
The following changes since commit 20fac491cfeebb042f59cc61ae76fed1b397d25c:
Merge tag 'qtest-20250117-pull-request' of https://gitlab.com/farosas/qemu into staging (2025-01-18 18:37:16 -0500)
are available in the Git repository at:
https://gitlab.com/thuth/qemu.git tags/pull-request-2025-01-21
for you to fetch changes up to 929efa1955ffc8bdbd79a413e8057cb35c1d9c01:
pc-bios: Update the s390 bios images with the recent changes (2025-01-21 08:53:50 +0100)
----------------------------------------------------------------
* Fix bugs related to the new "boot order" feature in the s390-ccw bios
* Fix crash that occurs when introspecting older s390-virtio-ccw machines
* Fix error in pbkdf code on fast machines (e.g. s390x with crypto adapter)
* Convert kvm_xen_guest avocado test to the functional framework
----------------------------------------------------------------
Daniel P. Berrangé (1):
crypto: fix bogus error benchmarking pbkdf on fast machines
Jared Rossi (1):
pc-bios/s390-ccw: Abort IPL on invalid loadparm
Philippe Mathieu-Daudé (1):
MAINTAINERS: Remove myself as Avocado Framework reviewer
Thomas Huth (6):
tests/functional: Convert the kvm_xen_guest avocado test hw/s390x: Fix crash that occurs when inspecting older versioned machines types pc-bios/s390-ccw/virtio: Add a function to reset a virtio device pc-bios/s390-ccw: Fix boot problem with virtio-net devices pc-bios/s390-ccw/netmain: Fix error messages with regards to the TFTP server
pc-bios: Update the s390 bios images with the recent changes
MAINTAINERS | 3 +-
pc-bios/s390-ccw/virtio.h | 2 +
crypto/pbkdf.c | 15 +++-
hw/s390x/s390-virtio-ccw.c | 15 ++--
pc-bios/s390-ccw/bootmap.c | 15 ++--
pc-bios/s390-ccw/netmain.c | 52 +++++++------
pc-bios/s390-ccw/virtio-net.c | 5 ++
pc-bios/s390-ccw/virtio.c | 7 +-
pc-bios/s390-ccw.img | Bin 79608 -> 96000 bytes
tests/functional/meson.build | 2 +
.../test_x86_64_kvm_xen.py} | 83 ++++++++++++---------
11 files changed, 125 insertions(+), 74 deletions(-)
rename tests/{avocado/kvm_xen_guest.py => functional/test_x86_64_kvm_xen.py} (64%)
mode change 100644 => 100755[PULL 8/9] pc-bios/s390-ccw: Abort IPL on invalid loadparm
From: Jared Rossi <[email protected]>
Because the loadparm specifies an exact kernel the user wants to boot, if the loadparm is invalid it must represent a misconfiguration of the guest. Thus we should abort the IPL immediately, without attempting to use other devices, to avoid booting into an unintended guest image.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/bootmap.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
pc-bios/s390-ccw/bootmap.c +9 -6
@@ -336,8 +336,7 @@ static int run_eckd_boot_script(block_number_t bmt_block_nr,debug_print_int ("loadparm" , loadparm);if (loadparm >=MAX_BOOT_ENTRIES ) { -puts ("loadparm value greater than max number of boot entries allowed" ); -return -EINVAL ; +panic ("loadparm value greater than max number of boot entries allowed" ); }memset (sec,FREE_SPACE_FILLER ,sizeof (sec));
@@ -348,8 +347,8 @@ static int run_eckd_boot_script(block_number_t bmt_block_nr, block_nr =gen_eckd_block_num (&bmt->entry[loadparm].xeckd, ldipl);if (block_nr ==NULL_BLOCK_NR ) { -puts ("Cannot find Boot Map Table Entry" ); -return -EIO ; +printf ("The requested boot entry (%d) is invalid\n" , loadparm); +panic ("Invalid loadparm" ); }memset (sec,FREE_SPACE_FILLER ,sizeof (sec));
@@ -792,8 +791,12 @@ static int ipl_scsi(void)debug_print_int ("loadparm" , loadparm);if (loadparm >=MAX_BOOT_ENTRIES ) { -puts ("loadparm value greater than max number of boot entries allowed" ); -return -EINVAL ; +panic ("loadparm value greater than max number of boot entries allowed" ); + } + +if (!valid_entries[loadparm]) { +printf ("The requested boot entry (%d) is invalid\n" , loadparm); +panic ("Invalid loadparm" ); }return zipl_run (&prog_table->entry[loadparm].scsi);
Signature · 1 line
2.48.1
[PULL 7/9] pc-bios/s390-ccw/netmain: Fix error messages with regards to the TFTP server
In reply to Thomas HuthThe code in net_init_ip() currently bails out early if "rc" is less than 0, so the if-statements that check for negative "rc" codes to print out some specific error messages with regards to the TFTP server are never reached. Move them earlier to bring that dead code back to life.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/netmain.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
pc-bios/s390-ccw/netmain.c +8 -11
@@ -168,6 +168,14 @@ static int net_init_ip(filename_ip_t *fn_ip)if (fn_ip->ip_version ==4 ) {set_ipv4_address (fn_ip->own_ip); } + }else if (rc ==-2 ) { +printf ("ARP request to TFTP server (%d.%d.%d.%d) failed\n" , + (fn_ip->server_ip >>24 ) &0xFF , (fn_ip->server_ip >>16 ) &0xFF , + (fn_ip->server_ip >>8 ) &0xFF , fn_ip->server_ip &0xFF ); +return -102 ; + }else if (rc ==-4 || rc ==-3 ) { +puts ("Can't obtain TFTP server IP address" ); +return -107 ; }else {puts ("Could not get IP address" );return -101 ;
@@ -183,17 +191,6 @@ static int net_init_ip(filename_ip_t *fn_ip)printf (" Using IPv6 address: %s\n" , ip6_str); } -if (rc ==-2 ) { -printf ("ARP request to TFTP server (%d.%d.%d.%d) failed\n" , - (fn_ip->server_ip >>24 ) &0xFF , (fn_ip->server_ip >>16 ) &0xFF , - (fn_ip->server_ip >>8 ) &0xFF , fn_ip->server_ip &0xFF ); -return -102 ; - } -if (rc ==-4 || rc ==-3 ) { -puts ("Can't obtain TFTP server IP address" ); -return -107 ; - } -printf (" Using TFTP server: " );if (fn_ip->ip_version ==4 ) { printf("%d.%d.%d.%d\n",
Signature · 1 line
2.48.1
[PULL 3/9] crypto: fix bogus error benchmarking pbkdf on fast machines
In reply to Thomas HuthFrom: Daniel P. Berrangé <[email protected]>
We're seeing periodic reports of errors like:
$ qemu-img create -f luks --object secret,data=123456,id=sec0 \
-o key-secret=sec0 luks-info.img 1M
Formatting 'luks-info.img', fmt=luks size=1048576 key-secret=sec0
qemu-img: luks-info.img: Unable to get accurate CPU usageThis error message comes from a recent attempt to workaround a kernel bug with measuring rusage in long running processes:
commit c72cab5ad9f849bbcfcf4be7952b8b8946cc626e
Author: Tiago Pasqualini <[email protected]>
Date: Wed Sep 4 20:52:30 2024 -0300
crypto: run qcrypto_pbkdf2_count_iters in a new thread
Unfortunately this has a subtle bug on machines which are very fast.
On the first time around the loop, the 'iterations' value is quite small (1 << 15), and so will run quite fast. Testing has shown that some machines can complete this benchmarking task in as little as 7 milliseconds.
Unfortunately the 'getrusage' data is not updated at the time of the 'getrusage' call, it is done asynchronously by the scheduler. The 7 millisecond completion time for the benchmark is short enough that 'getrusage' sometimes reports 0 accumulated execution time.
As a result the 'delay_ms == 0' sanity check in the above commit is triggering non-deterministically on such machines.
The benchmarking loop intended to run multiple times, increasing the 'iterations' value until the benchmark ran for > 500 ms, but the sanity check doesn't allow this to happen.
To fix it, we keep a loop counter and only run the sanity check after we've been around the loop more than 5 times. At that point the 'iterations' value is high enough that even with infrequent updates of 'getrusage' accounting data on fast machines, we should see a non-zero value.
Message-ID: <[email protected]>
--- crypto/pbkdf.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
crypto/pbkdf.c +13 -2
@@ -107,7 +107,7 @@ static void *threaded_qcrypto_pbkdf2_count_iters(void *data)size_t nsalt = iters_data->nsalt;size_t nout = iters_data->nout;Error **errp = iters_data->errp; - +size_t scaled =0 ;uint64_t ret =-1 ; g_autofree uint8_t *out = g_new(uint8_t, nout);uint64_t iterations = (1 <<15 );
@@ -131,7 +131,17 @@ static void *threaded_qcrypto_pbkdf2_count_iters(void *data) delta_ms = end_ms - start_ms; -if (delta_ms ==0 ) {/* sanity check */ +/* +* For very small 'iterations' values, CPU (or crypto +* accelerator) might be fast enough that the scheduler +* hasn't incremented getrusage() data, or incremented +* it by a very small amount, resulting in delta_ms == 0. +* Once we've scaled 'iterations' x10, 5 times, we really +* should be seeing delta_ms != 0, so sanity check at +* that point. +*/ +if (scaled >5 && + delta_ms ==0 ) {/* sanity check */ error_setg (errp,"Unable to get accurate CPU usage" ); goto cleanup; }else if (delta_ms >500 ) {
@@ -141,6 +151,7 @@ static void *threaded_qcrypto_pbkdf2_count_iters(void *data) }else { iterations = (iterations *1000 / delta_ms); } + scaled++; } iterations = iterations *1000 / delta_ms;
Signature · 1 line
2.48.1
[PULL 4/9] hw/s390x: Fix crash that occurs when inspecting older versioned machines types
In reply to Thomas Huthqemu-system-s390x currently crashes when trying to inspect older machines types, for example:
$ echo '{ "execute": "qmp_capabilities" }
{ "execute": "qom-list-properties","arguments":
{ "typename": "s390-ccw-virtio-3.0-machine"}}' \
| ./qemu-system-s390x -qmp stdio -no-shutdown
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 2, "major": 9},
"package": "v9.2.0-1071-g81e97df3e7"}, "capabilities": ["oob"]}}
{"return": {}}
**
Bail out! ERROR:../target/s390x/cpu_models.c:832:s390_set_qemu_cpu_model:
assertion failed: (QTAILQ_EMPTY_RCU(&cpus_queue))
Aborted (core dumped)The problem is that the versioned s390-ccw-virtio machine types use instance_init() to set global state that should be initialized before the CPUs get instantiated. But instance_init() is not called only for the machine that is finally used, it is also called for temporary instances of objects that are e.g. just created for introspection. That means that those instance_init() functions can also be called while a machine (and its CPUs) is already created, which triggers the assertion in cpu_models.c.
So we must not use instance_init() for setting global state, but use the machine->init() function instead, which is really only called once when the machine comes to life.
Message-ID: <[email protected]>
--- hw/s390x/s390-virtio-ccw.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
hw/s390x/s390-virtio-ccw.c +7 -8
@@ -782,7 +782,6 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) s390mc->hpage_1m_allowed = true; s390mc->max_threads =1 ; - mc->init = ccw_init; mc->reset = s390_machine_reset; mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ;
@@ -852,6 +851,12 @@ static const TypeInfo ccw_machine_info = { };#define DEFINE_CCW_MACHINE_IMPL (latest, ...) \ + static void MACHINE_VER_SYM(mach_init, ccw, __VA_ARGS__)(MachineState *mach) \ + { \ + current_mc = S390_CCW_MACHINE_CLASS(MACHINE_GET_CLASS(mach)); \ + MACHINE_VER_SYM(instance_options, ccw, __VA_ARGS__)(mach); \ + ccw_init(mach); \ + } \ static void MACHINE_VER_SYM(class_init, ccw, __VA_ARGS__)( \ ObjectClass *oc, \ void *data) \
@@ -859,24 +864,18 @@ static const TypeInfo ccw_machine_info = {MachineClass *mc =MACHINE_CLASS (oc); \MACHINE_VER_SYM (class_options, ccw, __VA_ARGS__)(mc); \ mc->desc = "Virtual s390x machine (version " MACHINE_VER_STR(__VA_ARGS__) ")"; \ + mc->init =MACHINE_VER_SYM (mach_init, ccw, __VA_ARGS__); \MACHINE_VER_DEPRECATION (__VA_ARGS__); \if (latest) { \ mc->alias ="s390-ccw-virtio" ; \ mc->is_default = true; \ } \ } \ -static void MACHINE_VER_SYM (instance_init ,ccw ,__VA_ARGS__ )(Object *obj) \ - { \ -MachineState *machine =MACHINE (obj); \ - current_mc =S390_CCW_MACHINE_CLASS (MACHINE_GET_CLASS (machine)); \ -MACHINE_VER_SYM (instance_options, ccw, __VA_ARGS__)(machine); \ - } \static const TypeInfo MACHINE_VER_SYM (info ,ccw ,__VA_ARGS__ ) = \ { \ .name =MACHINE_VER_TYPE_NAME ("s390-ccw-virtio" , __VA_ARGS__), \ .parent =TYPE_S390_CCW_MACHINE , \ .class_init =MACHINE_VER_SYM (class_init, ccw, __VA_ARGS__), \ - .instance_init =MACHINE_VER_SYM (instance_init, ccw, __VA_ARGS__), \ }; \ static void MACHINE_VER_SYM(register, ccw, __VA_ARGS__)(void) \ { \
Signature · 1 line
2.48.1
[PULL 2/9] MAINTAINERS: Remove myself as Avocado Framework reviewer
In reply to Thomas HuthFrom: Philippe Mathieu-Daudé <[email protected]>
While I was very enthusiastic when Avocado was presented to the QEMU community and pushed forward to have it integrated, time passed and I lost interest. Be honest, remove my R: tag to not give fake expectation I'd review patches related to Avocado anymore.
Message-ID: <[email protected]>
--- MAINTAINERS | 1 - 1 file changed, 1 deletion(-)
MAINTAINERS +0 -1
@@ -4207,7 +4207,6 @@ F: tests/tcg/Makefile.target Integration Testing with the Avocado framework W: https://trello.com/b/6Qi1pxVn/avocado-qemu R: Cleber Rosa <[email protected]> -R: Philippe Mathieu-Daudé <[email protected]> S: Odd Fixes F: tests/avocado/
Signature · 1 line
2.48.1
[PULL 5/9] pc-bios/s390-ccw/virtio: Add a function to reset a virtio device
In reply to Thomas HuthTo be able to properly silence a virtio device after using it, we need a global function to reset the device.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/virtio.h | 1 + pc-bios/s390-ccw/virtio.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-)
pc-bios/s390-ccw/virtio.h +1 -0
@@ -274,6 +274,7 @@ void vring_send_buf(VRing *vr, void *p, int len, int flags);int vr_poll (VRing *vr);int vring_wait_reply (void );int virtio_run (VDev *vdev,int vqid,VirtioCmd *cmd); +int virtio_reset (VDev *vdev);int virtio_setup_ccw (VDev *vdev);int virtio_net_init (void *mac_addr);
pc-bios/s390-ccw/virtio.c +6 -1
@@ -217,6 +217,11 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd)return 0 ; } +int virtio_reset (VDev *vdev) +{ +return run_ccw (vdev,CCW_CMD_VDEV_RESET ,NULL ,0 , false); +} +int virtio_setup_ccw (VDev *vdev) {int i, cfg_size =0 ;
@@ -235,7 +240,7 @@ int virtio_setup_ccw(VDev *vdev) vdev->config.blk.blk_size =0 ;/* mark "illegal" - setup started... */ vdev->guessed_disk_nature =VIRTIO_GDN_NONE ; -run_ccw (vdev,CCW_CMD_VDEV_RESET ,NULL ,0 , false); +virtio_reset (vdev); status =VIRTIO_CONFIG_S_ACKNOWLEDGE ;if (run_ccw (vdev,CCW_CMD_WRITE_STATUS , &status,sizeof (status), false)) {
Signature · 1 line
2.48.1
[PULL 6/9] pc-bios/s390-ccw: Fix boot problem with virtio-net devices
In reply to Thomas HuthWhen we are trying to boot from virtio-net devices, the s390-ccw bios currently leaves the virtio-net device enabled after using it. That means that the receiving virt queues will continue to happily write incoming network packets into memory. This can corrupt data of the following boot process. For example, if you set up a second guest on a virtual network and create a lot of broadcast traffic there, e.g. with:
ping -i 0.02 -s 1400 -b 192.168.1.255
and then you try to boot a guest with two boot devices, a network device first (which should not be bootable) and e.g. a bootable SCSI CD second, then this guest will fail to load the kernel from the CD image:
$ qemu-system-s390x -m 2G -nographic -device virtio-scsi-ccw \
-netdev tap,id=net0 -device virtio-net-ccw,netdev=net0,bootindex=1 \
-drive if=none,file=test.iso,format=raw,id=cd1 \
-device scsi-cd,drive=cd1,bootindex=2
LOADPARM=[ ] Network boot device detected
Network boot starting...
Using MAC address: 52:54:00:12:34:56
Requesting information via DHCP: done
Using IPv4 address: 192.168.1.76
Using TFTP server: 192.168.1.1
Trying pxelinux.cfg files...
TFTP error: ICMP ERROR "port unreachable"
Receiving data: 0 KBytes
Repeating TFTP read request...
TFTP error: ICMP ERROR "port unreachable"
Failed to load OS from network.
Failed to IPL from this network!
LOADPARM=[ ]
Using virtio-scsi.
! virtio-scsi:setup:inquiry: response VS RESP=ff !
ERROR: No suitable device for IPL. Halting...
We really have to shut up the virtio-net devices after we're not using it anymore. The easiest way to do this is to simply reset the device, so let's do that now.
Message-ID: <[email protected]>
--- pc-bios/s390-ccw/virtio.h | 1 + pc-bios/s390-ccw/netmain.c | 33 +++++++++++++++++++++++---------- pc-bios/s390-ccw/virtio-net.c | 5 +++++ 3 files changed, 29 insertions(+), 10 deletions(-)
pc-bios/s390-ccw/virtio.h +1 -0
@@ -278,5 +278,6 @@ int virtio_reset(VDev *vdev);int virtio_setup_ccw (VDev *vdev);int virtio_net_init (void *mac_addr); +void virtio_net_deinit (void );#endif /* VIRTIO_H */
pc-bios/s390-ccw/netmain.c +23 -10
@@ -153,19 +153,10 @@ static int tftp_load(filename_ip_t *fnip, void *buffer, int len)return rc; } -static int net_init (filename_ip_t *fn_ip) +static int net_init_ip (filename_ip_t *fn_ip) {int rc; -memset (fn_ip,0 ,sizeof (filename_ip_t)); - - rc =virtio_net_init (mac); -if (rc <0 ) { -puts ("Could not initialize network device" ); -return -101 ; - } - fn_ip->fd = rc; -printf (" Using MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n" , mac[0 ], mac[1 ], mac[2 ], mac[3 ], mac[4 ], mac[5 ]);
@@ -221,11 +212,33 @@ static int net_init(filename_ip_t *fn_ip)return rc; } +static int net_init (filename_ip_t *fn_ip) +{ +int rc; + +memset (fn_ip,0 ,sizeof (filename_ip_t)); + + rc =virtio_net_init (mac); +if (rc <0 ) { +puts ("Could not initialize network device" ); +return -101 ; + } + fn_ip->fd = rc; + + rc =net_init_ip (fn_ip); +if (rc <0 ) { +virtio_net_deinit (); + } + +return rc; +} +static void net_release (filename_ip_t *fn_ip) {if (fn_ip->ip_version ==4 ) {dhcp_send_release (fn_ip->fd); } +virtio_net_deinit (); }/**
pc-bios/s390-ccw/virtio-net.c +5 -0
@@ -140,3 +140,8 @@ int recv(int fd, void *buf, int maxlen, int flags)return len; } + +void virtio_net_deinit (void ) +{ +virtio_reset (virtio_get_device ()); +}
Signature · 1 line
2.48.1
[PULL 9/9] pc-bios: Update the s390 bios images with the recent changes
In reply to Thomas HuthFix the problem with the non-quiesced virtio-net device and make sure to abort the boot process if the user specified a wrong loadparm parameter.
--- pc-bios/s390-ccw.img | Bin 79608 -> 96000 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
Signature · 1 line
2.48.1
[PULL 1/9] tests/functional: Convert the kvm_xen_guest avocado test
In reply to Thomas HuthUse 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.
Message-ID: <[email protected]>
---
MAINTAINERS | 2 +-
tests/functional/meson.build | 2 +
.../test_x86_64_kvm_xen.py} | 83 +++++++++++--------
3 files changed, 52 insertions(+), 35 deletions(-)
rename tests/{avocado/kvm_xen_guest.py => functional/test_x86_64_kvm_xen.py} (64%)
mode change 100644 => 100755MAINTAINERS +1 -1
@@ -489,7 +489,7 @@ S: Supported F: include/system/kvm_xen.h F: target/i386/kvm/xen* F: hw/i386/kvm/xen* -F: tests/avocado/kvm_xen_guest.py +F: tests/functional/test_x86_64_kvm_xen.py Guest CPU Cores (other accelerators) ------------------------------------
tests/functional/meson.build +2 -0
@@ -44,6 +44,7 @@ test_timeouts = { 'riscv64_tuxrun' : 120, 's390x_ccw_virtio' : 420, 'sh4_tuxrun' : 240, + 'x86_64_kvm_xen' : 180, } tests_generic_system = [
@@ -244,6 +245,7 @@ tests_x86_64_system_thorough = [ 'netdev_ethtool', 'virtio_gpu', 'x86_64_hotplug_cpu', + 'x86_64_kvm_xen', 'x86_64_tuxrun', ]
tests/functional/test_x86_64_kvm_xen.py renamed from tests/avocado/kvm_xen_guest.py +49 -34
152 lines not on this page · raw message
Signature · 1 line
2.48.1
Hi Thomas,
Please take a look at these CI failures:
https://gitlab.com/qemu-project/qemu/-/jobs/8913471007
https://gitlab.com/qemu-project/qemu/-/jobs/8913471508
https://gitlab.com/qemu-project/qemu/-/jobs/8913472011
Thanks,
Stefan
Quoted 5 lines · Stefan Hajnoczi
Hi Thomas,
Please take a look at these CI failures:
https://gitlab.com/qemu-project/qemu/-/jobs/8913471007
https://gitlab.com/qemu-project/qemu/-/jobs/8913471508
https://gitlab.com/qemu-project/qemu/-/jobs/8913472011
Ah, thanks, nice catch, unlike the gitlab shared runners, these runners obviously have an older version of KVM enabled and thus ran into an error path that should skip the test - I need to replace cancel() with skipTest() here. I'll fix it up and send a v2...
Thomas