Commit Graph

126420 Commits

Author SHA1 Message Date
Shameer Kolothum
49f6b93d07 linux-headers: Update to Linux v6.19-rc1
Mainly for adding support for VFIO DMABUF. While at it, update all
headers.

The header update breaks virtio-net due to virtio_net_hdr_v1_hash
changes. Include the virtio-net changes to avoid build and bisect
failures.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260121114111.34045-2-skolothumtho@nvidia.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
2026-01-26 08:30:04 +01:00
Jim Shu
0e387bd1df hw/vfio: cpr-iommufd: Fix wrong usage of migrate_add_blocker_modes
The return value of API is 0 for success and negative error code for
failure. We'll check if the return value equals to 0.
Also, the MIG_MODE should be CPR_TRANSFER and CPR_EXEC instead
of 2 same bits.

The API usage is aligned with 'hw/vfio/cpr-legacy.c' after these 2
changes.

Fixes: 3ca0a0ab05 ("migration: Use bitset of MigMode instead of variable arguments")
Signed-off-by: Jim Shu <jim.shu@sifive.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260121063418.2001326-1-jim.shu@sifive.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
2026-01-26 08:30:04 +01:00
Zhenzhong Duan
e3c659fee0 vfio/migration: Fix page size calculation
Coverity detected an issue of left shifting int by more than 31 bits leading
to undefined behavior.

In practice bcontainer->dirty_pgsizes always have some common page sizes
when dirty tracking is supported.

Resolves: Coverity CID 1644186
Resolves: Coverity CID 1644187
Resolves: Coverity CID 1644188
Fixes: 46c7633114 ("vfio/migration: Add migration blocker if VM memory is too large to cause unmap_bitmap failure").
Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260116060315.65723-1-zhenzhong.duan@intel.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
2026-01-26 08:30:04 +01:00
Richard Henderson
fea2d7a784 Merge tag 'linux-user-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa into staging
linux-user: statx() syscall, termios2 support and futext() syscall fixes

v2:
Fix build error in which CentOS9 is lacking the definition of MADV_COLLAPSE

# -----BEGIN PGP SIGNATURE-----
#
# iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCaXSIawAKCRD3ErUQojoP
# X1HtAQDmDfFPKNNL9+tRr+6d2mzfc2mM4B8prJhh1LdUaDy6SwEAmf/M080jpH5W
# ljtBSN41MIOfS4s3qFs2O9uL096YgQE=
# =WcLZ
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 24 Jan 2026 07:52:59 PM AEDT
# gpg:                using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F
# gpg: Good signature from "Helge Deller <deller@gmx.de>" [unknown]
# gpg:                 aka "Helge Deller <deller@kernel.org>" [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: 4544 8228 2CD9 10DB EF3D  25F8 3E5F 3D04 A7A2 4603
#      Subkey fingerprint: BCE9 123E 1AD2 9F07 C049  BBDE F712 B510 A23A 0F5F

* tag 'linux-user-for-v11-pull-request' of https://github.com/hdeller/qemu-hppa:
  linux-user: Fix MADV_XXX constants on hppa target
  linux-user: strace: Fix 5th argument of futex syscall
  linux-user: fixup termios2 related things on PowerPC
  linux-user: Add missing termios baud rates
  linux-user: Add termios2 support to sparc target
  linux-user: Add termios2 support to sh4 target
  linux-user: Add termios2 support to mips target
  linux-user: Add termios2 support to hppa target
  linux-user: Add termios2 support to alpha target
  linux-user: Add termios2 support
  linux-user: update statx emulation

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-01-24 21:31:17 +11:00
Helge Deller
5db961f92b linux-user: Fix MADV_XXX constants on hppa target
Older hppa binaries may still use the old MADV_XXX constants for the
madivise() syscall. Fix it up in the same manner as it's done in the
Linux kernel in the parisc_madvise() function.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2026-01-24 09:47:00 +01:00
Richard Henderson
363a069b31 Merge tag 'migration-20260123-pull-request' of https://gitlab.com/farosas/qemu into staging
Migration pull request

