From: Jonas Theisen <j.theisen@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH docs/manager/qemu-server v2 00/20] check the target node's CPU before live migrating a VM
Date: Tue, 24 Nov 2026 17:30:24 +0100 [thread overview]
Message-ID: <20261124163136.320992-1-j.theisen@proxmox.com> (raw)
Live migrations of running VMs can currently fail late, or seem to
succeed and leave the guest unstable, if the target node's CPU cannot
run the VM's virtual CPU. This series checks the target's CPU upfront,
reports the result in the migration precondition API, and refuses
migrations that cannot work.
The checks use CPU information each node broadcasts to the cluster. The
already existing 'cpuflags-kvm' node key-value entry provides the flags
KVM supports. The new 'host-cpu-info' entry, broadcast by pvestatd,
provides the CPU vendor and model name, TSC frequency and TSC scaling
support. The checks are only done for running VMs, as stopped VMs get
a virtual CPU based on the target node, and they operate on the QEMU
CPU of the running instance, so they also cover custom CPU models.
Checks that block the migration:
- 'host'/'max' CPU model, target has a different CPU vendor
- fix #2924: 'host'/'max' CPU model, target lacks KVM CPU flags of the
source. As the source flags only approximate those of the VM, root
can override this with the new 'allow-missing-cpu-flags' option.
'force' is not reused, as the HA stack always sets it. Instead, the
new option is forwarded to the HA stack like other migration options.
The migration dialog offers it as an "Ignore CPU incompatibility"
checkbox for root, also for HA-managed VMs. Only flags that QEMU
recognizes are compared, as the broadcast also includes other CPU
properties that can differ between QEMU versions.
- any CPU model other than 'host'/'max', for example 'x86-64-v3',
'Skylake-Server' or a custom model: KVM on the target does not
support an enabled Hyper-V enlightenment (for example the Intel-only
'hv-evmcs' on an AMD target), or, as PVE sets 'enforce' for these
models, any other enabled flag. This includes the flags the QEMU CPU
model enables by default, which are queried from QEMU of the running
VM. Abstracted CPU configurations (custom model, 'nested-virt', ...)
keep the running QEMU CPU on the target, the others get the same
flags from the configuration.
- new 'hv-reenlightenment' flag or 'invtsc', target can neither scale
the TSC nor match the source's TSC frequency within 250 ppm
Checks that only warn, as a task warning and in the precondition API:
- fix #6535: live migration between CPU vendors with any other model
- 'host'/'max' CPU model, target has a different CPU model name
- the target does not broadcast the CPU information a blocking check
needs, for example as it runs an older version. Such nodes are not
blocked, as it is unknown whether they are compatible.
HA-managed VMs:
The checks run in the migration task, so they also apply to migrations
by the HA stack. For a migration requested via the API, the CPU of the
target is now also checked before handing it over to the HA stack, so
the API call fails with the reason directly, instead of only the LRM's
migration task failing later.
Migrations that the HA stack starts on its own, for maintenance mode,
the 'migrate' shutdown policy or automatic rebalancing, do not use the
override option and fail in the migration task. The HA stack currently
retries such failed migrations without backoff and without avoiding
the failing target, see bug #8059 [0]. Without this series, they fail
as well, but only after preparing the migration, or for 'host'/'max'
seem to succeed and leave the guest unstable.
[0] https://bugzilla.proxmox.com/show_bug.cgi?id=8059
The 'hv-reenlightenment' flag is added as part of this series. It lets
nested Hyper-V guests, for example Windows with WSL2 or VBS, keep
a stable clock source across live migrations. For it, the TSC
frequency is set explicitly to the host's, which is queried via
KVM_GET_TSC_KHZ on a temporary VM, as upstream Linux does not export it
otherwise.
The same is done for the invariant TSC flag 'invtsc', which can be
enabled with custom CPU models. Without an explicit TSC frequency, QEMU
blocks live migration, snapshots with RAM and hibernation of such VMs.
Guests need the flag to rely on the TSC as clock source, for example
for applications reading it directly or for nested hypervisors.
Nodes now also report whether they support invtsc. Previously, they
never reported it, as QEMU omits it from the migratable 'host' CPU
model, so the "Supported On" column of the flag selector of the
custom CPU model editor was always empty for it.
API changes of the migrate precondition endpoint:
- 'incompatible-cpu' in 'not_allowed_nodes', listing the type, message
and possible override option of each blocking incompatibility
- 'cpu-warnings', listing the warnings per node
The migration tests are extended to check for expected warnings in the
log, and cover each of the checks.
Dependencies: pve-manager's pvestatd patch uses
PVE::QemuServer::Helpers::get_host_cpu_info(), so it needs a bumped
qemu-server. Without it, qemu-server still works and runs the checks
based on the already broadcast CPU flags, but warns about the missing
CPU information.
The 'allow-missing-cpu-flags' override option relies on the HA stack
accepting forwarded migration options, as introduced for
'with-conntrack-state' and 'skip-config-check'.
Testing:
Upgrading the packages reloads pvestatd, so that it broadcasts the new
'host-cpu-info' entry and the 'cpuflags-kvm' entry including invtsc.
Only when deploying the code without the packages, restart pvestatd
manually. Start the test VMs only afterwards, as only VMs started with
this series get an explicit TSC frequency, without which the TSC check
does not apply.
The checks can be tested on a cluster with identical CPUs by making the
target node broadcast different CPU information. Unless noted
otherwise, run the following on the target node.
pvestatd broadcasts 'host-cpu-info' again whenever it differs, so stop
it first. Choose a 'tsc-khz' clearly different from the real one, as
the TSC check tolerates 250 ppm:
systemctl stop pvestatd
perl -MPVE::Cluster -e 'PVE::Cluster::broadcast_node_kv("host-cpu-info", q({"vendor":"GenuineIntel","model-name":"Fake CPU","tsc-khz":1000000,"tsc-scaling":0}))'
The 'cpuflags-kvm' entry is only broadcast again when the QEMU version
changes, so it can be changed while pvestatd runs. The following
removes the flags listed in REMOVE and adds the ones listed in ADD:
REMOVE='avx512f sha-ni' ADD='' perl -MPVE::Cluster -MPVE::INotify -e '
PVE::Cluster::cfs_update();
my $node = PVE::INotify::nodename();
my $flags = PVE::Cluster::get_node_kv("cpuflags-kvm", $node)->{$node};
my %remove = map { $_ => 1 } split(" ", $ENV{REMOVE});
my @flags = grep { !$remove{$_} } split(" ", $flags);
push @flags, split(" ", $ENV{ADD});
PVE::Cluster::broadcast_node_kv("cpuflags-kvm", join(" ", @flags));
'
Restarting pvestatd broadcasts the real values of both entries again:
systemctl restart pvestatd
The results show up in the precondition API, in the migration dialog,
and in the task log of 'qm migrate <vmid> <target> --online'. Disk-less
VMs suffice for live migration tests. The source node must be able to
start the VM, so it must support the flags of the tested CPU model.
pvesh get /nodes/<source>/qemu/<vmid>/migrate --output-format json-pretty
What to expect for a running VM:
- vendor 'GenuineIntel' on an AMD cluster (or vice versa): blocked for
CPU type 'host'/'max', a warning for other CPU types
- a different 'model-name': a warning for CPU type 'host'/'max'
- 'tsc-scaling' 0 and a 'tsc-khz' more than 250 ppm off: blocked for
VMs with 'flags=+hv-reenlightenment' or a custom CPU model with
'+invtsc'
- flags removed from 'cpuflags-kvm': blocked for CPU type 'host'/'max',
unless '--allow-missing-cpu-flags' is set, also for HA-managed VMs
- properties that are no CPU flags added to 'cpuflags-kvm' of the
source, for example ADD='x-test-property' run on the source node: not
blocked
- flags removed that a VM with a CPU model other than 'host'/'max'
uses: blocked, without override. For example 'avx2' for 'x86-64-v3',
'avx512f' for 'Skylake-Server', which that model enables by default,
or 'hv-stimer' for 'x86-64-v2-AES' with ostype 'win11'.
- 'invtsc' removed on the target for a VM with a custom CPU model with
'+invtsc' and a reported model other than 'host', for example the
default 'kvm64': blocked, without override. With reported model
'host', it is blocked like other flags missing for 'host', so it can
be overridden. VMs with CPU type 'host' do not have invtsc unless
enabled explicitly, so they are not blocked.
- an empty 'host-cpu-info' value: a 'missing-cpu-info' warning for VMs
where a blocking check needs the information
- a stopped VM: no CPU checks, as it gets a virtual CPU based on the
target node
The invtsc support of a node requires a host CPU with an invariant TSC,
which nested nodes only have if their own CPU has 'invtsc' enabled.
After the upgrade, the "Supported On" column of the flag selector of
the custom CPU model editor lists such nodes for invtsc.
For an HA-managed VM, 'qm migrate <vmid> <target> --online' to a node
with an incompatible CPU fails right away with the reason, instead of
requesting the migration from the HA stack. With
'--allow-missing-cpu-flags' and only missing flags for 'host'/'max',
the HA stack migrates the VM, and the migration task logs the ignored
incompatibility.
The "Ignore CPU incompatibility" checkbox of the migration dialog is
only shown for root, and the API refuses 'allow-missing-cpu-flags' for
other users.
The bulk migration of a node ("Bulk Migrate", 'pvenode migrateall')
skips VMs whose target is blocked, and logs the reason as "Has
incompatible CPU". It does not offer the override, so it also skips
VMs that are only blocked due to missing flags for 'host'/'max'.
Changes since v1:
* fix #2924 patch: only compare flags that QEMU recognizes as CPUID
flags. The broadcast flags also include other CPU properties, such as
'migratable' or 'l3-cache', which can differ between QEMU versions
and would block live migration between nodes running different QEMU
versions.
* extend the check of the flags of the kept virtual CPU to all CPU
models other than 'host'/'max', for example 'x86-64-v3'. These are
generated again from the configuration on the target, but with the
same flags, and QEMU refuses to start if one is missing, as PVE sets
'enforce' for them. The flags the QEMU CPU model enables by default
are now included as well. The 'kept-cpu-flags' type of the
precondition API is renamed to 'vm-cpu-flags' accordingly.
* new: report the invtsc support of nodes
* new: set the TSC frequency for invtsc, as for 'hv-reenlightenment',
so that such VMs can be live migrated, and extend the TSC check of
the target node to it
* new: check the CPU of the target in the migrate API before
requesting a migration of an HA-managed VM from the HA stack, with
a preparatory patch that factors out the check
* new: docs patch for the checks, 'hv-reenlightenment' and invtsc
* add 'Fixes:' trailers with the bug report URLs
* pvestatd patch: drop the error handling for querying the host CPU
information, as qemu-server already handles the only query that can
fail
* rebased onto current master
qemu-server:
Jonas Theisen (15):
test: migration: allow checking for warnings and errors in the log
migrate: block live migration of host CPU VMs between CPU vendors
fix #6535: migrate: warn about live migration between CPU vendors
cpu flags: factor out parsing the broadcast CPU flags of a node
fix #2924: migrate: block live migration of host CPU VMs to nodes
lacking flags
migrate: warn about live migration of host CPU VMs between CPU models
migrate: factor out whether the running virtual CPU is kept
migrate: block migration if the target cannot run the virtual CPU
cpu flags: report invtsc support of nodes
helpers: add helper to query the host's TSC frequency and scaling
support
cpu config: add hv-reenlightenment flag and set TSC frequency for it
migrate: block migration to nodes with incompatible TSC for
re-enlightenment
cpu config: set TSC frequency for invtsc to allow live migration
migrate: factor out asserting the CPU compatibility of the target
api: migrate: check the CPU of the target before requesting HA
migration
src/PVE/API2/Qemu.pm | 114 +-
src/PVE/QemuMigrate.pm | 11 +-
src/PVE/QemuMigrate/Helpers.pm | 437 +++++++
src/PVE/QemuServer.pm | 14 +
src/PVE/QemuServer/CPUConfig.pm | 35 +
src/PVE/QemuServer/CPUFlags.pm | 29 +-
src/PVE/QemuServer/Helpers.pm | 99 ++
src/test/MigrationTest/QemuMigrateMock.pm | 52 +
src/test/QemuServerTest/CommandLineMocks.pm | 7 +
src/test/cfg2cmd/cpu-hv-reenlightenment.conf | 6 +
.../cfg2cmd/cpu-hv-reenlightenment.conf.cmd | 26 +
src/test/cfg2cmd/cpu-invtsc.conf | 6 +
src/test/cfg2cmd/cpu-invtsc.conf.cmd | 27 +
src/test/run_qemu_migrate_tests.pl | 1033 +++++++++++++++++
14 files changed, 1887 insertions(+), 9 deletions(-)
create mode 100644 src/test/cfg2cmd/cpu-hv-reenlightenment.conf
create mode 100644 src/test/cfg2cmd/cpu-hv-reenlightenment.conf.cmd
create mode 100644 src/test/cfg2cmd/cpu-invtsc.conf
create mode 100644 src/test/cfg2cmd/cpu-invtsc.conf.cmd
pve-manager:
Jonas Theisen (4):
pvestatd: broadcast host CPU information relevant for live migration
ui: migrate: show why the CPU of the target node is incompatible
fix #6535: ui: migrate: show CPU warnings for the target node
api: nodes: migrateall: skip VMs whose CPU is incompatible with the
target
PVE/API2/Nodes.pm | 5 +++
PVE/Service/pvestatd.pm | 15 ++++++++
www/manager6/window/Migrate.js | 63 ++++++++++++++++++++++++++++++++++
3 files changed, 83 insertions(+)
pve-docs:
Jonas Theisen (1):
qm: document hv-reenlightenment, invtsc and CPU checks for migration
qm.adoc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
Summary over all repositories:
18 files changed, 2021 insertions(+), 9 deletions(-)
--
Generated by murpp 0.12.1
next reply other threads:[~2026-11-24 16:32 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 16:30 Jonas Theisen [this message]
2026-11-24 16:30 ` [PATCH qemu-server v2 01/20] test: migration: allow checking for warnings and errors in the log Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 02/20] migrate: block live migration of host CPU VMs between CPU vendors Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 03/20] fix #6535: migrate: warn about live migration " Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 04/20] cpu flags: factor out parsing the broadcast CPU flags of a node Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 05/20] fix #2924: migrate: block live migration of host CPU VMs to nodes lacking flags Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 06/20] migrate: warn about live migration of host CPU VMs between CPU models Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 07/20] migrate: factor out whether the running virtual CPU is kept Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 08/20] migrate: block migration if the target cannot run the virtual CPU Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 09/20] cpu flags: report invtsc support of nodes Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 10/20] helpers: add helper to query the host's TSC frequency and scaling support Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 11/20] cpu config: add hv-reenlightenment flag and set TSC frequency for it Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 12/20] migrate: block migration to nodes with incompatible TSC for re-enlightenment Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 13/20] cpu config: set TSC frequency for invtsc to allow live migration Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 14/20] migrate: factor out asserting the CPU compatibility of the target Jonas Theisen
2026-11-24 16:30 ` [PATCH qemu-server v2 15/20] api: migrate: check the CPU of the target before requesting HA migration Jonas Theisen
2026-11-24 16:30 ` [PATCH manager v2 16/20] pvestatd: broadcast host CPU information relevant for live migration Jonas Theisen
2026-11-24 16:30 ` [PATCH manager v2 17/20] ui: migrate: show why the CPU of the target node is incompatible Jonas Theisen
2026-11-24 16:30 ` [PATCH manager v2 18/20] fix #6535: ui: migrate: show CPU warnings for the target node Jonas Theisen
2026-11-24 16:30 ` [PATCH manager v2 19/20] api: nodes: migrateall: skip VMs whose CPU is incompatible with the target Jonas Theisen
2026-11-24 16:30 ` [PATCH docs v2 20/20] qm: document hv-reenlightenment, invtsc and CPU checks for migration Jonas Theisen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124163136.320992-1-j.theisen@proxmox.com \
--to=j.theisen@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox