Commit Graph

2106 Commits

Author SHA1 Message Date
Philippe Mathieu-Daudé
bfa0801e91 buildsys: Remove support for MIPS hosts
MIPS host support is deprecated since commit 269ffaabc8
("buildsys: Remove support for 32-bit MIPS hosts"). Time
to remove.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20260511135312.38705-3-philmd@linaro.org>
2026-05-21 08:20:58 +02:00
Marc-André Lureau
4cb2250c58 char: error out if given unhandled size options
This is a small help, because in fact all combined chardev
options are accepted by qemu_chardev_opts[]. But given that a user may
legitimately want to use the size options with a VC backend, we can
report an error when we know the backend doesn't support it.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:30 +04:00
Markus Armbruster
c6ea6ce1e6 qemu-print: Document qemu_fprintf(), qemu_vfprintf() failure
These functions fail when @stream is null and the current monitor
isn't HMP.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20260114124713.3308719-4-armbru@redhat.com>
[Comments rewritten in review]
2026-05-05 12:52:26 +02:00
Markus Armbruster
0da15e16c3 error: Restore error_printf()'s function comment
Lost in commit 397d30e940 (qemu-error: remove dependency of stubs on
monitor) many moons ago.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20260114124713.3308719-3-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
[Trivial conflict with commit a582a5784e (monitor: move
error_vprintf back to error-report.c) resolved]
2026-05-05 12:52:14 +02:00
Markus Armbruster
5237737439 error: Fix "to current monitor if we have one" comments
A number of print functions are documented to print to "current
monitor if we have one, else stderr".  Wrong, they print to the
current monitor only when it's HMP.  This is the case since commit
4ad417baa4 (error: Print error_report() to stderr if using qmp).

Fix the comments to say "current HMP monitor if we have one".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20260114124713.3308719-2-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
[Commit a582a5784e (monitor: move error_vprintf back to
error-report.c) lost a comment this commit fixes, restore it]
2026-05-05 12:50:35 +02:00
Stefan Hajnoczi
a02bebe15c Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging
Pull request

- Jaehoon Kim's AioContext polling CPU efficiency optimizations

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmnyTCEACgkQnKSrs4Gr
# c8jB2wf7BXoNAW73Qwd31vZO2/0ZSDCQI781aeKrO/zl0k6nBgWKYYxjel3ezSJs
# qfwLnu7RpLFp89i6s9fO3PgyPdq81YJBHqeu/AsqXFcNNkkLPMavzcGCr7YeY3xP
# VIprpNBBYI/v6AnuFeEMp04FtLrcFO82ZIvTMpq7FsssytdmmqcleqQRTlecIpbK
# 33z6aYKfPO/0VZRfpj5/NosQGaqU4y9ZgygPVoOvUlmPZgB0TpEReewtphqv7BHa
# LCJD03QBxJyTtsipD0ngcig+LeNzDsdla8fR7LD1hb/iqftxod6anaPIXWYvTu1v
# xC1fWyWZ+r1Nkv249Uzi+dEc4JkMmg==
# =rhl4
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 29 Apr 2026 14:21:21 EDT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [ultimate]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [ultimate]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* tag 'block-pull-request' of https://gitlab.com/stefanha/qemu:
  qapi/iothread: introduce poll-weight parameter for aio-poll
  aio-poll: refine iothread polling using weighted handler intervals
  aio-poll: avoid unnecessary polling time computation

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-04-30 10:30:22 -04:00
Jaehoon Kim
9fea80ddf0 qapi/iothread: introduce poll-weight parameter for aio-poll
Introduce a configurable poll-weight parameter for adaptive polling
in IOThread. This parameter replaces the hardcoded POLL_WEIGHT_SHIFT
constant, allowing runtime control over how much the most recent
event interval affects the next polling duration calculation.

The poll-weight parameter uses a shift value where larger values
decrease the weight of the current interval, enabling more gradual
adjustments. When set to 0, a default value of 3 is used (meaning
the current interval contributes approximately 1/8 to the weighted
average).

This patch also removes the hardcoded default value checks from
adjust_polling_time(). Instead, poll-grow, poll-shrink, and
poll-weight now use default values initialized in iothread.c
during IOThread creation.

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20260423195918.661299-4-jhkim@linux.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-04-29 11:31:44 -04:00
Jaehoon Kim
9563d0b5e2 aio-poll: refine iothread polling using weighted handler intervals
Improve adaptive polling by updating each AioHandler's poll.ns
every loop iteration using weighted averages. This reduces CPU
consumption while minimizing performance impact.

Background:
Starting from QEMU 10.0, poll.ns was introduced per event handler
to mitigate excessive fluctuations in IOThread polling times
observed in earlier versions (QEMU 9.x). However, the current
design has limitations:

1. poll.ns is updated only when an event occurs, making it
   difficult to treat block_ns as a reliable event interval.
2. The IOThread's next polling time is determined by the maximum
   poll.ns among all AioHandlers, meaning idle AioHandlers with
   high poll.ns can have an outsized impact on polling duration.
3. For io_uring, idle AioHandlers are cleared after
   POLL_IDLE_INTERVAL_NS (7s), but for ppoll/epoll there is no
   such mechanism, leading to increased CPU consumption from idle
   nodes.

Implementation:
This patch treats block_ns as an event interval and updates each
AioHandler's poll.ns in every loop iteration:

- Active handlers (with events): poll.ns is updated using a
  weighted average of the current block_ns and previous poll.ns,
  smoothing out adjustments and preventing excessive fluctuations.
- Inactive handlers (no events): poll.ns accumulates block_ns
  without weighting, allowing rapid isolation of idle nodes. When
  poll.ns exceeds poll_max_ns, it resets to 0, preventing
  sporadically active handlers from unnecessarily prolonging
  iothread polling.
- The iothread polling duration is set based on the largest poll.ns
  among active handlers. The shrink divider defaults to 2, matching
  the grow rate, to reduce frequent poll_ns resets for slow devices.

The implementation renames poll_idle_timeout to last_dispatch_timestamp
for use as an active handler identifier.

Testing:
POLL_WEIGHT_SHIFT=3 (12.5% weight) was selected based on testing
comparing baseline vs weight=2/3 across various workloads:
Performance results (RHEL 10.1 + QEMU 10.0.0, FCP/FICON, 1-8 iothreads,
numjobs 1/4/8 averaged):
                    | poll-weight=2      | poll-weight=3
--------------------|--------------------|-----------------
Throughput avg      | -2.4% (all tests)  | -2.2% (all tests)
CPU consumption avg | -10.9% (all tests) | -9.4% (all tests)