- Removal of deprecated query-migrationthreads command
- Removal of deprecated QMP migrate argument 'detach'
- Removal of deprecated zero-blocks capability
- Removal of deprecated migration to file using fd: URI
- Improvements to fd handling in QEMUFile
- Cleanups to postcopy tests
- Cleanup of migration channel connection code

# -----BEGIN PGP SIGNATURE-----
#
# iQJEBAABCAAuFiEEqhtIsKIjJqWkw2TPx5jcdBvsMZ0FAmlz0PIQHGZhcm9zYXNA
# c3VzZS5kZQAKCRDHmNx0G+wxnS1hEADSUFCynktz0MwmPbun9rHI/DSTmkk2SFIj
# 4WI66Wgez805uD/Xa/r7qpqpjkTTFd+mgbfUlkcmiatrrPMFsYFP4cyrtFfLOl16
# ODmYZO+VQ+cFpzgXDsS1IrHSwaJ1zU7sFkYLXGJdwwhkDWDDxHpO/1OADG7HotkH
# GFaZaMFim4fAHuDp688uzbUsljNjaKNlqbZQFVeg2S+ewEFtp1/tTY2oRTuKA0Es
# BPeENU6xQxR26YPn8lZub61D12ZNw4BCKTNANGvnDGjTmC9Ijw3iAjEo5O4TWhca
# q7UPkFS9uuxIxtAeRul92XzAclASnZ52Lk1oTfP083GcXIepsFwNKKmZtulOjGm2
# bz8exu46WUSO0wxlWcM/DGfmkapKbXteP/nIBjpeRrYxxz4dBJ4MHHCNv487Si3Y
# Um8dar3wUNP6UZEt/ZGidJRvcigMwM01aDVXyn05qqHQ8Qfj93ozi9hz1ttHBeDP
# QuX6LlJ4wiU4z9QZqNaDe7pwSi/VdROkp3U0/0SVySudqE/vTC0YtUxq2miH7RLl
# VJsYPF9nZOEgKXCqMdzM4G9kr/jJ0Ou7z8hm/J6l19joBn79pf7FrRG935LCM7at
# 0xkF1D+D/O4+C/mnYemVXNwY35MhQR9OihS6DjVxYeySf4QIwUtuzBQ6W1pz9vJt
# EyLedtJXpg==
# =7sEk
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 24 Jan 2026 06:50:10 AM AEDT
# gpg:                using RSA key AA1B48B0A22326A5A4C364CFC798DC741BEC319D
# gpg:                issuer "farosas@suse.de"
# gpg: Good signature from "Fabiano Rosas <farosas@suse.de>" [unknown]
# gpg:                 aka "Fabiano Almeida Rosas <fabiano.rosas@suse.com>" [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: AA1B 48B0 A223 26A5 A4C3  64CF C798 DC74 1BEC 319D

