Commit Graph

129062 Commits

Author SHA1 Message Date
Marc-André Lureau
d4895fb4bf ui/vnc: defer listener registration until the console is known
Previously, the display change listener was registered early in
vnc_display_new() without a console, requiring vnc_display_open() to
conditionally unregister and re-register it when the actual console was
resolved. Since vnc_display_new() and vnc_display_open() were merged in
the previous commit, simply delay the registration and keyboard state
initialization to vnc_display_open(), after the console has been looked
up. This removes the conditional re-registration and simplifies the code.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:56 +04:00
Marc-André Lureau
4a33bdd9e0 ui/vnc: clean up VNC displays on exit
Previously, VNC displays were never torn down on QEMU exit, leaking
resources and leaving connected clients with unclean disconnects.

Add vnc_cleanup() to free all VNC displays during qemu_cleanup().
Make vnc_display_close() initiate disconnection of active clients,
and have vnc_display_free() drain the main loop until all clients
have completed their teardown, instead of asserting the client list
is empty.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:55 +04:00
Marc-André Lureau
bbd8cb0ed7 ui/vnc: merge vnc_display_init() and vnc_display_open()
Combine the two-step vnc_display_init()/vnc_display_open() sequence
into a single vnc_display_new() function that returns VncDisplay*.
This simplifies the API by making vnc_display_open() an
internal detail and will allow further code simplification.

vnc_display_new() is moved to vnc.h, since it returns VncDisplay* now.
Add vnc_display_free() for consistency, and it will be later used.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:53 +04:00
Marc-André Lureau
86dd35cf71 ui/vnc: vnc_display_init() and vnc_display_open() return bool
Use the QEMU-style error pattern returning "true" on success.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:51 +04:00
Marc-André Lureau
3ca9eff4af ui/vnc: make the worker thread per-VncDisplay
The VNC encoding worker thread was using a single global queue shared
across all VNC displays, with no way to stop it. This made it impossible
to properly clean up resources when a VncDisplay is freed.

Move the VncJobQueue from a file-scoped global to a per-VncDisplay
member, so each display owns its worker thread and queue. Add
vnc_stop_worker_thread() to perform an orderly shutdown: signal the
thread to exit, join it, and destroy the queue. The thread is now
created as QEMU_THREAD_JOINABLE instead of QEMU_THREAD_DETACHED.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:50 +04:00
Marc-André Lureau
c3cb2067d9 ui/console-vc: move VT100 emulation into separate unit
Move the VT100 terminal emulation code into dedicated ui/vt100.c and
ui/vt100.h files, completing the extraction from console-vc.c started
in the previous patches. This makes the VT100 layer a self-contained
module that can be reused independently of the chardev/console
infrastructure.