Both configurations achieve ~10% CPU reduction with minimal throughput
impact (~2%). Weight=3 is chosen as default for slightly better
throughput while maintaining substantial CPU savings.

Additional validation testing on s390x SSD with fio (bs=8k, iodepth=8,
numjobs=1) shows how poll_weight affects polling time (poll.ns)
behavior:

RandRead workload:
+-------------+-----------+-----------+-------------+-------------+
| poll_weight | #samples  | Mean (ns) | 50th % (ns) | 90th % (ns) |
+-------------+-----------+-----------+-------------+-------------+
| 1           | 4.79M     |  8,034    |  5,116      | 20,509      |
| 2           | 5.01M     | 12,584    | 11,078      | 24,693      |
| 3           | 5.01M     | 15,647    | 14,863      | 28,695      |
| 4           | 5.12M     | 16,430    | 15,556      | 30,848      |
| 5           | 5.14M     | 16,461    | 15,306      | 32,123      |
+-------------+-----------+-----------+-------------+-------------+
RandWrite workload:
+-------------+-----------+-----------+-------------+-------------+
| poll_weight | #samples  | Mean (ns) | 50th % (ns) | 90th % (ns) |
+-------------+-----------+-----------+-------------+-------------+
| 1           | 6.37M     |  2,049    |  1,262      |  4,301      |
| 2           | 7.46M     |  4,118    |  3,226      |  7,476      |
| 3           | 7.97M     |  7,034    |  5,984      | 11,645      |
| 4           | 7.96M     | 12,789    | 11,362      | 20,040      |
| 5           | 7.82M     | 22,992    | 20,644      | 32,768      |
+-------------+-----------+-----------+-------------+-------------+

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Message-ID: <20260423195918.661299-3-jhkim@linux.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-04-29 11:31:44 -04:00
Jaehoon Kim
ed21d9d65c aio-poll: avoid unnecessary polling time computation
Nodes are no longer added to poll_aio_handlers when adaptive polling is
disabled, preventing unnecessary try_poll_mode() calls. This avoids
iterating over all nodes to compute max_ns unnecessarily when polling
is disabled.

Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20260423195918.661299-2-jhkim@linux.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-04-29 11:31:44 -04:00
Emmanuel Blot
1d2276997e util: export CRC32[C] lookup tables
These are needed for the xlrbr CRC32 instructions which pre-XOR the data
into the CRC state before the instruction is executed, making the zlib
crc32 and QEMU crc32c implementations inappropriate.

https://github.com/riscv/riscv-bitmanip/releases/download/v0.93/bitmanip-0.93.pdf

Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260320134254.217123-2-james.wainwright@lowrisc.org>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2026-04-29 11:41:00 +10:00
Daniel P. Berrangé
b8c2426157 util: fix use of pthread_get_name_np on OpenBSD
The pthread_get_name_np function is present on FreeBSD and OpenBSD
and has 'void' return not 'int'. We didn't notice this build problem
on FreeBSD since it also has pthread_getname_np which does return
int like Linux and we use the latter preferentially.

Fixes: 215235d365
Closes: https://gitlab.com/qemu-project/qemu/-/work_items/3399
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260417120531.2215549-1-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2026-04-27 08:39:44 +02:00
Paolo Bonzini
55e0216466 thread-win32: replace CRITICAL_SECTION with SRWLOCK
SRWLOCK is a much cheaper primitive than CRITICAL_SECTION, which
basically exists only as a legacy API.  The SRWLOCK is a single word
in memory and it is cheaper to just initialize it always.

Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-23 12:27:27 +02:00
Kostiantyn Kostiuk
d14d8ea23b util: Remove unused sys/param.h
We dropped the use of PATH_MAX in commit f3a8bdc1d5 (which
basically completely rewrote the path handling).
Now we don't need any sys/param.h defines.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Link: https://lore.kernel.org/r/20260327134401.270186-14-kkostiuk@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-23 12:27:27 +02:00
Kostiantyn Kostiuk
8cb2131cf4 util: Remove unused dirent.h
This one is OK to drop, because the rewrite of path.c in
commit f3a8bdc1d5 removed the uses of the dirent.h functions.

Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Link: https://lore.kernel.org/r/20260327134401.270186-13-kkostiuk@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-23 12:27:27 +02:00
Marc-André Lureau
f42c7a79db util: move datadir.c from system/
The datadir module provides general-purpose data file lookup
utilities that are not specific to system emulation. Move it
to util/ so it can be reused more broadly.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-04-22 12:51:51 +04:00
Bernhard Beschow
f1b1db98cc util/cutils: Fix heap corruption under Windows
Under Windows, QEMU would only sporadically start successfully. In the
G_OS_WIN32 case, get_relocated_path() first determines a cursor
to the end of the "result" string and then increases its size with
g_string_set_size(). Since g_string_set_size() may reallocate, the
cursor may become dangling. Windows may detect this and crash the QEMU
process with the following message:

  HEAP: Free Heap block 000000000499B640 modified at 000000000499B684 after it was freed

Furthermore, QEMU crashes spontaneously, even long after the guest has
booted. For example, it presumably crashes due to the guest setting a
new cursor icon which may be a result of the heap corruption.

Fix this by determining the cursor on the resized string.

Fixes: cf60ccc330 ("cutils: Introduce bundle mechanism")
Cc: qemu-stable@nongnu.org
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Message-id: 20260414114033.2360-1-shentey@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-04-14 15:52:21 +01:00
Peter Maydell
6d3e9dddef Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
trivial patches for 2026-04-08

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEZKoqtTHVaQM2a/75gqpKJDselHgFAmnWM84ACgkQgqpKJDse
# lHgJMxAAuz4rJQh51cTA1vKa/Pte//BZ4ro9dVnCi2ogCVjmy/ZaD6r2B8ZJtpHo
# RMXbTrswGF1Hs6J5HxztcMHNHE9fO+2CGjhgjujCsvs72Msdp5j6TjQ61DzIG3UL
# jz3g7fGPxabOyiJcMi61QMIMwcOQlS4WSZhvcRtxixc6KpY6fx5uCXpvEKUIzumQ
# WSmTkHVah4C8D05jUWmD5jF2krAUvf0XjsGDIYidjXRwsnORnBSZdHGoukQ8rGl9
# 6OjvuWT9UZIM7nXv76lPkk3APVFL4q9FMNoc3GxcTzHMWyvYknOM5KI4tDFhncqh
# 0gvie5OalWCxrzq8inGy3o+3v0/ggsOG/mjyN9tR5nas6qsqzya6PHaPoXbLn/uq
# ibsV+LOtjo65w0uJUV1LRn1TwG6bBQBKO1pdYmx3SouaY8dF9UsNTsvhiyFOdBge
# 7ZnjzoMmD33USkSWbAL5icGHSAShsIvJkQfWd8lrsx46dzuePC/DwGp8S384sNA+
# j0Ecqd/ar0cBfGi9mToKHufrGZS4S4R4xdVU41k2eA5AmhaEQ4D3BkWaZC7ocx59
# Q5s2N/XMDK6CX7OEkIAEy6Oi8DyO8vl/hozEI/USpc6OqUM/eX74WH7dR2fKaDZa
# D+36iSHOKQK2wgPVHaeBrfjobgFXY+/MGFGPMlvk9Z4q4zQNZ2Y=
# =XP94
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Apr  8 11:54:06 2026 BST
# gpg:                using RSA key 64AA2AB531D56903366BFEF982AA4A243B1E9478
# gpg: Good signature from "Michael Tokarev <mjt@debian.org>" [full]
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>" [full]
# gpg:                 aka "Michael Tokarev <mjt@tls.msk.ru>" [full]
# Primary key fingerprint: 9D8B E14E 3F2A 9DD7 9199  28F1 61AD 3D98 ECDF 2C8E
#      Subkey fingerprint: 64AA 2AB5 31D5 6903 366B  FEF9 82AA 4A24 3B1E 9478

* tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu:
  util: fix missing aio_wait sym in qemu guest agent only build
  Allow building qemu tools on 32-bit hosts
  util/meson.build: do not add cpuinfo-$arch to util_ss for 32bit CPUs

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-04-08 13:34:10 +01:00
Nguyen Dinh Phi
4e4832dd72 util/readline: Fix out-of-bounds access in readline_insert_char().
Currently, the readline_insert_char() function is guarded by the cursor
position (cmd_buf_index) rather than the actual buffer fill level(cmd_buf_size).
The current check is:
	if (rs->cmd_buf_index < READLINE_CMD_BUF_SIZE)

This logic is flawed because if the command buffer is full and a user moves the
cursor backward (e.g. by sending left arrow key), cmd_buf_index can be
decreased without descreasing of buffer size.
This allow subsequent insertions to increase cmd_buf_size past its maximum
limit of rs->cmd_buf.

Because in the ReadLineState struct, cmd_buf[READLINE_CMD_BUF_SIZE + 1] is
immediately followed by the cmd_buf_index integer, once the buffer size is
sufficiently inflated, the memmove() operation inside readline_insert_char()
can write past the end of cmd_buf[] and overwrites cmd_buf_index itself.

The subsequent line:
	rs->cmd_buf[rs->cmd_buf_index] = ch;

then writes the input character to an address determined by the now-corrupted
index.

By providing a specifically crafted input sequence via HMP, this flaw can be
used to redirect the write operation to overwrite any field within the
ReadLineState structure, which can lead to unpredictable behavior or
application crashes.

Fix this by adding the guard to check for buffer fullness.

Cc: qemu-stable@nongnu.org
Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
Message-id: 20260406050454.284873-2-phind.uet@gmail.com
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-04-08 13:33:25 +01:00
Daniel P. Berrangé
17fbf3e18c util: fix missing aio_wait sym in qemu guest agent only build
Configure QEMU with

 --disable-system --disable-user --disable-tools --enable-guest-agent

and the build with fail with

  FAILED: [code=1] qga/qemu-ga
  ld: libqemuutil.a.p/qapi_qmp-dispatch.c.o: in function `do_qmp_dispatch_bh':
  qapi/qmp-dispatch.c:140:(.text+0x5c): undefined reference to `aio_wait_kick'

This aio_kick() usage was recently introduced in qmp-dispatch.c
without updating the build logic.

Fixes commit fc1a2ec7da
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Cc: qemu-stable@nongnu.org
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-04-08 13:48:50 +03:00
Michael Tokarev
276b060a74 util/meson.build: do not add cpuinfo-$arch to util_ss for 32bit CPUs
qemu dropped support for 32bit CPUs recently, so this change is an
additional clean-up on top.  But in theory it will allow building
qemu-guest-agent on a 32bit system.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-04-03 18:31:08 +03:00
Paolo Bonzini
3060e9b93b treewide: replace qemu_hw_version() with QEMU_HW_VERSION
The version is never set on 2.5+ machine types, so qemu_hw_version() and
qemu_set_hw_version() are not needed anymore.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-03-25 18:22:27 +01:00
Michael Tokarev
7cc61f922f rename CONFIG_EPOLL_CREATE1 to CONFIG_EPOLL, and stop checking for epoll in meson.build
Since CONFIG_EPOLL is now unused, it's okay to
perform this rename, to make it less ugly.

Since epoll is linux-specific and is always present on linux,
define CONFIG_EPOLL to 1 on linux, without compile-time test.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2026-03-16 13:50:18 +03:00
Peter Maydell
1fd5ff9d76 Merge tag 'for-upstream' of https://gitlab.com/kmwolf/qemu into staging
Block layer patches