* tag 'migration-20260123-pull-request' of https://gitlab.com/farosas/qemu: (36 commits)
  migration/channel: Centralize calling migration_channel_connect_outgoing
  migration: Remove qmp_migrate_finish
  migration: Move CPR HUP watch to cpr-transfer.c
  migration: Free cpr-transfer MigrationAddress along with gsource
  migration: Move URI parsing to channel.c
  migration: Move channel parsing to channel.c
  migration: Move transport connection code into channel.c
  migration: Move channel code to channel.c
  migration: Rename instances of start
  migration/channel: Rename migration_channel_connect
  migration: Start incoming from channel.c
  migration/rdma: Use common connection paths
  migration: Move setting of QEMUFile into migration_outgoing|incoming_setup
  migration: Handle error in the early async paths
  migration: Fold migration_cleanup() into migration_connect_error_propagate()
  migration: yank: Move register instance earlier
  migration: Expand migration_connect_error_propagate to cover cancelling
  migration: Move error reporting out of migration_cleanup
  migration: Free the error earlier in the resume case
  migration: Use migrate_mode() to query for cpr-transfer
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-01-24 10:08:23 +11: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
Richard Henderson
092009a55c Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into staging
# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCAAdFiEEIV1G9IJGaJ7HfzVi7wSWWzmNYhEFAmlzZqsACgkQ7wSWWzmN
# YhGITAf+I46cGYha4dE7Gepbqnk+/eHxURNhToX2yZwWsRBkn4LEWHxavWzYGhTk
# acaVL7zPiHG7S33xSUT7Ie3yrLvbpATAlBsa5xbEKS26KAVIzVtsmMJA6jHyKXUX
# RKBoX2zUkveMZCDtU0XSPjf/wzf7LyeFEDk/o9Agl5zzqfU3mfe58Zk+9MkpFJ9Y
# HEGgocbW4Kuu65RJzesejbrBw0f3PMq8cfktUJ8rj0o5v5MX58hrijBAbE5JLrxG
# Z2u1GvMFR4ZA3e+Mmgu5zg2/AZ4/ZrN9c8moxB9DWLVX8Psz4fJwyYm2Hx0ldhf4
# 4ETQ326nrAZ5REiUTea1FPACBSK7dw==
# =TV7k
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 23 Jan 2026 11:16:43 PM AEDT
# gpg:                using RSA key 215D46F48246689EC77F3562EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.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: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* tag 'net-pull-request' of https://github.com/jasowang/qemu:
  tests/qtest: Add test for filter-redirector rx event opened
  qtest: add a test to test redirector status change
  net/filter-redirector: add support for dynamic status on/off switching
  tests/qtest: add test for filter-buffer interval change
  net/filter-buffer: make interval change take effect immediately
  net/tap: rework tap_set_sndbuf()
  net/tap: tap_set_sndbuf(): add return value
  net/tap: setup exit notifier only when needed
  net/tap: rework scripts handling
  net/tap: pass NULL to net_init_tap_one() in cases when scripts are NULL
  net/tap: net_init_tap_one(): move parameter checking earlier
  net/tap: net_init_tap_one(): drop extra error propagation
  net/tap-linux.c: avoid abort when setting invalid fd

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2026-01-24 07:58:52 +11:00
Helge Deller
160b9347c7 linux-user: strace: Fix 5th argument of futex syscall
The 5th argument isn't printed, but instead the 4th argument is shown twice.
Fix this, and print the FUTEX_BITSET_MATCH_ANY string constant instead of -1
if the op is FUTEX_WAIT_BITSET or FUTEX_WAKE_BITSET.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2026-01-23 20:40:15 +01:00
Icenowy Zheng
d68f0e2e90 linux-user: fixup termios2 related things on PowerPC
The termios things on PowerPC equal to termios2 things otherwhere.

Use some simple #define's to allow both termios and termios2 to map to
termios on PowerPC.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Link: 8d77eeaa76/app-virtualization/qemu/01-shared/patches/0005-AOSCOS-linux-user-fixup-termios2-related-things-on-P.patch
Link: https://lore.kernel.org/qemu-devel/4403eb94ddbb2934f1f75d94ce921f0f1078ad9f.camel@icenowy.me
Reviewed-by: Helge Deller <deller@gmx.de>
2026-01-23 20:40:15 +01:00
Vivian Wang
4f22fcb5c6 linux-user: Add missing termios baud rates
Add several missing baud rates and inputs baud rates in cflag_tbl.

Add these missing definitions in termbits.h:

- TARGET_BOTHER for alpha, hppa, ppc, sh4, sparc
- TARGET_IBSHIFT for hppa, mips, ppc, sh4, sparc
- Missing standard baud rates for hppa

These are required for the glibc test tst-termios-linux.