The code is moved as-is, with minor coding style fixes (adding missing
braces, fixing whitespace) applied during the move.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:48 +04:00
Marc-André Lureau
9e839f1ab7 ui/console: remove console_ch_t typedef and console_write_ch()
Since commit e2f82e924d ("console: purge curses bits from
console.h"), console_ch_t is a plain uint32_t typedef and
console_write_ch() is a trivial assignment (*dest = ch). These
abstractions were originally needed because console_ch_t was the
curses chtype when CONFIG_CURSES was enabled, and console_write_ch()
handled VGA-to-curses character translation. That commit moved the
curses logic into curses_update(), making the typedef and helper
dead abstractions.

Replace console_ch_t with uint32_t and console_write_ch() calls
with direct assignments.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:46 +04:00
Marc-André Lureau
d209ed1570 ui/console-vc: extract vt100_init() and vt100_fini()
Consolidate VT100 initialization and finalization into dedicated
functions, continuing the extraction of the VT100 layer from the
console/chardev code.

vt100_init() gathers the scattered setup (cursor timer, list insertion,
FIFO creation, default attributes, and image) that was previously spread
across vc_chr_open() and qemu_text_console_class_init().

vt100_fini() pairs with it by handling list removal, FIFO destruction,
and cells cleanup, replacing the open-coded QTAILQ_REMOVE in
qemu_text_console_finalize().

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:45 +04:00
Marc-André Lureau
c81db697a4 ui/console-vc: extract vt100_keysym() from qemu_text_console_handle_keysym()
Move the keysym handling logic out of qemu_text_console_handle_keysym()
into a new vt100_keysym() helper that operates on QemuVT100 directly,
continuing the effort to decouple the VT100 layer from the console layer.

The echo path is updated to call vt100_input() instead of
qemu_chr_write(), since the function no longer has direct access
to the chardev.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:43 +04:00
Marc-André Lureau
61420f1415 ui/console-vc: extract vt100_input() from vc_chr_write()
Move the VT100 input processing logic out of vc_chr_write() into a new
vt100_input() function that operates on QemuVT100 directly, rather than
going through the Chardev/VCChardev layers. This continues the effort
to decouple the VT100 emulation from the chardev backend, making the
VT100 layer self-contained and reusable.

vc_chr_write() becomes a thin wrapper that extracts the QemuVT100 from
the chardev and delegates to vt100_input().

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:41 +04:00
Marc-André Lureau
8fa294482e ui/console-vc: move VT100 state machine and output FIFO into QemuVT100
Move the terminal escape sequence parser state (TTYState, esc_params,
text attributes, saved cursor position) and the output FIFO from
VCChardev/QemuTextConsole into QemuVT100. Rename the corresponding
functions from vc_* to vt100_* to reflect they now operate on the VT100
layer directly, removing the indirection through vc->console->vt.

Add an out_flush callback to QemuVT100 so vt100_write() can flush
output without knowing about QemuTextConsole, and move FIFO/VT100
initialization from qemu_text_console_init() to vc_chr_open() where
the callback can be wired up.

This continues the decoupling of VT100 terminal emulation from the
chardev layer, making QemuVT100 a self-contained terminal emulator.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2026-05-09 10:24:39 +04:00
Marc-André Lureau
5080dc706e ui/console-vc: add UTF-8 input decoding with CP437 rendering
The text console receives bytes that may be UTF-8 encoded (e.g. from
a guest running a modern distro), but currently treats each byte as a
raw character index into the VGA/CP437 font, producing garbled output
for any multi-byte sequence.

Add a UTF-8 decoder using Bjoern Hoehrmann's DFA. The DFA inherently
rejects overlong encodings, surrogates, and codepoints above U+10FFFF.
Completed codepoints are then mapped to CP437, unmappable characters are
displayed as '?'.

Note that QEMU has a "buffered" utf8 decoder in util/unicode.c, but
it is not a good fit for byte-per-byte decoding.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:37 +04:00
Marc-André Lureau
ff7977e2c6 ui/dbus: expose vc encoding via D-Bus Chardev.VCEncoding interface
When a D-Bus VC chardev is instantiated, export an extra
org.qemu.Display1.Chardev.VCEncoding interface on the chardev
object.  This lets D-Bus display clients discover the encoding
(cp437 or utf8) in use by the virtual console.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:35 +04:00
Marc-André Lureau
0b1f036753 ui/console: default vc encoding to cp437 for machine < 11.1
Add a QOM "encoding" enum property to some chardev-vc backends
(console-vc & dbus - gtk and spice don't make use of it) so that the
machine compat mechanism can override the default. For machine versions
prior to 11.1, the charset defaults to cp437 (raw 8-bit VGA) instead of
utf8, preserving the historical behaviour.

The following commits are going to wire this to VT100 emulation code and
an extra exported D-Bus property.

Note that GTK libvte uses utf8 unconditionally, and Spice doesn't have a
way to set the encoding, and typically just use libvte in client too.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:33 +04:00
Marc-André Lureau
b389b87d3c ui/console: add vc encoding=utf8/cp437 option
Expose a new "encoding" QemuOpt option.

Add the corresponding QAPI type and properties.

This is going to be wired in the following commits.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:32 +04: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
Marc-André Lureau
f031490790 qemu-options.hx: document -chardev vc backend-specific behavior
The -chardev vc documentation only mentioned the built-in console with
optional size parameters, but the actual behavior depends on the display
backend. Document the GTK (libvte), D-Bus and spice-app cases.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:24:28 +04:00
Jindřich Makovička
960a41fbfd ui/gtk: Fix GTK assertion failure introduced with clipboard fixes
gtk_clipboard_request_targets actually returns n_targets == -1
when targets ==  NULL instead of zero. This result in failed assertion
within GTK:

qemu: Gtk: gtk_targets_include_text:
assertion 'targets != NULL || n_targets == 0' failed

Extend the check to require non-null targets and positive n_targets.

Signed-off-by: Jindrich Makovicka <makovick@gmail.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260501-clipboard-assert-fix-v1-1-e549243e4583@gmail.com>
2026-05-09 10:20:52 +04:00
Marc-André Lureau
4dc8407837 ui/input: do not assert() when tracing invalid input
It's possible to reach an assert() in the input tracing code by sending
some out of range input values via D-Bus for ex:

  #0  0x00007fec8652186c in __pthread_kill_implementation () at /lib64/libc.so.6
  #1  0x00007fec864c648e in raise () at /lib64/libc.so.6
  #2  0x00007fec864ad7b3 in abort () at /lib64/libc.so.6
  #3  0x00007fec864ae804 in __libc_message_impl.cold () at /lib64/libc.so.6
  #4  0x00007fec864be345 in __assert_fail () at /lib64/libc.so.6
  #5  0x00005597964c551e in qapi_enum_lookup[cold] ()
  #6  0x000055979650514a in qemu_input_event_send_impl ()
  #7  0x0000559796505a4d in qemu_input_queue_btn ()
  #8  0x00007fec85780c19 in dbus_mouse_press () at /usr/bin/../lib64/qemu/ui-dbus.so
  #9  0x00007fec857912fc in _g_dbus_codegen_marshal_BOOLEAN__OBJECT_UINT.part.0 () at /usr/bin/../lib64/qemu/ui-dbus.so
  #10 0x00007fec874cce7c in g_closure_invoke () at /lib64/libgobject-2.0.so.0
  #11 0x00007fec874eb849 in signal_emit_unlocked_R.isra.0 () at /lib64/libgobject-2.0.so.0
  #12 0x00007fec874ec66f in g_signal_emitv () at /lib64/libgobject-2.0.so.0
  #13 0x00007fec85797e0a in _qemu_dbus_display1_mouse_skeleton_handle_method_call () at /usr/bin/../lib64/qemu/ui-dbus.so

Other paths in input code accept out-of-range values
(qemu_input_key_value_to_number etc). Let it pass tracing.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2026-05-09 10:20:36 +04:00
Fabiano Rosas
9a816f6843 tests/qtest/dbus-vmstate: Re-enable the test
Back in 2020, the dbus-vmstate test was disabled by commit d46f81cb74
("tests: Disable dbus-vmstate-test") due to Patchew failures. We don't
use Patchew anymore for CI, so re-enable the test.

G_TEST_DBUS_DAEMON=../tests/dbus-vmstate-daemon.sh \
QTEST_QEMU_BINARY=./qemu-system-x86_64  \
./tests/qtest/dbus-vmstate-test

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260429190550.20122-6-farosas@suse.de>
2026-05-09 10:20:36 +04:00
Fabiano Rosas
50c71bc767 tests/qtest/dbus-vmstate: Stop the daemons explicitly
The dbus-vmstate test is currently non-deterministically emitting a
"cleaning up pid" message, followed by the PID of one of the
dbus-daemon processes used during the test. This is due to a race
between the GTestDBus g_autoptr destructor and a child process that
does cleanup when the program ends.

Add calls to g_test_dbus_down() to make the issuance of the SIGTERM to
the dbus-daemon deterministic.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260429190550.20122-5-farosas@suse.de>
2026-05-09 10:20:36 +04:00
Fabiano Rosas
db0c5927bc tests/qtest/dbus-vmstate: Honor QTEST_LOG env variable
Don't hide QEMU error messages unconditionally, make the tests that
expect to fail honor QTEST_LOG and show every output if the variable
is set.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260429190550.20122-4-farosas@suse.de>
2026-05-09 10:20:36 +04:00
Fabiano Rosas
09218537e4 tests/qtest/dbus-vmstate: Mute Glib complaints about g_unsetenv thread-safety
TLDR: GLib is bugged, the dbus-vmstate-test spams debug messages
unconditionally. Mute them.

GLib is trying to protect against the lack of thread-safety of
setenv/unsetsenv functions by warning when those functions were
invoked after a thread has been started.
https://gitlab.gnome.org/GNOME/glib/issues/715

Unfortunately:
1) GLib itself starts a thread pool via _g_dbus_initialize when
working around a bug in its type dependency chain. This happens in
many places, but the test triggers it via
g_dbus_address_get_for_bus_sync.
https://bugzilla.gnome.org/show_bug.cgi?id=627724

2) GLib itself calls g_unsetenv after the test calls g_test_dbus_up.

