From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 45E1A1FF0BC for ; Wed, 02 Dec 2026 16:18:58 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 270FC217F3; Wed, 02 Dec 2026 16:18:46 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH docs/manager/qemu-server v4 00/21] check the target node's CPU before live migrating a VM Date: Wed, 2 Dec 2026 16:17:56 +0100 Message-ID: <20261202151831.414110-1-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1796224718064 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.092 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: WVSJPNC7C5VLMGW6H6HQRZFKG75Z7KHY X-Message-ID-Hash: WVSJPNC7C5VLMGW6H6HQRZFKG75Z7KHY X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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. 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, this can be overridden with the new 'allow-missing-cpu-flags' option, see below. Only flags that QEMU recognizes are compared, as the broadcast also includes other CPU properties that can differ between QEMU versions. Flags that only tell the guest which vulnerabilities do not affect it only cause a warning, see below. Flags set for 'max' with KVM are checked without override as part of the next check, as PVE sets 'enforce' for it. - any CPU model with KVM: KVM on the target does not support an enabled Hyper-V enlightenment, as QEMU always requires them, also for 'host'/'max'. For models other than 'host'/'max', for example 'x86-64-v3', 'Skylake-Server' or a custom model, PVE sets 'enforce', so this also applies to any other enabled flag, including the flags the QEMU CPU model enables by default, which are queried from QEMU of the running VM, but not to QEMU CPU properties that are no flags, like 'host-phys-bits'. Abstracted CPU configurations (custom model, 'nested-virt', ...) keep the running QEMU CPU on the target, so for example the Intel-only 'hv-evmcs' blocks them from AMD targets. The others get their flags from the configuration again, where the automatic 'hv-evmcs' is only enabled on Intel hosts, so it is not checked for other targets, unless it is set for the VM. With TCG, which VMs of another architecture than the host's use by default, all flags are emulated, so the checks do not apply. 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 - 'host'/'max' CPU model, target lacks flags that only tell the guest which CPU vulnerabilities do not affect it, for example 'its-no' or 'gds-no' of the IA32_ARCH_CAPABILITIES MSR on Intel, or 'srso-no' or 'tsa-l1-no' on AMD. KVM reports some of them only with newer kernels, so blocking would prevent live migration to nodes with an older kernel during upgrades. The guest keeps running, but might have skipped a mitigation it needs if the target CPU is actually affected. 'tsx-ctrl' is still blocking, as it lets the guest access an MSR, and so are the 'vmx-*' flags, which a nested hypervisor in the guest uses. - 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. The same applies if only the source lacks its CPU flags, for example as their entry got lost when pmxcfs was restarted. - the target's broadcast CPU flags include no Hyper-V enlightenments, as they were detected before qemu-server 9.1.17: the enlightenments of the VM are reported as possibly unsupported - the check itself fails, for example as the QEMU command line of the VM cannot be read: the checks only guard migrations that work without them, so a failure must not block them, for example the migrations of HA maintenance mode Override: The 'allow-missing-cpu-flags' option only needs 'VM.Migrate', as ignoring the check only risks the migrated guest. 'force' is not reused, as the HA stack always sets it. The migration dialog offers the option as an "Ignore CPU incompatibility" checkbox. 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. The override option is forwarded to the HA stack like other migration options, if the source node runs pve-manager 9.2.31 or newer. As the HA stack passes it on to VMs in positive affinity, 'VM.Migrate' is required on these as well. 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 and the live migration of VMs with 'invtsc', which were part of v2, are split out into a separate series that builds on this one, as they extend the checks with one for the TSC frequency of the target. 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, including a 'cpu-check-failed' warning for each node if the check itself fails - both include the values of the message as typed details, so that clients do not need to parse them: the CPU vendors and model names of the nodes, and all missing flags, of which the message lists at most ten The migration tests are extended to check for expected warnings in the log and for unexpected ones about the CPU, and cover each of the checks. API tests cover the reasons of the precondition API against its schema, and the check before requesting an HA migration. 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. Only when deploying the code without the packages, restart pvestatd manually. 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: systemctl stop pvestatd perl -MPVE::Cluster -e 'PVE::Cluster::broadcast_node_kv("host-cpu-info", q({"vendor":"GenuineIntel","model-name":"Fake CPU"}))' 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 --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//qemu//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' - 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'. - 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 For an HA-managed VM, 'qm migrate --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. With a positive resource affinity rule between the HA-managed VM and another VM, '--allow-missing-cpu-flags' is refused for users lacking 'VM.Migrate' on the other VM. The bulk migration of a node ("Bulk Migrate", 'pvenode migrateall') skips VMs whose target is blocked, and logs the reason as "Has incompatible CPU". The bulk migration of the datacenter skips them with a warning, like VMs that are already on the target, instead of starting migrations that are refused. Neither offers the override, so they also skip VMs that are only blocked due to missing flags for 'host'/'max'. pvestatd now broadcasts the supported CPU flags again if their entry got lost, for example when pmxcfs is restarted. Before, they stayed missing until the QEMU version changed. Changes since v3: * allow 'allow-missing-cpu-flags' for all users with 'VM.Migrate' instead of only root. The root-only check did not hold for the HA resource migration API, which forwards the option with only 'Sys.Console' on '/', and ignoring the check only risks the migrated guest. * ui: show the "Ignore CPU incompatibility" checkbox for all users * check the CPU before setting up the conntrack state helper, as a failed preparation does not stop it again * check Hyper-V enlightenments for all CPU models with KVM, also 'host' and 'max' generated again on the target, as QEMU requires them regardless of 'enforce' * only skip the automatic 'hv-evmcs' for targets that do not enable it when generating the CPU again, using the same decision as qemu-server does when generating it, and not if it is set for the VM * parse the running QEMU CPU with QEMU's precedence, so that for example '-hv-evmcs' overrides a later 'hv_evmcs' * warn instead of refusing if the target broadcasts no Hyper-V enlightenments, as its flags were detected before qemu-server 9.1.17 * warn if the source node lacks its CPU flags, the only CPU information it does not determine itself, instead of skipping the checks silently * add typed details for the values in the messages to the precondition API * new: pvestatd: broadcast the supported CPU flags again if they got lost * new: api: cluster: bulk migrate: skip VMs whose CPU is incompatible with the target * new: cpu config: factor out whether hv-evmcs is enabled for a CPU vendor * tests: assume an x86_64 host in the migration tests, so that the test of the TCG default for other architectures also works on aarch64 builders * only warn about missing flags that only tell the guest which vulnerabilities do not affect it, those of the IA32_ARCH_CAPABILITIES MSR on Intel and the corresponding CPUID flags on AMD, as KVM reports some of them only with newer kernels * report flags set for 'max' with KVM only as non-overridable 'vm-cpu-flags', instead of also as overridable 'host-cpu-flags', as QEMU on the target refuses to start without them * HA: require 'VM.Migrate' on the VMs in positive affinity if 'allow-missing-cpu-flags' is forwarded to the HA stack, as it passes the option on to them. If it is not forwarded, as with pve-manager older than 9.2.31 on the source node, do not suggest the override, neither in the error nor in the precondition API. * do not refuse the migration if the CPU check itself fails, but log a task warning, and report a 'cpu-check-failed' warning for each node in the precondition API instead of only logging the error there * skip QEMU CPU properties that are no flags, like 'host-phys-bits', for CPU models with 'enforce' as well, as is done for 'host' and 'max' * skip the checks for confidential VMs, which cannot be live migrated at all * test the extra privilege of 'allow-missing-cpu-flags' for HA-managed VMs in its own commit * pvestatd: query the host CPU information in each cycle, so that information qemu-server could not determine before is broadcast once it can * docs: list the refused migrations as requirements and the warnings as a separate list, and shorten the section Changes since v2: * split out 'hv-reenlightenment' and the live migration of VMs with 'invtsc' into a separate series, and split the docs patch accordingly * drop the patch that factored out asserting the CPU compatibility of the target: it is a helper from the first patch on, so later patches extend it instead of the migration preparation. The precondition API reports warnings from the first patch on as well, and the CPU checks are documented as lists, so that later patches only add to them. * do not block the live migration of VMs with CPU types that are generated again on the target, like 'x86-64-v2-AES', because of 'hv-evmcs', which PVE only enables for Windows 11 on Intel hosts. This blocked such Windows 11 VMs from Intel to AMD nodes. VMs that keep their virtual CPU, for example with 'nested-virt', are still blocked. * use TCG as default for VMs of another architecture than the host's, as qemu-server does elsewhere, and skip the check of the VM's flags with TCG, which emulates them all * do not report CPU information as missing on the target that the source node lacks as well, for example the CPU vendor on aarch64 * treat flags as disabled for the VM for all boolean values, not only 'off' * HA: only honor override options in the API check if they are forwarded to the HA stack * pvestatd patch: encode the CPU information as UTF-8, as qemu-server decodes it as such * order the independent refactors before the checks * docs: correct which checks need the CPU information of the new version, that 'max' is only affected with KVM, and name the checkbox of the migration dialog * new: normalize underscores in all CPU flag names, as every spelling QEMU accepts for '-cpu' refers to the flag with dashes, instead of only in the migration checks. This drops the aliases that only replaced dashes with underscores. * new: factor out reading the flags of a CPU model expansion, which was done in two places * report missing CPU information of a node as a regular warning of the CPU checks, instead of handling it separately in the API and the migration task. The task log now shows it as "CPU of node '' might be incompatible: the node does not provide the CPU information needed to check it, ..." * log the CPU warnings only if the migration is not refused anyway * tests: add a helper for the migration tests of the CPU checks, which shrinks them to less than half, and fail on unexpected warnings or errors about the CPU, which uncovered a test that silently logged a warning about missing CPU information. Add tests for flags disabled for the VM, aliases in the broadcast flags, and missing information that only warnings need. * tests: new API tests for the reasons of the precondition API, validated against its schema, and for the check before requesting an HA migration, with a preparatory patch * new: ignore the runtime files of the migration tests in git * pvestatd patch: only mention the CPU vendor and model name in the commit message, as only these are broadcast with this series * rebased onto current master 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: 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 * 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 (14): buildsys: ignore migration test runtime files test: migration: allow checking for warnings and errors in the log cpu flags: normalize underscores in all CPU flag names test: api: factor out validating the migration preconditions cpu flags: factor out parsing the broadcast CPU flags of a node migrate: factor out whether the running virtual CPU is kept cpu flags: factor out the flags of a CPU model expansion cpu config: factor out whether hv-evmcs is enabled for a CPU vendor migrate: block live migration of host CPU VMs between CPU vendors fix #6535: migrate: warn about live migration between CPU vendors 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: block live migration if the target cannot run the virtual CPU api: migrate: check the CPU of the target before requesting HA migration .gitignore | 1 + src/PVE/API2/Qemu.pm | 143 +++++- src/PVE/QemuMigrate.pm | 12 +- src/PVE/QemuMigrate/Helpers.pm | 600 ++++++++++++++++++++++ src/PVE/QemuServer.pm | 9 +- src/PVE/QemuServer/CPUConfig.pm | 16 +- src/PVE/QemuServer/CPUFlags.pm | 72 +-- src/PVE/QemuServer/Helpers.pm | 34 ++ src/test/MigrationTest/QemuMigrateMock.pm | 67 +++ src/test/run_api_tests.pl | 389 +++++++++++++- src/test/run_qemu_migrate_tests.pl | 551 ++++++++++++++++++++ 11 files changed, 1836 insertions(+), 58 deletions(-) manager: Jonas Theisen (6): pvestatd: broadcast the supported CPU flags again if they got lost 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 api: cluster: bulk migrate: skip VMs whose CPU is incompatible with the target PVE/API2/Cluster/BulkAction/Guest.pm | 15 +++++++ PVE/API2/Nodes.pm | 5 +++ PVE/Service/pvestatd.pm | 38 +++++++++++++----- www/manager6/window/Migrate.js | 60 ++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 10 deletions(-) docs: Jonas Theisen (1): qm: document the CPU checks for live migration qm.adoc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) Summary over all repositories: 16 files changed, 1990 insertions(+), 68 deletions(-) -- Generated by murpp 0.12.1