Link: https://lore.kernel.org/qemu-devel/20251203-linux-user-higher-baud-rates-v2-1-e45b35224437@iscas.ac.cn
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Reviewed-by: Helge Deller <deller@gmx.de>
2026-01-23 20:40:15 +01:00
Luca Bonissi
947b971cad linux-user: Add termios2 support to sparc target
Signed-off-by: Luca Bonissi <qemu@bonslack.org>
Link: https://lore.kernel.org/qemu-devel/909d9d68-c6fe-4368-825c-6aa8fdbd3bbc@bonslack.org
Reviewed-by: Helge Deller <deller@gmx.de>
2026-01-23 20:40:15 +01:00
Luca Bonissi
afbe0ff81c linux-user: Add termios2 support to sh4 target
Signed-off-by: Luca Bonissi <qemu@bonslack.org>
Link: https://lore.kernel.org/qemu-devel/642b32de-2985-45d2-bbdf-c0b2e3ea0551@bonslack.org
Reviewed-by: Helge Deller <deller@gmx.de>
2026-01-23 20:40:15 +01:00
Luca Bonissi
edf9184f4f linux-user: Add termios2 support to mips target
Signed-off-by: Luca Bonissi <qemu@bonslack.org>
Link: https://lore.kernel.org/qemu-devel/361aa9c5-4464-4d27-8a2c-9ab767324530@bonslack.org
Reviewed-by: Helge Deller <deller@gmx.de>
2026-01-23 20:40:15 +01:00
Luca Bonissi
edc741710a linux-user: Add termios2 support to hppa target
Signed-off-by: Luca Bonissi <qemu@bonslack.org>
Link: https://lore.kernel.org/qemu-devel/ccf1be5c-9e2e-46f6-b303-d29888371fb0@bonslack.org
Reviewed-by: Helge Deller <deller@gmx.de>
2026-01-23 20:40:15 +01:00
Luca Bonissi
8d8c6aeee8 linux-user: Add termios2 support to alpha target
Signed-off-by: Luca Bonissi <qemu@bonslack.org>
Link: https://lore.kernel.org/qemu-devel/02dba951-1bcf-4c74-8a6a-f4f4aa5ce909@bonslack.org
Reviewed-by: Helge Deller <deller@gmx.de>
2026-01-23 20:40:15 +01:00
Luca Bonissi
e9a8a10e84 linux-user: Add termios2 support
Signed-off-by: Luca Bonissi <qemu@bonslack.org>
Link: https://lore.kernel.org/qemu-devel/745f18b6-ee62-4903-9a56-dcb903b610cf@bonslack.org
Reviewed-by: Helge Deller <deller@gmx.de>
Tested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2026-01-23 20:40:15 +01:00
Andreas Schwab
344640b479 linux-user: update statx emulation
Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Helge Deller <deller@gmx.de>
2026-01-23 20:40:15 +01:00
Fabiano Rosas
03a680c978 migration/channel: Centralize calling migration_channel_connect_outgoing
Make the synchronous calls evident by not hiding the call to
migration_channel_connect_outgoing() in the transport code. Have those
functions return and call the function at the upper level.

This helps with navigation: the transport code returns the ioc,
there's no need to look into them when browsing the code.

It also allows RDMA in the source side to use the same path as the
rest of the transports.

While here, document the async calls which are the exception.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-26-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:34:25 -03:00
Fabiano Rosas
2379a04e60 migration: Remove qmp_migrate_finish
After cleanups, the qmp_migrate_finish function is now just a call to
migration_connect_outgoing(). Remove qmp_migrate_finish() and rename
the qmp_migrate_finish_cb callback.

This also allows the function's error handling to be removed as it now
receives &local_err like the rest of the callees of qmp_migrate().

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-25-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:19 -03:00
Fabiano Rosas
f523e5aa5f migration: Move CPR HUP watch to cpr-transfer.c
Move this CPR-specific code into a cpr file. While here, give the
functions more significant names.

This makes the new idea (after cpr-transfer) of having two parts to
qmp_migrate slightly more obvious: either wait for the hangup or
continue directly.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-24-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:19 -03:00
Fabiano Rosas
6a887119ce migration: Free cpr-transfer MigrationAddress along with gsource
When setting a callback on a Glib source and giving it a data pointer,
it's natural to also provide the destructor for the data in question.