3) The debug message at g_unsetenv is issued to the G_LOG_DOMAIN
defined while compiling the library, i.e "GLib", but this domain is
never initialized, so the log functions go into a fallback chain that
results in ignoring the G_MESSAGES_DEBUG environment variable, causing
the debug messages to not be suppressed when they should.

Mute the messages by implementing a handler for G_LOG_LEVEL_DEBUG
in the "GLib" log domain and honoring G_MESSAGES_DEBUG.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260429190550.20122-3-farosas@suse.de>
2026-05-09 10:20:35 +04:00
Fabiano Rosas
18ff25e131 tests/qtest/dbus-vmstate: Bring the test up-to-date
The dbus-vmstate-test has been disabled for years. Here's the things
that have changed in the meantime and how to update the test:

- Migration tests got new headers.
Update the includes.

- migrate_qmp got new parameters.
Update the caller.

- migrate_incoming_qmp is now used instead of -incoming URL.
Use -incoming defer.

- Tests expecting failure should not check non-zero return code.
Check for failed migration state instead.

- The test result enum was introduced.
Replace the migration_fail flag with the enum.

- The DEVICE state was added.
Replace wait_for_migration_complete with migration_event_wait, which
won't trip on intermediary states.

- Migration completion was reworked.
Explicitly wait for the RESUME event before asserting runstate is
RUNNING to avoid checking too quickly and seeing FINISH_MIGRATE
instead.