- export/fuse: Use coroutines and multi-threading
- curl: Add force-range option
- nfs: add support for libnfs v6

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCgAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmmwOl4RHGt3b2xmQHJl
# ZGhhdC5jb20ACgkQfwmycsiPL9b1dBAAikQXP9Pf9QMa2Z+DxlsZkTZW7y0mDKZW
# QKcHLPmeKvBFI/jPBM4Kh3X3cxXP74q9n4qHW/mCwttYvEK/ZT47MmlypAawFoVL
# NIp9LGDUi/ohh2eAM/v21kdjWClBXnX9T2DPIM8QYn4RcpSrcKVoCs8f5wlTg52/
# hpJdvksF53P6dUcGSVv6MmQGnHl4Y22+mWXtn6KMDYqm7CaaqWEfcANMEMHdxaxZ
# zCEbEFuiEsX7EiG+AooVkqZJoe17roBeYq5td91qZy1by5pBo8W86Q26303n+DII
# 45qtEhhxIaKxHtxop/c84khImNdETUZI1rObXDuNqVPX6YrqPixBDHZ8QxO6+t0z
# MfRz6AcEIJ0ImNagnAy7wG80gFhoInuy7G0pGSP4bkIV3A523sqrjkbJmbVXConC
# 98PoNoAIzG7NnxtFdu5JiaTHvCe9ZgH6P5GpgBZEGw0eGZBZuhsqsR7XqGWJRC/A
# XLGCG0UKKJvsMVWciHAseQuF/dme04EqpW27hZnh4IaqTQhEAYlh6gVJCI5h0HRj
# iRGBA9KsInO1DhI9roIxc1CFb6N6PmLCLxbzcizaPv0gtm3ADWXKe3k1ZbwkCs99
# erHEW8hWnNJb3cVheLcxr6wUsX2cd9sxwQ3+17Ou04UUvYPwojsLmr5JLAFHdvRN
# 3RyhPEyvyb0=
# =VJn6
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 10 15:35:58 2026 GMT
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "kwolf@redhat.com"
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* tag 'for-upstream' of https://gitlab.com/kmwolf/qemu: (28 commits)
  block/curl: add support for S3 presigned URLs
  qapi: block: Refactor HTTP(s) common arguments
  block/nfs: add support for libnfs v6
  iotests/308: Add multi-threading sanity test
  qapi/block-export: Document FUSE's multi-threading
  fuse: Implement multi-threading
  fuse: Make shared export state atomic
  iotests/307: Test multi-thread export interface
  block/export: Add multi-threading interface
  fuse: Process requests in coroutines
  fuse: Reduce max read size
  fuse: Manually process requests (without libfuse)
  fuse: Drop permission changes in fuse_do_truncate
  block: Move qemu_fcntl_addfl() into osdep.c
  fuse: Explicitly handle non-grow post-EOF accesses
  iotests/308: Use conv=notrunc to test growability
  fuse: fuse_{read,write}: Rename length to blk_len
  fuse: Add halted flag
  fuse: Introduce fuse_{inc,dec}_in_flight()
  fuse: Introduce fuse_{at,de}tach_handlers()
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-03-10 16:29:24 +00:00
Hanna Czenczek
247fa896d5 block: Move qemu_fcntl_addfl() into osdep.c
Move file-posix's helper to add a flag (or a set of flags) to an FD's
existing set of flags into osdep.c for other places to use.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
Message-ID: <20260309150856.26800-16-hreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2026-03-10 12:11:43 +01:00
Peter Maydell
be7f1c297c Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* hvf/x86: compilation fixes
* whpx: fixes
* xen-block: fix possible NULL pointer dereference
* coroutine-lock: fix thinko

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCgAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmmugQwUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroOOpQf/euE88TGF71S3kW4ckqCN4hLlvpl8
# 7wHjj83ggzufJikx5UI1lw31UuqyZYDX5ICQnvNeVEvBqCpi8oo9SJMBIwXJxn45
# 3oolIy+TJ7/k+QjZ1kMLPubnbH7p5h/iix+IkU01gFS0F0S12LgiJcLpBsSkKZHK
# 5AK53dKBAEikPP+IIT8Y4RrzNOZrydZzaXAtU4eCi3YVxf7/Ld1w9nRGvfG07Zd6
# Y0TptxjfMzbhxLuKetaHrAEI8EYYsmLAE3uJaDMSZ6heCXtfwQjkOaFjaqE/OYOK
# NhtIFArkq+tneI3sqDEoIdMngkL6SEowi1uDAOc5vKmtb2JcWzNo9PsXJw==
# =3X24
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  9 08:13:00 2026 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu:
  whpx: i386: remove SIPI trapping
  whpx: arm64: enable enlightenments if asked for
  whpx: make Hyper-V enlightenments configurable
  whpx: i386: enable some more enlightenments
  target/i386: emulate: LA57 fix
  whpx: i386: do not enable nested virt when kernel-irqchip=off
  hvf: arm: unbreak the x86 build
  target/i386/hvf/hvf.c: fix compilation
  qemu-coroutine-lock: fix has_waiters()
  xen-block: remove NULL pointer dereference

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-03-10 09:32:17 +00:00
Paolo Bonzini
4878c3a43a qemu-coroutine-lock: fix has_waiters()
has_waiters() is testing a reversed condition.  The logic is that
has_waiters() must return true if a qemu_co_mutex_lock_slowpath()
happened:

  qemu_co_mutex_unlock            qemu_co_mutex_lock_slowpath
  -------------------------       -------------------------------
  set handoff                     push to from_push
  memory barrier                  memory barrier
  check has_waiters()             check handoff

which requires it to return true if from_push (or to_pop from a previous
call) are *not* empty.

This was unlikely to cause trouble because it can only happen when the
same CoMutex is used across multiple threads, but it is nevertheless
completely wrong.  The bug would show up as either a NULL-pointer
dereference inside qemu_co_mutex_lock_slowpath(), or a missed wait in
qemu_co_mutex_unlock().

Reported-by: Siteshwar Vashisht <svashisht@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-03-09 09:03:42 +01:00
Bernhard Beschow
6cbfd6008d util/fifo8: Make all read-only methods const-correct
Allows these methods to be used in const contexts, i.e. where the parent
of the fifo itself is const. This is in particular useful for Rust code.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260305220911.131508-5-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2026-03-08 23:08:42 +01:00
Jon Kohler
ca61f91ef9 util/oslib-posix: increase memprealloc thread count to 32
Increase MAX_MEM_PREALLOC_THREAD_COUNT from 16 to 32. This was last
touched in 2017 [1] and, since then, physical machine sizes and VMs
therein have continue to get even bigger, both on average and on the
extremes.

For very large VMs, using 16 threads to preallocate memory can be a
non-trivial bottleneck during VM start-up and migration. Increasing
this limit to 32 threads reduces the time taken for these operations.

Test results from quad socket Intel 8490H (4x 60 cores) show a fairly
linear gain of 50% with the 2x thread count increase.

---------------------------------------------
Idle Guest w/ 2M HugePages   | Start-up time
---------------------------------------------
240 vCPU, 7.5TB (16 threads) | 2m41.955s
---------------------------------------------
240 vCPU, 7.5TB (32 threads) | 1m19.404s
---------------------------------------------

Note: Going above 32 threads appears to have diminishing returns at
the point where the memory bandwidth and context switching costs
appear to be a limiting factor to linear scaling. For posterity, on
the same system as above:
- 32 threads: 1m19s
- 48 threads: 1m4s
- 64 threads: 59s
- 240 threads: 50s

Additional thread counts also get less interesting as the amount of
memory is to be preallocated is smaller. Putting that all together,
32 threads appears to be a sane number with a solid speedup on fairly
modern hardware. To go faster, we'd either need to improve the hardware
(CPU/memory) itself or improve clear_pages_*() on the kernel side to
be more efficient.

[1] 1e356fc14b ("mem-prealloc: reduce large guest start-up and migration time.")