Since migrate_hup_add() already needs to clone the MigrationAddress
when setting the qmp_migrate_finish_cb callback, also pass the
qapi_free_MigrationAddress as the GDestroyNotify callback.

With this the address doesn't need to be freed at the callback body,
making the management of that memory slightly simpler.

Cc: Mark Kanda <mark.kanda@oracle.com>
Cc: Ben Chaney <bchaney@akamai.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-23-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:18 -03:00
Fabiano Rosas
0c26f7f8e9 migration: Move URI parsing to channel.c
The migrate_uri_parse function is responsible for converting the URI
string into a MigrationChannel for consumption by the rest of the
code. Move it to channel.c and add a wrapper that calls both URI and
channels parsing.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-22-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:18 -03:00
Fabiano Rosas
b16e0dae8e migration: Move channel parsing to channel.c
Encapsulate the MigrationChannelList parsing in a new
migrate_channels_parse() located at channel.c.

This also makes the memory management of the MigrationAddress more
uniform. Previously, half the parsing code (uri parsing) would
allocate memory for the address while the other half (channel parsing)
would instead pass the original QAPI object along. After this patch,
the MigrationAddress is always QAPI_CLONEd, so the callers can use
g_autoptr(MigrationAddress) in all cases.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-21-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:18 -03:00
Fabiano Rosas
468bd4ba1c migration: Move transport connection code into channel.c
Move the <transport>_connect_incoming|outgoing functions to channel.c.
It leaves migration.c to deal with the established connection only.

While here, sort the includes.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-20-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:18 -03:00
Fabiano Rosas
7d7bf3e60e migration: Move channel code to channel.c
Move the code responsible for the various channels connection into
channel.c. This is all executed before the migration_thread and
process_incoming_migration_co are running, so it helps the reasoning
to have them out of migration.c.

migration_ioc_process_incoming becomes migration_channel_identify
which is more in line with what the function does.

Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-19-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:18 -03:00
Fabiano Rosas
86a0ceb1ce migration: Rename instances of start
To make it easier to follow the code, rename the functions that start
the migration thread and migration coroutine to contain the word
"start".

This will give new contributors the chance of seeing the word start
and reaching the actual migration code, instead of twists and turns of
qio_channel_add_watch and qio_task_run_in_thread.

Remove all other instances of "start" and use wording more suitable to
what the current migration stage is. The transport code such as
fd_start_migration_outgoing becomes fd_connect_outgoing, the early
setup code such as qemu_start_incoming_migration becomes
qemu_setup_incoming_migration and so on.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-18-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:18 -03:00
Fabiano Rosas
9fdca27637 migration/channel: Rename migration_channel_connect
Rename migration_channel_connect to indicate this is the source
side. Future patches will do similar changes to the incoming side and
this will avoid inconsistencies in naming.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-17-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:18 -03:00
Fabiano Rosas
9834b6de61 migration: Start incoming from channel.c
Leave migration_ioc_process_incoming to do only the channel
identification process and move the migration start into
channel.c. Both routines will be renamed in the next patches to better
reflect their usage.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-16-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:17 -03:00
Fabiano Rosas
52f3b05d54 migration/rdma: Use common connection paths
Use the common connection paths for the incoming and outgoing sides of
rdma migration. This removes one usage of QEMUFile from rdma.c. It
also allows further unification of the connection code in next
patches.

Move the channels enum to channel.h so rdma.c can access it. The RDMA
channel is considered a CH_MAIN channel.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-15-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:17 -03:00
Fabiano Rosas
5bc9c7995c migration: Move setting of QEMUFile into migration_outgoing|incoming_setup
Centralize, on both sides of migration, the setting of the to_src_file
and from_dst_file QEMUFiles. This will clean up the interface with
channel.c and rdma.c, allowing those files to stop dealing with
QEMUFile themselves.