- The FAILING state was added.
Wait for it before waiting for the RESUME event.

- Sanity checks were added to migration_get_env().
Start calling that function in main.

- qtest_add_func now has a wrapper.
Replace qtest_add_func with migration_test_add. Update tests'
signatures to take MigrationCommon, although it's unused.

- meson now sets up G_TEST_DBUS_DAEMON.
Remove the logic around it.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260429190550.20122-2-farosas@suse.de>
2026-05-09 10:20:35 +04:00
Stefan Hajnoczi
ee7eb612be Merge tag 'single-binary-20260506' of https://github.com/philmd/qemu into staging
Various patches related to single binary effort:

- Reduce "exec/cpu-defs.h" inclusions
- Build various target specific files once
- Remove need of per-target monitor handlers
- Reduce target_ulong uses in migration code
- Reduce uses of legacy native endianness & ld/st_phys APIs
- Removed MIPSCPU::mvp memory leak
- Clear dangling GLib event source tag
- Remove pointless variable initialization in *FOREACH*() macro uses
- Few checkpatch.pl updates

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmn7S/EACgkQ4+MsLN6t
# wN5bCBAAu05saLnGWy3s9aJ7mrrs2yqSOHRMskrV8/ULr9beJhqLCH7xobuHoSO0
# c3o6BSU9QnBB04Ps3uM2SKcWx2JrhN0em09CjxUW6QRk7pLhvyRWD+JK/JBc8mU+
# kew5ul9udpPeRo8JjyQQzB8qI8ZZZtFQl5iRp4vLxWWjaf3qHOtgnfl+86L9OLCy
# KLuzt2ppppwBOQuOl/i/yZ5JXyx+2cy21m9CmYIX0ApWYC8FngmNTtSgFCTFVu5a
# BZ21EaPGwvvw7OiE0pzY1424BvYKcR6EFQ5NOS1WNl1YvYsq8XeTONRFAFlVR6XC
# OVsaLnQpIMOhi5V7kTCsS5/OH5iNJNK5LVPF2R3e6F9ShcWiNVhR0RONkjpu3e/5
# OIXBfw4swO7rCDZvHg5dSW/up1KRs3XN+jGgvj0CONzxEcXJ/2VJTVdVdv6TqQUn
# dg8q0yfwxHbQZ/lfNH8wRhOmQw35gI3sZk/rGtV+0dTwK2ohQFBewCq6x5aLTKkY
# gMrZ5UvFntpTUBJUEw6L+56qLp3yQk3t5Wn43oQ04iRO6rAeGmHEw9IiVbF/jkxo
# ohe5DzZiUNErd8jbuFNgd/xMRvjKvLgxfwdqnos8yT0wyhhNa88pBUDcFP0diE0j
# sJGFjziBhfLhmrs+2VEsknY1I/Y0yJGN7ENyA5/+VnrW3Hlaa8A=
# =rwvm
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 06 May 2026 10:10:57 EDT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'single-binary-20260506' of https://github.com/philmd/qemu: (110 commits)
  system/vl: inline qemu_opts_parse_noisily() result checks
  scripts/checkpatch: Avoid false positive on empty blocks
  cocci: Do not initialize variable used by RAMBLOCK_FOREACH* macro
  cocci: Do not initialize variable used by QTAILQ_FOREACH macro
  cocci: Do not initialize variable used by QSIMPLEQ_FOREACH macro
  cocci: Do not initialize variable used by QSLIST_FOREACH macro
  cocci: Do not initialize variable used by QLIST_FOREACH macro
  scripts/checkpatch: Reject another license boilerplate pattern
  io: use g_clear_handle_id() for GSource cleanup
  io: Clear dangling GLib event source tag
  target/xtensa/core: register types using type_init
  target/s390x: Do not compile KVM stubs for linux-user binary
  target/mips: Do not initialize variable used by CPU_FOREACH macro
  target/mips: Reduce CPUState scope when used with CPU_FOREACH()
  target/riscv: Iterate vCPUs using CPU_FOREACH() macro
  target/s390x: Replace cpu_stb_data_ra -> cpu_stb_mmu in STFLE opcode
  target/s390x: Compile crypto_helper.c as common unit
  target/s390x: Have MSA helper pass a mmu_idx argument
  target/s390x: Compile vec_helper.c as common unit
  target/s390x: Compile translate.c as common unit
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-05-06 10:45:02 -04:00
Stefan Hajnoczi
7c71b7ae8b Merge tag 'pbouvier/pr/docs-20260505' of https://gitlab.com/p-b-o/qemu into staging
Changes:
- [PATCH] docs/devel/codebase: add link to rev.ng video series (Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>)
  Link: https://lore.kernel.org/qemu-devel/20260423213557.780112-1-pierrick.bouvier@oss.qualcomm.com