Signed-off-by: Jon Kohler <jon@nutanix.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
13bedeb212 util: fix interleaving of error prefixes
The vreport() function will optionally emit an prefix for error
messages which is output to stderr incrementally. In the event
that two vreport() calls execute concurrently, there is a risk
that the prefix output will interleave. To address this it is
required to take a lock on 'stderr' when outputting errors.

Reported-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
6365e97c84 util: don't skip error prefixes when QMP is active
The vreport() function will print to HMP if available, otherwise
to stderr. In the event that vreport() is called during execution
of a QMP command, it will print to stderr, but mistakenly omit the
message prefixes (timestamp, guest name, program name).

This new usage of monitor_is_cur_qmp() from vreport() requires that
we add a stub to satisfy linking of non-system emulator binaries.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
2eb00abcfe util: fix interleaving of error & trace output
The monitor_cur_hmp() function will acquire/release mutex locks, which
will trigger trace probes, which can in turn trigger qemu_log() calls.
vreport() calls monitor_cur() multiple times through its execution
both directly and indirectly via error_vprintf().

The result is that the prefix information printed by vreport() gets
interleaved with qemu_log() output, when run outside the context of
an HMP command dispatcher. This can be seen with:

 $ qemu-system-x86_64 \
     -msg timestamp=on,guest-name=on \
     -display none \
     -object tls-creds-x509,id=f,dir=fish \
     -name fish \
     -d trace:qemu_mutex*
   2025-09-10T16:30:42.514374Z qemu_mutex_unlock released mutex 0x560b0339b4c0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:30:42.514400Z qemu_mutex_lock waiting on mutex 0x560b033983e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:30:42.514402Z qemu_mutex_locked taken mutex 0x560b033983e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:30:42.514404Z qemu_mutex_unlock released mutex 0x560b033983e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:30:42.516716Z qemu_mutex_lock waiting on mutex 0x560b03398560 (../monitor/monitor.c:91)
   2025-09-10T16:30:42.516723Z qemu_mutex_locked taken mutex 0x560b03398560 (../monitor/monitor.c:91)
   2025-09-10T16:30:42.516726Z qemu_mutex_unlock released mutex 0x560b03398560 (../monitor/monitor.c:96)
   2025-09-10T16:30:42.516728Z qemu_mutex_lock waiting on mutex 0x560b03398560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842057Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842058Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   2025-09-10T16:31:04.842055Z 2025-09-10T16:31:04.842060Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842061Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842062Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   2025-09-10T16:31:04.842064Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842065Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842066Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   fish 2025-09-10T16:31:04.842068Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842069Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842070Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   2025-09-10T16:31:04.842072Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842097Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842099Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   qemu-system-x86_64:2025-09-10T16:31:04.842100Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842102Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842103Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
    2025-09-10T16:31:04.842105Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842106Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842107Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)
   Unable to access credentials fish/ca-cert.pem: No such file or directory2025-09-10T16:31:04.842109Z qemu_mutex_lock waiting on mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842110Z qemu_mutex_locked taken mutex 0x564f5e401560 (../monitor/monitor.c:91)
   2025-09-10T16:31:04.842111Z qemu_mutex_unlock released mutex 0x564f5e401560 (../monitor/monitor.c:96)

To avoid this interleaving (as well as reduce the huge number of
mutex lock/unlock calls) we need to ensure that monitor_cur_is_hmp()
is only called once at the start of vreport(), and if no HMP is
present, no further monitor APIs can be called.

This implies error_[v]printf() cannot be called from vreport().
Instead we must introduce error_[v]printf_mon() which accept a
pre-acquired Monitor object. In some cases, however, fprintf
can be called directly as output will never be directed to the
monitor.

 $ qemu-system-x86_64 \
     -msg timestamp=on,guest-name=on \
     -display none \
     -object tls-creds-x509,id=f,dir=fish \
     -name fish \
     -d trace:qemu_mutex*
   2025-09-10T16:31:22.701691Z qemu_mutex_unlock released mutex 0x5626fd3b84c0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:31:22.701728Z qemu_mutex_lock waiting on mutex 0x5626fd3b53e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:31:22.701730Z qemu_mutex_locked taken mutex 0x5626fd3b53e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:31:22.701732Z qemu_mutex_unlock released mutex 0x5626fd3b53e0 (/var/home/berrange/src/virt/qemu/include/qemu/lockable.h:56)
   2025-09-10T16:31:22.703989Z qemu_mutex_lock waiting on mutex 0x5626fd3b5560 (../monitor/monitor.c:91)
   2025-09-10T16:31:22.703996Z qemu_mutex_locked taken mutex 0x5626fd3b5560 (../monitor/monitor.c:91)
   2025-09-10T16:31:22.703999Z qemu_mutex_unlock released mutex 0x5626fd3b5560 (../monitor/monitor.c:96)
   2025-09-10T16:31:22.704000Z fish qemu-system-x86_64: Unable to access credentials fish/ca-cert.pem: No such file or directory

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
a582a5784e monitor: move error_vprintf back to error-report.c
The current unit tests rely on monitor.o not being linked, such
that the monitor stubs get linked instead. Since error_vprintf
is in monitor.o this allows a stub error_vprintf impl to be used
that calls g_test_message.

This takes a different approach, with error_vprintf moving
back to error-report.c such that it is always linked into the
tests. The monitor_vprintf() stub is then changed to use
g_test_message if QTEST_SILENT_ERRORS is set, otherwise it will
return -1 and trigger error_vprintf to call vfprintf.

The end result is functionally equivalent for the purposes of
the unit tests.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
03eb6f411f util/log: add missing error reporting in qemu_log_trylock_with_err
One codepath that could return NULL failed to populate the errp
object.

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
338f63e5f0 util: avoid repeated prefix on incremental qemu_log calls
There are three general patterns to QEMU log output

 1. Single complete message calls

      qemu_log("Some message\n");

 2. Direct use of fprintf

      FILE *f = qemu_log_trylock()
      fprintf(f, "...");
      fprintf(f, "...");
      fprintf(f, "...\n");
      qemu_log_unlock(f)

 3. Mixed use of qemu_log_trylock/qemu_log()

      FILE *f = qemu_log_trylock()
      qemu_log("....");
      qemu_log("....");
      qemu_log("....\n");
      qemu_log_unlock(f)

When message prefixes are enabled, the timestamp will be
unconditionally emitted for all qemu_log() calls. This
works fine in the 1st case, and has no effect in the 2nd
case. In the 3rd case, however, we get the timestamp
printed over & over in each fragment.

One can suggest that pattern (3) is pointless as it is
functionally identical to (2) but with extra indirection
and overhead. None the less we have a fair bit of code
that does this.

The qemu_log() call itself is nothing more than a wrapper
which does pattern (2) with a single fprintf() call.