(multifd_recv_new_channel was changed to return bool+errp for
convenience)

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-14-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:17 -03:00
Fabiano Rosas
b6ef92ddbd migration: Handle error in the early async paths
Simplify migration_channel_connect() and migration_connect() to not
take an error as input. Move the error handling into the paths that
generate the error.

To achieve this, call migration_connect_error_propagate() from
socket.c and tls.c, which are the async paths.

For the sync paths, the handling is done as normal by returning all
the way to qmp_migrate_finish(), except that now the sync paths don't
pass the error forward into migration_connect() anymore.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-13-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:17 -03:00
Fabiano Rosas
6b587af5ec migration: Fold migration_cleanup() into migration_connect_error_propagate()
Whenever an error occurs between migrate_init() and the start of
migration_thread, do cleanup immediately.

This allows the special casing for resume to be removed from
migration_connect(), that check is now done at
migration_connect_error_propagate() which already had a case for
resume.

The cleanup at qmp_migrate_finish_cb can also be removed because it
will always be reached either via the error path at
qmp_migrate_finish->migration_connect_error_propagate or via the
migrate_cleanup_bh.

The yank_unregister_instance at qmp_migrate() is now replaced by the
one at migration_cleanup().

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-12-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:17 -03:00
Fabiano Rosas
7e71439243 migration: yank: Move register instance earlier
Move the register_instance call to migrate_prepare() so it can be
paired with the unregister_instance at migration_cleanup(). Otherwise,
the cleanup cannot be run when cpr_state_save() fails because the
instance is registered only after it.

When resuming from a paused postcopy migration, migrate_prepare()
returns early, but migration_cleanup() doesn't run, so the yank will
remain paired.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-11-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:17 -03:00
Fabiano Rosas
2f8ccc5d58 migration: Expand migration_connect_error_propagate to cover cancelling
Cover the CANCELLING state in migration_connect_error_propagate() and
use it to funnel errors from migrate_prepare() until the end of
migration_connect().

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-10-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:17 -03:00
Fabiano Rosas
f7be51a690 migration: Move error reporting out of migration_cleanup
In the next patches migration_cleanup() will be used in qmp_migrate(),
which currently does not show an error message. Move the error
reporting out of migration_cleanup() to avoid duplicate messages.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-9-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:16 -03:00
Fabiano Rosas
318cb7906e migration: Free the error earlier in the resume case
Freeing the error at migration_connect() is redundant in the normal
migration case. The freeing already happened at migrate_init():

qmp_migrate()
-> migrate_prepare()
   -> migrate_init()
-> qmp_migrate_finish()
   -> *_start_outgoing_migration()
   -> migration_channel_connect()
      -> migration_connect()

For the resume case, migrate_prepare() returns early and doesn't reach
migrate_init(). Move the extra migrate_error_free() call to
migrate_prepare() along with the resume check.

Also change migrate_init() to use migrate_error_free(), so it's easier
to see where are the places the error gets freed.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-8-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:16 -03:00
Fabiano Rosas
5dafed3235 migration: Use migrate_mode() to query for cpr-transfer
cpr_set_incoming_mode() is only called on the target side, so
migrate_mode() on the source side is the same as s->parameters.mode.

Use the function to reduce explicit access to s->parameters, we have
options.c for that.

Cc: Mark Kanda <mark.kanda@oracle.com>
Cc: Ben Chaney <bchaney@akamai.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-7-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:16 -03:00
Fabiano Rosas
a57209371b migration: Move postcopy_try_recover into migration_incoming_process
The postcopy_try_recover() call doesn't need to be duplicated, move it
into migration_incoming_process().

This removes code from migration_fd_process_incoming() so it can be
removed in the near future.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-6-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:16 -03:00
Fabiano Rosas
5a26b76b4a migration: Cleanup TLS handshake hostname passing
The TLS hostname is doing a tour around the world just to be cached
into s->hostname. We're already abusing MigrationState by doing that,
so incorporate the s->hostname into migration_tls_hostname() and stop
passing the string around.