# -----BEGIN PGP SIGNATURE-----
#
# iQGzBAABCgAdFiEEN8FWlNi6l2Sxlz/btEQ30ZwoYt8FAmn6eKkACgkQtEQ30Zwo
# Yt+rnQv+PHi2mV1JvYqvS2sY3fa2KXtuooYFY/LcFf2ohtj5TdQZOMUB8pCodVv/
# 7yNdw6jGjsPByJJDYA5nS6bq6Oz8goyOv5lGwLfczR8c7cINFA8Hqn90IuhCChUn
# oL5s6fZHfaMYa7RMGgYDTBxzMhIGLFN7Mk44kPXDOxIyxH5vb3DHZEhFnaTH/Xz8
# iefR0JXr+RSgYFhjprJOBWcqMDi3zWFW9r25VtktwJHm1/DQGW03/A/w3cpInMZT
# qoSjRnUPoGqgEwmbBwBmYqoRgFaG4Zve0Ig9yG3ObDR3HiqTq1nTjATirmR3TWj/
# Votyyiu6PDFXroR/ijRb4qUe3+IykgUd+dydX/Z8F8T96GE+E5X5jqAYUnZ2wazT
# yU05UC7NT1Zuxiftx09MpmJhCsF/pDoICnVx1qGV01ND7xSRFEdMbbqhYXbczbOp
# 51k8i7Ql0t1/YkZ0Wt4TLroCW42G5TePfGnZAVCWsVm/RagceK25Zup1nltyoHba
# W5O3qTXb
# =ZXTI
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 05 May 2026 19:09:29 EDT
# gpg:                using RSA key 37C15694D8BA9764B1973FDBB44437D19C2862DF
# gpg: Good signature from "Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.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: 37C1 5694 D8BA 9764 B197  3FDB B444 37D1 9C28 62DF

* tag 'pbouvier/pr/docs-20260505' of https://gitlab.com/p-b-o/qemu:
  docs/devel/codebase: add link to rev.ng video series

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-05-06 10:44:06 -04:00
Stefan Hajnoczi
cd02ca8a65 Merge tag 'next-pull-request' of https://gitlab.com/peterx/qemu into staging
Migration and mem pull request

- Fabiano's fix on migrate_set_parameter crash with multifd & zerocopy
- Pranav's fix on postcopy stucking at device state when ack lost
- Samuel's new migration parameter x-rdma-chunk-size for RDMA
- PeterX's vfio/migration series to report remaining data and fix downtime calc
- PeterM's MemoryRegionOps .impl cleanup series
- Fabiano's fix to build a-b migration bootfiles for all archs

# -----BEGIN PGP SIGNATURE-----
#
# iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCafpSQxIccGV0ZXJ4QHJl
# ZGhhdC5jb20ACgkQO1/MzfOr1wZgygEAuuUARI33fSQ1t3xJr9BllwHp79R5A3ud
# DywPLgtaLVEA/061/96QYiHoBx/9u+y/7yCHilFqQo3pNLk6NEsp47gI
# =EW25
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 05 May 2026 16:25:39 EDT
# gpg:                using EDDSA key B9184DC20CC457DACF7DD1A93B5FCCCDF3ABD706
# gpg:                issuer "peterx@redhat.com"
# gpg: Good signature from "Peter Xu <xzpeter@gmail.com>" [full]
# gpg:                 aka "Peter Xu <peterx@redhat.com>" [full]
# Primary key fingerprint: B918 4DC2 0CC4 57DA CF7D  D1A9 3B5F CCCD F3AB D706