One might question whether (2) should include the message
prefix in the same way that (1), but there are scenarios
where this could be inappropriate / unhelpful such as the
CPU register dumps or linux-user strace output.

This patch fixes the problem in pattern (3) by keeping
track of the call depth of qemu_log_trylock() and then
only emitting the the prefix when the starting depth
was zero. In doing this qemu_log_trylock_context() is
also introduced as a variant of qemu_log_trylock()
that emits the prefix. Callers doing to batch output
can thus choose whether a prefix is appropriate or
not.

Fixes: 012842c075 (log: make '-msg timestamp=on' apply to all qemu_log usage)
Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
215235d365 util: add API to fetch the current thread name
This will be used to include the thread name in error reports
in a later patch. It returns a const string stored in a thread
local to avoid memory allocation when it is called repeatedly
in a single thread. The thread name should be set at the very
start of the thread execution, which is the case when using
qemu_thread_create.

This uses the official thread APIs for fetching thread names,
so that it captures  names of threads spawned by code in 3rd
party libraries, not merely QEMU spawned thrads.

This also addresses the gap from the previous patch for setting
the name of the main thread. A constructor is used to initialize
the 'namebuf' thread-local in the main thread only.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
d74938d14c util: set the name for the 'main' thread on Windows
The default main thread name is undefined, so use a constructor to
explicitly set it to 'main'. This constructor is marked to run early
as the thread name is intended to be used in error reporting / logs
which may be triggered very early in QEMU execution.

This is only done on Windows platforms, because on Linux (and possibly
other POSIX platforms) changing the main thread name has a side effect
of changing the process name reported by tools like 'ps' which fetch
from the file /proc/self/task/tid/comm, expecting it to be the binary
name.

The subsequent patch will address POSIX platforms in a different way.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
46255cc2be util: expose qemu_thread_set_name
The ability to set the thread name needs to be used in a number
of places, so expose the current impls as public methods.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
71d81b320d util: fix race setting thread name on Win32
The call to set the thread name on Win32 platforms is done by the parent
thread, after _beginthreadex() returns. At this point the new child
thread is potentially already executing its start method. To ensure the
thread name is guaranteed to be set before any "interesting" code starts
executing, it must be done in the start method of the child thread itself.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Daniel P. Berrangé
1b65aeed2a system: unconditionally enable thread naming
When thread naming was introduced years ago, it was disabled by
default and put behind a command line flag:

  commit 8f480de0c9
  Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
  Date:   Thu Jan 30 10:20:31 2014 +0000

    Add 'debug-threads' suboption to --name

This was done based on a concern that something might depend
on the historical thread naming. Thread names, however, were
never promised to be part of QEMU's public API. The defaults
will vary across platforms, so no assumptions should ever be
made about naming.

An opt-in behaviour is also unfortunately incompatible with
RCU which creates its thread from an constructor function
which is run before command line args are parsed. Thus the
RCU thread lacks any name.

libvirt has unconditionally enabled debug-threads=yes on all
VMs it creates for 10 years. Interestingly this DID expose a
bug in libvirt, as it parsed /proc/$PID/stat and could not
cope with a space in the thread name. This was a latent
pre-existing bug in libvirt though, and not a part of QEMU's
API.

Having thread names always available, will allow thread names
to be included in error reports and log messags QEMU prints
by default, which will improve ability to triage QEMU bugs.

Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-03-05 17:40:24 +00:00
Peter Maydell
4577ac30d8 Merge tag 'bsd-user-2026q1-upstream-pull-request' of ssh://github.com/bsdimp/qemu into staging
git-publish --base upstream/master --pull --to qemu-devel@nongnu.org --no-check-url

bsd-user: Upstream for 11.0

This combines several batch streams that:
(1) Upstream the bsd-misc.c system calls:
    quoatctl, reboot, getdtablesize, uuidgen, semget, semop, semctl, msgctl