The old route was roughly:

 -transport code (socket.c, fd.c, etc):
    if (SOCKET_ADDRESS_TYPE_INET)
        hostname = saddr->u.inet.host
    else
        hostname = NULL
    migration_channel_connect(..., hostname)
      s->hostname = hostname;
      migration_tls_client_create(..., hostname)
        if (migrate_tls_hostname())
            qio_channel_tls_new_client(migrate_tls_hostname())
        else
            qio_channel_tls_new_client(hostname)

 -postcopy_preempt_setup:
    postcopy_preempt_send_channel_new
      migration_tls_client_create(..., s->hostname)

New route is:

 -socket.c only:
   if SOCKET_ADDRESS_TYPE_INET
       s->hostname = saddr->u.inet.host
   migration_channel_connect()
     migration_tls_client_create()
       qio_channel_tls_new_client(migrate_tls_hostname())

 -postcopy_preempt_setup:
    postcopy_preempt_send_channel_new
      migration_tls_client_create()
        qio_channel_tls_new_client(migrate_tls_hostname())

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-5-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:16 -03:00
Fabiano Rosas
13b50cc7ea migration/tls: Remove unused parameter
The MigrationState parameter is not used at
migration_tls_channel_process_incoming().

The last usage was removed by commit 3f461a0c0b ("migration: Drop
unused parameter for migration_tls_get_creds()")

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-4-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:16 -03:00
Fabiano Rosas
44fe18201c migration: Fix state change at migration_channel_process_incoming
When the incoming migration fails during the channel connection phase,
the state transition to FAILED is currently being done in the
MigrationState->state, but the MigrationIncomingState->state is the
one that should be used.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-3-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:16 -03:00
Fabiano Rosas
41982a06d1 migration: Remove redundant state change
If local_err is set, migration_connect_error_propagate() will be
called and that function already has a state transition from SETUP to
FAILED.

Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-2-farosas@suse.de
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:32:16 -03:00
Peter Xu
f1fcc1c101 migration: Remove fd: support on files
This feature was deprecated in 9.1.  Remove it in this release (11.0).

We also need to remove one unit test (/migration/precopy/fd/file) that
covers the fd: file migration, because it'll stop working now.

Reviewed-by: Prasad Pandit <ppandit@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260115225503.3083355-3-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:24:19 -03:00
Peter Xu
aa575660d0 migration: Remove zero-blocks capability
It was declared deprecated since 9.2.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260115225503.3083355-2-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:24:19 -03:00
Peter Xu
3346b16aa2 tests/migration-test: Remove postcopy_recovery_fail_stage from MigrateCommon
The parameter can be instead passed into the function to avoid polluting
the global address space of MigrateCommon.

Reviewed-by: Prasad Pandit <ppandit@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260114153751.2427172-3-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:24:19 -03:00
Peter Xu
86571f5121 tests/migration-test: Remove postcopy_data from MigrateCommon
Now postcopy is not the only user of start_hook / end_hook that will pass
in a opaque pointer.  It doesn't need to be defined in MigrateCommon as
part of the framework, as all other hook users can pass hook_data around.
Do it too for postcopy.

Reviewed-by: Prasad Pandit <ppandit@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260114153751.2427172-2-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:24:18 -03:00
Vladimir Sementsov-Ogievskiy
f43a45ba09 qemu-file: qemu_file_get_fd(): improve interface
Make it symmetrical with qemu_file_put_fd() and simplify callers.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/qemu-devel/20260114064710.176268-6-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:24:18 -03:00
Vladimir Sementsov-Ogievskiy
20125d93af qemu-file: qemu_file_get_fd(): check service byte itself
We can check it, so, why not.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/qemu-devel/20260114064710.176268-5-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:24:18 -03:00
Vladimir Sementsov-Ogievskiy
ace0ad87ae qemu-file: qemu_file_get_fd(): get byte in one shot
No reason to split into peek + get.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/qemu-devel/20260114064710.176268-4-vsementsov@yandex-team.ru
Signed-off-by: Fabiano Rosas <farosas@suse.de>
2026-01-23 11:24:18 -03:00