* tag 'next-pull-request' of https://gitlab.com/peterx/qemu: (23 commits)
  tests/qtest/migration: Fix A-B file build
  system/memory: assert on invalid MemoryRegionOps .unaligned combo
  hw/xtensa/mx_pic: Specify xtensa_mx_pic_ops .impl settings
  hw/npcm7xx_fiu: Specify .impl for npcm7xx_fiu_flash_ops
  hw/riscv: iommu-trap: remove .impl.unaligned = true
  vfio/migration: Add tracepoints for precopy/stopcopy query ioctls
  migration/qapi: Update unit for avail-switchover-bandwidth
  migration/qapi: Introduce system-wide "remaining" reports
  migration: Remember total dirty bytes in mig_stats
  migration: Fix calculation of expected_downtime to take VFIO info
  migration: Calculate expected downtime on demand
  migration: Introduce a helper to return switchover bw estimate
  migration: Move iteration counter out of RAM
  vfio/migration: Fix incorrect reporting for VFIO pending data
  migration: Introduce stopcopy_bytes in save_query_pending()
  migration: Use the new save_query_pending() API directly
  migration/treewide: Merge @state_pending_{exact|estimate} APIs
  vfio/migration: Cache stop size in VFIOMigration
  migration/qapi: Rename MigrationStats to MigrationRAMStats
  migration: Fix low possibility downtime violation
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-05-06 10:31:51 -04:00
Stefan Hajnoczi
e664457616 Merge tag 'or1k-maint-20260505' of https://github.com/stffrdhrn/qemu into staging
OpenRISC board maintainer updates for 2026-05-05

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEE2cRzVK74bBA6Je/xw7McLV5mJ+QFAmn6JL0ACgkQw7McLV5m
# J+TQGg//bqg5NQQP9VdM6EHqeHsy8RykKFotHU6hNDML+Gj5+4mnUvqLFwZBR9Rr
# AWizrCl9wHvP/RGDSZuM9QWSVsN3CUni60R5KIV/vkwEUTRhnRReHukYmGKItHbO
# pI+8KcYfD1/nflDXvAgtz+YaDLGruIUIvL651OMElAYoDrQxN+x4XilPHQRRNLfo
# ugJjHXaikXBLFwoEhEHzbNK8qeEtJQyN7GHOyigy+R5vrfBqqXYwNZQBUI/9rUrk
# VHKo9G25BjxgJC7mvBRJynzVpIu8McX9xqc4HmNepR4D9WCtR7Cndsh7cRPTgyju
# r5CjLvZahuzqdM/xluyMrApQQ8Qe4yChdNCsxhue83KZdOriGFzwz8aPyXKllMw3
# S7UyVkf1ZL1Th+Z4lBSzu+w2+5+Lz6xyQdUjUF9HR8x7QXD7Ouuofo+aUHweU2/N
# mnZvSvUa/zaq/ixUiHq21uqKASQxtIsF0aD5TGKIpYbWX181VpC1Xjh7KgmikzUF
# Yu93PvqvYN4KlzXU9o4uGuP4TmmI0AUSzGLrjTWCjWUwXOUYPwcWWxqAFZEIZToE
# MTIaWrvw5avzZI+CLuC3ZS9MJ+wpp/96QiUt7JJRI1PBO/Odf3SyQ+iu4F1dMSCp
# 6vRu9kj7+mjfW1avkUP4AzoVaD+DfKzNGtSJ1PqcC9e3rFVjqog=
# =uEyH
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 05 May 2026 13:11:25 EDT
# gpg:                using RSA key D9C47354AEF86C103A25EFF1C3B31C2D5E6627E4
# gpg: Good signature from "Stafford Horne <shorne@gmail.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: D9C4 7354 AEF8 6C10 3A25  EFF1 C3B3 1C2D 5E66 27E4

* tag 'or1k-maint-20260505' of https://github.com/stffrdhrn/qemu:
  MAINTAINERS: Add myself as the OpenRISC virt maintainer
  MAINTAINERS: Add myself as maintainer for or1k-sim

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2026-05-06 10:30:04 -04:00
Bin Guo
f73440f536 system/vl: inline qemu_opts_parse_noisily() result checks
In qemu_init()'s option parsing switch, several cases assigned the
return value of qemu_opts_parse_noisily() to the shared 'opts'
variable solely to check for NULL, without using the pointer
afterwards.  Inline the call directly into the if-condition, matching
the style already used by QEMU_OPTION_action.

This affects the following options:
  -drive, -numa, -iscsi, -m, -mon, -chardev, -fsdev, -fwcfg

Cases where the returned QemuOpts* is subsequently used (e.g.
-acpitable, -smbios, -virtfs) are left unchanged.

Signed-off-by: Bin Guo <guobin@linux.alibaba.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260429062004.36582-4-guobin@linux.alibaba.com>
[PMD: Reduce @opts declaration to innermost block]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2026-05-06 16:10:47 +02:00
Akihiko Odaki
e4bf9065c8 scripts/checkpatch: Avoid false positive on empty blocks
SUSPECT_CODE_INDENT checks the first line after a conditional statement.
When the block is empty, the first line after the conditional is the
closing brace at the same indentation level, so checkpatch reports a
bogus indentation error.