(2) common-user drop __linux__ ifdef
(3) Remove NetBSD and OpenBSD specific code for bsd-user (hasn't built in years)
(4) Fix inotify issues on FreeBSD 15
(5) Fix issues with gdb on aarch64

All of thse have been reviewed, and the only problems with the check patch line
length and about added files.

# -----BEGIN PGP SIGNATURE-----
# Comment: GPGTools - https://gpgtools.org
#
# iQIzBAABCgAdFiEEIDX4lLAKo898zeG3bBzRKH2wEQAFAmmlD6EACgkQbBzRKH2w
# EQANZw//edwiQF/H+07EBKdZNF/QJsBwsH5OwHh/rgyq6OPUHWtu00gxNDFd/e/D
# O+FisLvDbNa9v2es1RX0lDzdgXRwi2LRIc4tMW3ifEjK7Jj8np09tfWkghwc2u9Z
# RShNxlCHfg/lTFkkm5wbHEpl1W1sImcLhYSLdoXAdUhK8lQOoUiFYOtg9s6xq6LH
# 3NHH4roY+HQE2zpK6gY45BsD1Fi3qdg5VNwTHkvcducdC5jjXnJ1UikL48zM72An
# LK8EqQfGx06RVkPgPyxTeUjniJj9SyixZjBD8YzqlmhSCt3RD4e0V+5/wd8YlPpI
# dBaYqzLSfft+vtJEqUyds/SilMHqf2brvJ9e2chwIqBlghxPb9GpPjHASDqk1/t8
# +ckFaOtdtamw0H8JFp1ixzFn7WLvUp3jpQJbSzZxmKwC0hZCxl/aXFKcq+gDg3k5
# 1wt/su+1zfb1Qjp8M8tKHLWy2/aXT/yY7IeWAk2hpOel3e4L9pDU6bsgQMz4kOE8
# WO6GHDu2YA688EArVL8ErTkKw04+mGdTMmjqrF00O/MWnW8LNKNTHIHaxWtCfXVv
# mHSUyHt94CoDtScwCdLmyZslHiO0XgUFhnK+EPd+sHyaAPu2uH6ezfFMRF8F1vs8
# WXsOnZArDg+r02PnltEjbIEOJ8t+tYTZqZ/3IKn2Gecixqhqdmc=
# =yPBa
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar  2 04:18:41 2026 GMT
# gpg:                using RSA key 2035F894B00AA3CF7CCDE1B76C1CD1287DB01100
# gpg: Good signature from "Warner Losh <wlosh@netflix.com>" [unknown]
# gpg:                 aka "Warner Losh <imp@bsdimp.com>" [unknown]
# gpg:                 aka "Warner Losh <imp@freebsd.org>" [unknown]
# gpg:                 aka "Warner Losh <imp@village.org>" [unknown]
# gpg:                 aka "Warner Losh <wlosh@bsdimp.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 2035 F894 B00A A3CF 7CCD  E1B7 6C1C D128 7DB0 1100

* tag 'bsd-user-2026q1-upstream-pull-request' of ssh://github.com/bsdimp/qemu: (27 commits)
  bsd-user: update aarch64-bsd-user.mak gdb XML list
  bsd-user: Add miscellaneous BSD syscall implementations
  bsd-user: Add System V message queue syscalls
  bsd-user: Implement System V semaphore calls
  bsd-user: Add bsd-misc.c to build
  bsd-user: Add message queue implementations
  bsd-user: Add do_bsd_msgctl implementation
  bsd-user: Add do_bsd___semctl implementation
  bsd-user: Add do_bsd_semop implementation
  bsd-user: Add do_bsd_semget implementation
  bsd-user: Add do_bsd_uuidgen implementation
  bsd-user: Add do_bsd_quotactl, do_bsd_reboot and do_bsd_getdtablesize
  bsd-user: Add semaphore operation constants and structures
  bsd-user: Add host_to_target_msqid_ds for msgctl(2)
  bsd-user: Add target_to_host_msqid_ds for msgctl(2)
  bsd-user: Add host_to_target_semid_ds for semctl(2)
  bsd-user: Add target_to_host_semid_ds for semctl(2)
  bsd-user: Add host_to_target_semarray for semaphore operations
  bsd-user: Add target_to_host_semarray for semaphore operations
  bsd-user: Add host_to_target_uuid for uuidgen(2)
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-03-02 14:01:31 +00:00
Warner Losh
bba2f724f1 freebsd: FreeBSD 15 has native inotify
Check to make sure that we have inotify in libc, before looking for it
in libinotify.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Daniel P. Berrange <berrange@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
2026-03-01 20:49:39 -07:00
Akihiko Odaki
649a78aa32 Reapply "rcu: Unify force quiescent state"
This reverts commit ddb4d9d174.

The commit says:
> This reverts commit 55d98e3ede.
>
> The commit introduced a regression in the replay functional test
> on alpha (tests/functional/alpha/test_replay.py), that causes CI
> failures regularly. Thus revert this change until someone has
> figured out what is going wrong here.

Reapply the change as alpha is fixed.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/20260217-alpha-v1-2-0dcc708c9db3@rsg.ci.i.u-tokyo.ac.jp
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:48:04 +01:00
Peter Maydell
2f9c4ba196 Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging
Pull request

Jens Axboe's fixes for fdmon-io_uring.

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmmcYhEACgkQnKSrs4Gr
# c8i4BAgAgI7UlEbQs0iLV0N4qUJ7pc8p/bgRNP9/TkjFYtFIcmRZtNeRvlkIVdgD
# F2QAMJAP0KzP3T2mo3a9f5kcvKIqLFsOpwKmMiUa98aA4dDhkT6TNOqLjgKmaXmR
# muEv7TKjBPzZqNBWDyEMIcnIzxSGjnbATN1BdvEy+7awJJDqaYZEkxTT6u+Vv/2l
# MlaYwnNbfye7nFM/xCBt/wH07XLZMC3pezHQxJGq7CGGTG0JFFeXIhm0HrTjlAt/
# EBVf41zsAtYqBj9egl5Y570NXkTirBbY+Niv/rqtavknC/tAxN+PQTBoobHm2Wna
# yU7+L+lidtIcdwhbzeZar0KdoDhsEQ==
# =zdFX
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Feb 23 14:20:01 2026 GMT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* tag 'block-pull-request' of https://gitlab.com/stefanha/qemu:
  fdmon-io_uring: check CQ ring directly in gsource_check
  aio-posix: notify main loop when SQEs are queued

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-02-24 11:32:35 +00:00
Jens Axboe
961fcc0f22 fdmon-io_uring: check CQ ring directly in gsource_check
gsource_check() only looks at the ppoll revents for the io_uring fd,
but CQEs can be posted during gsource_prepare()'s io_uring_submit()
call via kernel task_work processing on syscall exit. These completions
are already sitting in the CQ ring but the ring fd may not be signaled
yet, causing gsource_check() to return false.

Add a fallback io_uring_cq_ready() check so completions that arrive
during submission are dispatched immediately rather than waiting for
the next ppoll() cycle.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Message-ID: <20260213143225.161043-3-axboe@kernel.dk>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-02-23 08:50:04 -05:00
Jens Axboe
2ae361ef1d aio-posix: notify main loop when SQEs are queued
When a vCPU thread handles MMIO (holding BQL), aio_co_enter() runs the
block I/O coroutine inline on the vCPU thread because
qemu_get_current_aio_context() returns the main AioContext when BQL is
held. The coroutine calls luring_co_submit() which queues an SQE via
fdmon_io_uring_add_sqe(), but the actual io_uring_submit() only happens
in gsource_prepare() on the main loop thread.

Since the coroutine ran inline (not via aio_co_schedule()), no BH is
scheduled and aio_notify() is never called. The main loop remains asleep
in ppoll() with up to a 499ms timeout, leaving the SQE unsubmitted until
the next timer fires.

Fix this by calling aio_notify() after queuing the SQE. This wakes the
main loop via the eventfd so it can run gsource_prepare() and submit the
pending SQE promptly.

This is a generic fix that benefits all devices using aio=io_uring.
Without it, AHCI/SATA devices see MUCH worse I/O latency since they use
MMIO (not ioeventfd like virtio) and have no other mechanism to wake the
main loop after queuing block I/O.

This is usually a bit hard to detect, as it also relies on the ppoll
loop not waking up for other activity, and micro benchmarks tend not to
see it because they don't have any real processing time. With a
synthetic test case that has a few usleep() to simulate processing of
read data, it's very noticeable. The below example reads 128MB with
O_DIRECT in 128KB chunks in batches of 16, and has a 1ms delay before
each batch submit, and a 1ms delay after processing each completion.
Running it on /dev/sda yields:

time sudo ./iotest /dev/sda

________________________________________________________
Executed in   25.76 secs	  fish           external
   usr time    6.19 millis  783.00 micros    5.41 millis
   sys time   12.43 millis  642.00 micros   11.79 millis

while on a virtio-blk or NVMe device we get:

time sudo ./iotest /dev/vdb

________________________________________________________
Executed in    1.25 secs      fish           external
   usr time    1.40 millis    0.30 millis    1.10 millis
   sys time   17.61 millis    1.43 millis   16.18 millis

time sudo ./iotest /dev/nvme0n1

________________________________________________________
Executed in    1.26 secs      fish           external
   usr time    6.11 millis    0.52 millis    5.59 millis
   sys time   13.94 millis    1.50 millis   12.43 millis

where the latter are consistent. If we run the same test but keep the
socket for the ssh connection active by having activity there, then
the sda test looks as follows:

time sudo ./iotest /dev/sda

________________________________________________________
Executed in    1.23 secs      fish           external
   usr time    2.70 millis   39.00 micros    2.66 millis
   sys time    4.97 millis  977.00 micros    3.99 millis

as now the ppoll loop is woken all the time anyway.

After this fix, on an idle system:

time sudo ./iotest /dev/sda

________________________________________________________
Executed in    1.30 secs      fish           external
   usr time    2.14 millis    0.14 millis    2.00 millis
   sys time   16.93 millis    1.16 millis   15.76 millis

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Message-Id: <07d701b9-3039-4f9b-99a2-abeae51146a5@kernel.dk>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
[Generalize the comment since this applies to all vCPU thread activity,
not just coroutines, as suggested by Kevin Wolf <kwolf@redhat.com>.
--Stefan]
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-02-23 08:49:51 -05:00
Marc-André Lureau
ba63a9643a util: add some extra stubs for qemu modules initialization
Avoid extra ifdef-ery when optionally supporting modules, as done in
audio-test (and vl.c).

Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-02-23 14:28:57 +01:00
Vladimir Sementsov-Ogievskiy
2eed5472ec error-report: make real_time_iso8601() public
To be reused in the following commit.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260201173633.413934-3-vsementsov@yandex-team.ru>
2026-02-13 10:00:02 +01:00
Thomas Huth
ddb4d9d174 Revert "rcu: Unify force quiescent state"
This reverts commit 55d98e3ede.

The commit introduced a regression in the replay functional test
on alpha (tests/functional/alpha/test_replay.py), that causes CI
failures regularly. Thus revert this change until someone has
figured out what is going wrong here.

Buglink: https://gitlab.com/qemu-project/qemu/-/issues/3197
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260209120336.41454-1-thuth@redhat.com>
2026-02-12 08:43:13 +01:00
Vladimir Sementsov-Ogievskiy
7404d6852d tests/unit: add unit test for qemu_hexdump()
Test that the fix in commit 20aa05edc2 ("util/hexdump: fix
QEMU_HEXDUMP_LINE_WIDTH logic") make sense.

To not break compilation when we build without 'block', move
hexdump.c out of "if have_block" in meson.build.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20260202112826.38018-1-philmd@linaro.org>
2026-02-02 12:34:14 +01:00
Richard Henderson
9c4c090d27 Merge tag 'pull-target-arm-20260123' of https://gitlab.com/pm215/qemu into staging
target-arm queue:
 * hw/arm/imx8mp-evk: Provide some defaults matching real hardware
 * hw/intc: endianness fixes
 * various: Clean up includes
 * kernel-doc.py: sync with upstream Kernel v6.19-rc4
 * scripts/clean-includes: Minor improvements; exclude list update
 * docs/system/arm/imx8mp-evk: Avoid suggesting redundant CLI parameters
 * docs/system/arm/xlnx-zynq.rst: Improve docs rendering
 * docs: Be consistent about capitalization of 'Arm' (again)
 * docs: Avoid unintended mailto: hyperlinks
 * qemu-options.hx: Drop uses of @var
 * qemu-options.hx: Improve formatting in colo-compare docs

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmlzju4ZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3uU/D/9IHpo57UIHAF7vU9gsWm5k
# TxLl9PBw3ev2Uv6zWWza0wYZQF2ZcvqwMiU/AlBFuyJFyXTLocL3iN6Rsw+8kcjh
# jaq2hCtzSNJWj41CEU22l7iUfJ5PdOVdRYhhwlrQqxXDJj8Oj3plliRc6AL1EZYD
# mxAJ+YQ8pfJ/2ibO66sqwGMLjPsjCmmgfloTm/qFzk7QccQkPZKzDrC9CGGRmmRA
# tcdBGMtu+DOqpCRKIRul0S8ed2qaTecIK3+fUID0+qEzb10VWgFs/AAQiwLPkwyi
# RvMmIbC9lYVCnP+YC4HlvYMfd61V3lpzsUXgMIbdRZYsN/IlTVfetJUOVmn3LTQ/
# gGU0b+t6D/OZAt1L6toBngKVh89VPqbpGXEx4UMHCNIcvfI1Xo+HRT9ZV5WCw6b8
# sVKOZUwKs9ZbFAcrgBgskXp/5KWZAb92IFjwbfwxxl/2NRK3B3y7CDHBoOM/zQ9a
# rZ7rfJHhQVGR2+1QonNbpG0IFwbgs0zPQwBjPreGh6TWf2UiXvx1ku94Wxe2lA+5
# CPeju+swbFKRNjwSas6NZjJWazacohYG3nhmhF7HtcgX279BzIV0d+ZIl786Juls
# 4Vt4dPUxU/kHHZHjE52AZUS/opIy+UHAj0FKPAPpTrc7UfuHlY3gqoI7UfVpciau
# q3DqM7PlF2X91kw4xJ6JCA==
# =bE6w
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 24 Jan 2026 02:08:30 AM AEDT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [unknown]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [unknown]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [unknown]
# gpg:                 aka "Peter Maydell <peter@archaic.org.uk>" [unknown]
# gpg: WARNING: The key's User ID is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* tag 'pull-target-arm-20260123' of https://gitlab.com/pm215/qemu: (22 commits)
  qemu-options.hx: Improve formatting in colo-compare docs
  qemu-options.hx: Drop uses of @var
  docs: avoid unintended mailto: hyperlinks
  docs/system/arm/xlnx-zynq.rst: Improve docs rendering
  hw/intc: avoid byte swap fiddling in gicv3 its path
  hw/intc: declare GICv3 regions as little endian
  hw/intc: declare GIC regions as little endian
  hw/intc: declare NVIC regions as little endian
  all: Clean up includes
  misc: Clean up includes
  bsd-user: Clean up includes
  mshv: Clean up includes
  scripts/clean-includes: Update exclude list
  scripts/clean-includes: Give the args in git commit messages
  scripts/clean-includes: Do all our exclusions with REGEXFILE
  scripts/clean-includes: Make ignore-regexes one per line
  scripts/clean-includes: Remove outdated comment
  scripts/clean-includes: Allow directories on command line
  docs: Be consistent about capitalization of 'Arm' (again)
  kernel-doc.py: sync with upstream Kernel v6.19-rc4
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-01-24 07:59:34 +11:00