Ignore same-indented braces and else statements, matching with:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6950a735f29e782bc219ece22bb91d6e1ab7bbc

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Message-ID: <20260424-force_rcu-v4-6-feccfaca0568@rsg.ci.i.u-tokyo.ac.jp>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
9873bef556 cocci: Do not initialize variable used by RAMBLOCK_FOREACH* macro
The RAMBLOCK_FOREACH_MIGRATABLE() macro, defined in
migration/ram.h, ends up calling QLIST_FOREACH_RCU()
which always assigns its iterator variable when entering
the loop. Remove the pointless and possibly misleading
assignment.

Mechanical patch using the following coccinelle spatch:

  @@
  type T;
  identifier e;
  iterator FOREACH_MACRO =~ ".*_FOREACH.*";
  statement S;
  @@
  -    T *e = ...;
  +    T *e;
       ... when != e
       FOREACH_MACRO(e, ...) S

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260415215539.92629-6-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
29e182003b cocci: Do not initialize variable used by QTAILQ_FOREACH macro
The QTAILQ_FOREACH() macro, defined in "qemu/queue.h",
always assigns its iterator variable when entering the
loop. Remove the pointless and possibly misleading
assignment.

Mechanical patch using the following coccinelle spatch:

  @@
  type T;
  identifier e;
  iterator FOREACH_MACRO =~ ".*_FOREACH.*";
  statement S;
  @@
  -    T *e = ...;
  +    T *e;
       ... when != e
       FOREACH_MACRO(e, ...) S

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260415215539.92629-5-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
122a3dd50a cocci: Do not initialize variable used by QSIMPLEQ_FOREACH macro
The QSIMPLEQ_FOREACH() macro, defined in "qemu/queue.h",
always assigns its iterator variable when entering the
loop. Remove the pointless and possibly misleading
assignment.

Mechanical patch using the following coccinelle spatch:

  @@
  type T;
  identifier e;
  iterator FOREACH_MACRO =~ ".*_FOREACH.*";
  statement S;
  @@
  -    T *e = ...;
  +    T *e;
       ... when != e
       FOREACH_MACRO(e, ...) S

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260415215539.92629-4-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
a252e830ab cocci: Do not initialize variable used by QSLIST_FOREACH macro
The QSLIST_FOREACH() macro, defined in "qemu/queue.h",
always assigns its iterator variable when entering the
loop. Remove the pointless and possibly misleading
assignment.

Mechanical patch using the following coccinelle spatch:

  @@
  type T;
  identifier e;
  iterator FOREACH_MACRO =~ ".*_FOREACH.*";
  statement S;
  @@
  -    T *e = ...;
  +    T *e;
       ... when != e
       FOREACH_MACRO(e, ...) S

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260415215539.92629-3-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
f168046842 cocci: Do not initialize variable used by QLIST_FOREACH macro
The QLIST_FOREACH() macro, defined in "qemu/queue.h",
always assigns its iterator variable when entering the
loop. Remove the pointless and possibly misleading
assignment.

Mechanical patch using the following coccinelle spatch:

  @@
  type T;
  identifier e;
  iterator FOREACH_MACRO =~ ".*_FOREACH.*";
  statement S;
  @@
  -    T *e = ...;
  +    T *e;
       ... when != e
       FOREACH_MACRO(e, ...) S

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260415215539.92629-2-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Bernhard Beschow
1d34d4a2c1 scripts/checkpatch: Reject another license boilerplate pattern
The pattern us used 56 times in QEMU.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Tested-by: Matyas Bobek <matyas.bobek@gmail.com>
Message-ID: <20260414135018.13585-1-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
11a64a4b7c io: use g_clear_handle_id() for GSource cleanup
Use g_clear_handle_id() instead of g_source_remove() with
manual ID checking and zeroing.

This simplifies the code and ensures consistent handling of
GSource IDs, since g_clear_handle_id() checks for a non-zero
ID before calling the cleanup function and zeros it afterwards.

No functional change intended.

Mechanical change using the following Coccinelle spatch script:

  @@
  expression TAG;
  @@
  -    if (TAG > 0) {
  +    if (TAG) {
           g_source_remove(TAG);
           <... when != TAG
           TAG = 0;
           ...>
       }

  @@
  expression TAG;
  @@
  -    g_source_remove(TAG);
  -    TAG = 0;
  +    g_clear_handle_id(&TAG, g_source_remove);

  @@
  expression TAG;
  @@
  -    if (TAG) {
           g_clear_handle_id(&TAG, g_source_remove);
  -    }

Inspired-by: Matthew Penney <matt@matthewpenney.net>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Matthew Penney <matt@matthewpenney.net>
Message-Id: <20260408100605.66795-3-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
f378a25b16 io: Clear dangling GLib event source tag
Following commit 34aad58901 ("hw/char/virtio-console: clear
dangling GLib event source tag"), prevent stale tags from
being reused by clearing dangling GLib event source tag during
the cleanup phase (finalize, unrealize).

Inspired-by: Matthew Penney <matt@matthewpenney.net>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Matthew Penney <matt@matthewpenney.net>
Message-Id: <20260408100605.66795-2-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Pierrick Bouvier
b81e0e2a26 target/xtensa/core: register types using type_init
Instead of using a static constructor, delay registering those types
until we call module_init(MODULE_INIT_QOM).

This is not yet a problem, but since we will start initializing
target-info types before any other, without this patch
qemu-system-xtensa* fails with:
Type 'dsp3400-xtensa-cpu' is missing its parent 'xtensa-cpu'

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-ID: <20260430203842.29156-4-pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
b482e552d9 target/s390x: Do not compile KVM stubs for linux-user binary
None of these KVM symbols should be used in the qemu-s390x
linux-user binary. Do not build the stub there, prefer a
real linker failure.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20260423135035.50126-3-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
4ed05237df target/mips: Do not initialize variable used by CPU_FOREACH macro
The CPU_FOREACH() macro, defined in "hw/core/cpu.h",
ends up calling QTAILQ_FOREACH_RCU() which always
assigns its iterator variable when entering the loop.
Remove the pointless and possibly misleading assignment.

Mechanical patch using the following coccinelle spatch:

  @@
  type T;
  identifier e;
  iterator FOREACH_MACRO =~ ".*_FOREACH.*";
  statement S;
  @@
  -    T *e = ...;
  +    T *e;
       ... when != e
       FOREACH_MACRO(e, ...) S

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260415215539.92629-7-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
734bd83030 target/mips: Reduce CPUState scope when used with CPU_FOREACH()
When possible, reduce CPUState variable scope.
Prefer cpu_env(cpu) over &cpu->env.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260415215539.92629-8-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
ea6904ce60 target/riscv: Iterate vCPUs using CPU_FOREACH() macro
Most code iterates over vCPUs using the CPU_FOREACH()
macro. Prefer cpu_env(cpu) over &cpu->env.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-Id: <20260415215539.92629-9-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
e7f6130478 target/s390x: Replace cpu_stb_data_ra -> cpu_stb_mmu in STFLE opcode
In preparation of building misc_helper.c as a common unit, update
the cpu_ld/st_be_data_ra() API by cpu_ld/st_mmu() one and replace
"accel/tcg/cpu-ldst.h" by "accel/tcg/cpu-ldst-common.h".

For now we are blocked by the CONFIG_DEVICES use so keep the file
in s390x_ss[].

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20260423135035.50126-10-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
de96db79aa target/s390x: Compile crypto_helper.c as common unit
In order do build crypto_helper.c as a common unit we need to
replace:

  "accel/tcg/cpu-ldst.h" -> "accel/tcg/cpu-ldst-common.h"

and update the cpu_ld/st_be_data_ra() API by cpu_ld/st_mmu() one.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20260423135035.50126-9-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
fcc2699d41 target/s390x: Have MSA helper pass a mmu_idx argument
Next commit will use the cpu_ld/st_mmu() API and thus
will also use a @mmu_idx. In order to keep it simple to
review, propate @mmu_idx in a preliminary step.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20260423135035.50126-8-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
0f1cffe509 target/s390x: Compile vec_helper.c as common unit
In order do build vec_helper.c as a common unit we need to
replace:

  "accel/tcg/cpu-ldst.h" -> "accel/tcg/cpu-ldst-common.h"

and update the cpu_ld/st_be_data_ra() API by cpu_ld/st_mmu() one.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20260423135035.50126-7-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
82a1334c7e target/s390x: Compile translate.c as common unit
In order do build translate.c as a common unit we need to
replace:

  #include "tcg/tcg-op.h" -> #include "tcg/tcg-op-common.h"
                          -> #include "tcg/tcg-op-mem.h"

and:

  "accel/tcg/tcg-op-gvec.h" -> "accel/tcg/tcg-op-gvec-common.h"

taking care to define TCG_ADDRESS_BITS, which is fixed
for this 64-bit target.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20260423135035.50126-6-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
b2dbead3f9 target/s390x: Compile few files as common unit
Nothing in these files prevents it to be built as common unit:

 - cc_helper.c
 - excp_helper.c
 - fpu_helper.c
 - vec_fpu_helper.c
 - vec_int_helper.c
 - vec_string_helper.c

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20260423135035.50126-5-philmd@linaro.org>
2026-05-06 16:10:46 +02:00
Philippe Mathieu-Daudé
0b83acf2f0 target/s390x: Introduce common system/user meson source set
Introduce a source set common to system / user. Start it
with the files built in both sets: 'cpu_models_user.c'
and 'gdbstub.c' No logical change intended.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20260423135035.50126-4-philmd@linaro.org>
2026-05-06 16:10:46 +02:00