all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM
@ 2026-11-18 15:40 Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 01/15] test: migration: allow checking for warnings and errors in the log Jonas Theisen
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

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.
- abstracted CPU configuration (custom model, 'nested-virt', ...), where
  the target keeps the running QEMU CPU: KVM on the target does not
  support an enabled Hyper-V enlightenment (for example the Intel-only
  'hv-evmcs' on an AMD target), or any enabled flag with 'enforce'
- new 'hv-reenlightenment' flag, 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.

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.

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 'host-cpu-flags' override option relies on the HA stack accepting
forwarded migration options, as introduced for 'with-conntrack-state'
and 'skip-config-check'.

Testing:

The checks can be tested on a cluster with identical CPUs by making the
target node broadcast different CPU information. 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","tsc-khz":3000000,"tsc-scaling":0}))'

The 'cpuflags-kvm' entry is only broadcast again when the QEMU version
changes, so it can be changed while pvestatd runs, for example to
remove some flags:

  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};
      $flags = join(" ", grep { !/^(avx512f|sha-ni)$/ } split(/ /, $flags));
      PVE::Cluster::broadcast_node_kv("cpuflags-kvm", $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:

  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', a warning for other CPU types
- a different 'model-name': a warning for CPU type 'host'
- 'tsc-scaling' 0 and a 'tsc-khz' more than 250 ppm off: blocked for
  VMs with 'flags=+hv-reenlightenment'
- flags removed from 'cpuflags-kvm': blocked for CPU type 'host',
  unless '--allow-missing-cpu-flags' is set, also for HA-managed VMs
- 'hv-*' flags removed that a VM with a kept virtual CPU uses, for
  example 'hv-stimer' for 'x86-64-v2-AES,flags=+hv-reenlightenment'
  with ostype 'win11': blocked, without override
- an empty 'host-cpu-info' value: a 'missing-cpu-info' warning for VMs
  where a blocking check needs the information


qemu-server:

Jonas Theisen (11):
  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 kept virtual CPU
  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

 src/PVE/API2/Qemu.pm                          | 104 ++-
 src/PVE/QemuMigrate.pm                        |  39 +-
 src/PVE/QemuMigrate/Helpers.pm                | 329 +++++++++
 src/PVE/QemuServer/CPUConfig.pm               |  18 +
 src/PVE/QemuServer/CPUFlags.pm                |  29 +-
 src/PVE/QemuServer/Helpers.pm                 |  99 +++
 src/test/MigrationTest/QemuMigrateMock.pm     |  36 +
 src/test/QemuServerTest/CommandLineMocks.pm   |   3 +
 src/test/cfg2cmd/cpu-hv-reenlightenment.conf  |   6 +
 .../cfg2cmd/cpu-hv-reenlightenment.conf.cmd   |  26 +
 src/test/run_qemu_migrate_tests.pl            | 685 ++++++++++++++++++
 11 files changed, 1366 insertions(+), 8 deletions(-)
 create mode 100644 src/test/cfg2cmd/cpu-hv-reenlightenment.conf
 create mode 100644 src/test/cfg2cmd/cpu-hv-reenlightenment.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        | 21 ++++++++++++
 www/manager6/window/Migrate.js | 63 ++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)


Summary over all repositories:
  14 files changed, 1455 insertions(+), 8 deletions(-)

-- 
Generated by murpp 0.12.1




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 01/15] test: migration: allow checking for warnings and errors in the log
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 02/15] migrate: block live migration of host CPU VMs between CPU vendors Jonas Theisen
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

So far, the log is only checked for the error message of a migration
that is expected to fail. Allow tests to also check that a migration
logs certain warnings, as the migration continues in these cases and
the result alone does not show whether the warning was issued.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/test/run_qemu_migrate_tests.pl | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/test/run_qemu_migrate_tests.pl b/src/test/run_qemu_migrate_tests.pl
index 598c1306..9e27d10e 100755
--- a/src/test/run_qemu_migrate_tests.pl
+++ b/src/test/run_qemu_migrate_tests.pl
@@ -534,6 +534,8 @@ my $tests = [
     #                  to be made if the migration gets far enough
     # expect_die     - expect the migration call to fail, and an error message
     #                  matching the specified text in the log
+    # expect_log     - list of texts that each must be present in a warning or
+    #                  error message in the log
     # expected       - hash consisting of:
     #                  source_volids    - hash of volids expected on the source
     #                  target_volids    - hash of volids expected on the target
@@ -1919,6 +1921,15 @@ foreach my $test (@{$tests}) {
         note("mocked migrate call failed, but it was not expected - check log");
     }
 
+    if (my $expect_log = $test->{expect_log}) {
+        my @lines = split(/\n/, file_get_contents("${run_dir}/log"));
+        for my $text ($expect_log->@*) {
+            next if grep { m/^(?:err|warn):.*\Q${text}\E/ } @lines;
+            fail($name);
+            note("expected message '$text' is not present in log");
+        }
+    }
+
     my $expected_calls = decode_json(file_get_contents("${run_dir}/expected_calls"));
     foreach my $call (keys %{$expected_calls}) {
         fail($name);
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 02/15] migrate: block live migration of host CPU VMs between CPU vendors
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 01/15] test: migration: allow checking for warnings and errors in the log Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 03/15] fix #6535: migrate: warn about live migration " Jonas Theisen
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

The 'host' and 'max' CPU models pass the features of the host CPU
through to the guest, including vendor-specific ones. A guest that was
started on an AMD CPU is likely to crash after a live migration to an
Intel CPU, or vice versa, as the CPU it detected during boot changed
underneath it.

Check this before the migration, based on CPU information that each
node broadcasts to the cluster as the 'host-cpu-info' node key-value
entry, which pvestatd needs to do. Report such nodes as not allowed in
the migration precondition API, so they can be shown as such before
the migration is started, and refuse to migrate to them. Nodes that do
not broadcast the information, for example because they run an older
version, are not blocked, as it is unknown whether they are
compatible, but a warning is logged. It counts as a task warning, so
that the task status shows it, as the task log is often not read when
a migration succeeds.

The checks are defined in a list, so that further combinations of VM
CPU settings and node CPUs that cannot work, or are known to be prone
to problems, can be added easily. They are only done for running VMs,
as stopped VMs are started with a virtual CPU based on the target
node, and operate on the QEMU CPU of the running instance, so they
also apply to settings from custom CPU models. With TCG, the 'max'
model is fully emulated and therefore not affected.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/API2/Qemu.pm                      |  41 ++++++-
 src/PVE/QemuMigrate.pm                    |  19 +++
 src/PVE/QemuMigrate/Helpers.pm            | 141 ++++++++++++++++++++++
 src/PVE/QemuServer/Helpers.pm             |  31 +++++
 src/test/MigrationTest/QemuMigrateMock.pm |  32 +++++
 src/test/run_qemu_migrate_tests.pl        | 114 +++++++++++++++++
 6 files changed, 377 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index e0661738..0210dd1c 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -5508,6 +5508,27 @@ __PACKAGE__->register_method({
                                 description => 'The config key of a mapped resource',
                             },
                         },
+                        'incompatible-cpu' => {
+                            description =>
+                                "Reasons why the node's CPU cannot run the running VM"
+                                . " after a live migration.",
+                            type => 'array',
+                            optional => 1,
+                            items => {
+                                type => 'object',
+                                properties => {
+                                    type => {
+                                        type => 'string',
+                                        description => "The check that failed.",
+                                        enum => ['cpu-vendor'],
+                                    },
+                                    message => {
+                                        type => 'string',
+                                        description => "Why the node's CPU is incompatible.",
+                                    },
+                                },
+                            },
+                        },
                         'blocking-ha-resources' => {
                             description => "HA resources, which are blocking the"
                                 . " VM from being migrated to the node.",
@@ -5623,7 +5644,8 @@ __PACKAGE__->register_method({
         # try to detect errors early
         PVE::QemuConfig->check_lock($vmconf);
 
-        $res->{running} = PVE::QemuServer::check_running($vmid) ? 1 : 0;
+        my $pid = PVE::QemuServer::check_running($vmid);
+        $res->{running} = $pid ? 1 : 0;
 
         my ($local_resources, $mapped_resources, $missing_mappings_by_node) =
             PVE::QemuMigrate::Helpers::check_local_resources($vmconf, $res->{running}, 1);
@@ -5651,6 +5673,16 @@ __PACKAGE__->register_method({
         }
 
         my $nodelist = PVE::Cluster::get_nodelist();
+
+        my $cpu_issues_by_node = eval {
+            my $targets = [grep { $_ ne $localnode } $nodelist->@*];
+            my ($issues) = PVE::QemuMigrate::Helpers::check_target_cpu_compatibility(
+                $vmconf, $pid, $targets,
+            );
+            return $issues;
+        } // {};
+        warn "unable to check CPU compatibility of target nodes - $@" if $@;
+
         for my $node ($nodelist->@*) {
             next if $node eq $localnode;
 
@@ -5666,6 +5698,13 @@ __PACKAGE__->register_method({
                     $missing_mappings;
             }
 
+            my @cpu_errors =
+                grep { $_->{severity} eq 'error' } ($cpu_issues_by_node->{$node} // [])->@*;
+            if (scalar(@cpu_errors)) {
+                $res->{not_allowed_nodes}->{$node}->{'incompatible-cpu'} =
+                    [map { { type => $_->{type}, message => $_->{message} } } @cpu_errors];
+            }
+
             # extracting blocking resources for current node
             if (my $blocking_ha_resources = $blocking_ha_resources_by_node->{$node}) {
                 $res->{not_allowed_nodes}->{$node}->{'blocking-ha-resources'} =
diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm
index 2d362140..cf01b2eb 100644
--- a/src/PVE/QemuMigrate.pm
+++ b/src/PVE/QemuMigrate.pm
@@ -17,6 +17,7 @@ use PVE::GuestHelpers qw(safe_boolean_ne safe_string_ne);
 use PVE::GuestID;
 use PVE::INotify;
 use PVE::JSONSchema;
+use PVE::RESTEnvironment qw(log_warn);
 use PVE::RPCEnvironment;
 use PVE::Replication;
 use PVE::ReplicationConfig;
@@ -315,6 +316,24 @@ sub prepare {
         }
     }
 
+    # nodes of other clusters do not broadcast their CPU information to this cluster
+    if (!$self->{opts}->{remote}) {
+        my $node = $self->{node};
+        my ($cpu_issues, $unchecked_nodes) =
+            PVE::QemuMigrate::Helpers::check_target_cpu_compatibility($conf, $running, [$node]);
+
+        my @errors = grep { $_->{severity} eq 'error' } ($cpu_issues->{$node} // [])->@*;
+        if (scalar(@errors)) {
+            die "can't migrate VM to '$node' - incompatible CPU: "
+                . join('; ', map { $_->{message} } @errors) . "\n";
+        }
+
+        if (scalar($unchecked_nodes->@*)) {
+            log_warn("unable to check CPU compatibility of node '$node' - CPU information not"
+                . " available");
+        }
+    }
+
     my $vollist = PVE::QemuServer::get_vm_volumes($conf);
 
     my $storages = {};
diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm
index 466517da..f4f15b96 100644
--- a/src/PVE/QemuMigrate/Helpers.pm
+++ b/src/PVE/QemuMigrate/Helpers.pm
@@ -6,11 +6,15 @@ use warnings;
 use JSON;
 
 use PVE::Cluster;
+use PVE::INotify;
 use PVE::JSONSchema qw(parse_property_string);
 use PVE::Mapping::Dir;
 use PVE::Mapping::PCI;
 use PVE::Mapping::USB;
 
+use PVE::QemuServer::CPUConfig;
+use PVE::QemuServer::CPUFlags;
+use PVE::QemuServer::Helpers;
 use PVE::QemuServer::Monitor qw(mon_cmd);
 use PVE::QemuServer::Virtiofs;
 
@@ -113,6 +117,143 @@ sub check_local_resources {
     return wantarray ? (\@loc_res, $mapped_res, $missing_mappings_by_node) : \@loc_res;
 }
 
+# Returns the CPU information the node broadcasts, see get_host_cpu_info() in
+# PVE::QemuServer::Helpers. Information the node does not broadcast is missing.
+my sub get_node_cpu_info {
+    my ($node) = @_;
+
+    my $raw = PVE::Cluster::get_node_kv('host-cpu-info', $node)->{$node};
+    my $info = defined($raw) ? eval { decode_json($raw) } : undef;
+
+    return ref($info) eq 'HASH' ? $info : {};
+}
+
+# Parses a QEMU '-cpu' argument into the CPU model and its properties. Flags given without a value
+# are stored as 'on' or 'off'.
+my sub parse_qemu_cpu_string {
+    my ($cpu_str) = @_;
+
+    my ($model, @options) = split(/,/, $cpu_str);
+
+    my $props = {};
+    for my $option (@options) {
+        my ($op, $name, $value) = $option =~ m/^([+-]?)([^=]+)(?:=(.*))?$/ or next;
+        # QEMU accepts both underscores and dashes in property names, and some aliases
+        $name =~ s/_/-/g;
+        $name = PVE::QemuServer::CPUFlags::normalize_cpu_flag($name);
+        $value = $op eq '-' ? 'off' : 'on' if !defined($value);
+        $props->{$name} = $value;
+    }
+
+    return { model => $model, props => $props };
+}
+
+my sub is_host_cpu_model {
+    my ($cpu) = @_;
+    # with TCG, 'max' is fully emulated instead of passing through the host CPU
+    return $cpu->{model} eq 'host' || ($cpu->{model} eq 'max' && $cpu->{kvm});
+}
+
+my sub vendors_differ {
+    my ($source, $target) = @_;
+
+    my ($source_vendor, $target_vendor) = ($source->{vendor}, $target->{vendor});
+    return defined($source_vendor) && defined($target_vendor) && $source_vendor ne $target_vendor;
+}
+
+# Checks whether the CPU of a target node can run a running VM after a live migration.
+#
+# 'applies' returns true if the check is relevant for the VM's CPU, as parsed by
+# parse_qemu_cpu_string(), with 'kvm' set if the VM uses KVM. 'needs' lists the CPU information
+# of the target node the check requires, nodes lacking any of it are skipped. 'check' returns why
+# the target node is incompatible, if it is. With the 'error' severity, an incompatibility
+# prevents the migration, with 'warning' it is only reported.
+my $target_cpu_checks = [
+    {
+        type => 'cpu-vendor',
+        severity => 'error',
+        needs => ['vendor'],
+        applies => sub {
+            my ($cpu) = @_;
+            # these models pass through the host CPU, including vendor-specific features
+            return is_host_cpu_model($cpu);
+        },
+        check => sub {
+            my ($cpu, $source, $target) = @_;
+
+            return if !vendors_differ($source, $target);
+
+            return "CPU model '$cpu->{model}' requires the same CPU vendor as on the source"
+                . " node ($source->{vendor}), but the node has $target->{vendor}";
+        },
+    },
+];
+
+# Returns the issues of the target node, and whether all checks that can prevent the migration
+# were done.
+my sub get_target_cpu_issues {
+    my ($cpu, $checks, $source_info, $target_info) = @_;
+
+    my ($issues, $complete) = ([], 1);
+    for my $check ($checks->@*) {
+        if (grep { !defined($target_info->{$_}) } $check->{needs}->@*) {
+            $complete = 0 if $check->{severity} eq 'error';
+            next;
+        }
+
+        my $message = $check->{check}->($cpu, $source_info, $target_info) or next;
+        push $issues->@*,
+            { type => $check->{type}, severity => $check->{severity}, message => $message };
+    }
+
+    return ($issues, $complete);
+}
+
+=head3 check_target_cpu_compatibility
+
+    my ($issues_by_node, $unchecked_nodes) = check_target_cpu_compatibility($conf, $pid, $nodes);
+
+Checks whether the VM with the configuration C<$conf>, running with the process ID C<$pid>, can
+run with its current virtual CPU on each node of C<$nodes>, based on the CPU information the
+nodes broadcast. Only applies to running VMs, as stopped VMs are started with a virtual CPU
+matching the target node.
+
+Returns a hash reference with the list of issues for each node that has any, and an array
+reference with the nodes that could not be checked for issues preventing the migration, because
+they lack the required CPU information, for example as they run an older version. Each issue is
+a hash with a C<type> identifying the check, a C<severity> of C<error> if the VM cannot run on
+the node or C<warning> if it might not, and a human-readable C<message>.
+
+=cut
+
+sub check_target_cpu_compatibility {
+    my ($conf, $pid, $nodes) = @_;
+
+    return ({}, []) if !$pid;
+
+    my $cpu = parse_qemu_cpu_string(PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid));
+    $cpu->{kvm} = $conf->{kvm} // 1;
+
+    my $checks = [grep { $_->{applies}->($cpu) } $target_cpu_checks->@*];
+    return ({}, []) if !scalar($checks->@*);
+
+    # Use what this node broadcasts, as for the target nodes. The local pvestatd might not
+    # broadcast it yet, for example if it was not restarted after an upgrade.
+    my $source_info = get_node_cpu_info(PVE::INotify::nodename());
+    $source_info = PVE::QemuServer::Helpers::get_host_cpu_info() if !scalar(keys $source_info->%*);
+
+    my ($issues_by_node, $unchecked_nodes) = ({}, []);
+    for my $node ($nodes->@*) {
+        my $target_info = get_node_cpu_info($node);
+
+        my ($issues, $complete) = get_target_cpu_issues($cpu, $checks, $source_info, $target_info);
+        $issues_by_node->{$node} = $issues if scalar($issues->@*);
+        push $unchecked_nodes->@*, $node if !$complete;
+    }
+
+    return ($issues_by_node, $unchecked_nodes);
+}
+
 sub set_migration_caps {
     my ($vmid, $savevm) = @_;
 
diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm
index 5efe7736..14f822cc 100644
--- a/src/PVE/QemuServer/Helpers.pm
+++ b/src/PVE/QemuServer/Helpers.pm
@@ -359,4 +359,35 @@ sub get_host_phys_address_bits {
     return; # undef, cannot really do anything..
 }
 
+=head3 get_host_cpu_info
+
+    my $info = get_host_cpu_info();
+
+Returns the properties of this host's CPU that decide whether a running VM can be live-migrated
+to it. pvestatd broadcasts them to the cluster as the C<host-cpu-info> node key-value entry,
+encoded as JSON. The returned hash contains:
+
+=over
+
+=item C<vendor>: the CPU vendor ID, for example C<GenuineIntel> or C<AuthenticAMD>
+
+=back
+
+Properties that cannot be determined are missing. Consumers of the broadcast information must
+also handle properties that nodes running an older version do not provide yet.
+
+=cut
+
+sub get_host_cpu_info {
+    my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
+
+    # read_cpuinfo() reports values it cannot determine as 'unknown'
+    my $known = sub { defined($_[0]) && $_[0] ne 'unknown' };
+
+    my $info = {};
+    $info->{vendor} = $cpuinfo->{vendor} if $known->($cpuinfo->{vendor});
+
+    return $info;
+}
+
 1;
diff --git a/src/test/MigrationTest/QemuMigrateMock.pm b/src/test/MigrationTest/QemuMigrateMock.pm
index cf1fde38..459a29a1 100644
--- a/src/test/MigrationTest/QemuMigrateMock.pm
+++ b/src/test/MigrationTest/QemuMigrateMock.pm
@@ -31,6 +31,7 @@ my $migrate_params = decode_json(file_get_contents("${RUN_DIR_PATH}/migrate_para
 my $test_vmid = $migrate_params->{vmid};
 my $test_target = $migrate_params->{target};
 my $test_opts = $migrate_params->{opts};
+my $test_cpu_info = $migrate_params->{cpu_info} // {};
 my $current_log = '';
 
 my $vm_stop_executed = 0;
@@ -110,6 +111,10 @@ $qemu_migrate_module->mock(
         my ($self, $level, $message) = @_;
         $current_log .= "$level: $message\n";
     },
+    log_warn => sub {
+        my ($message) = @_;
+        $current_log .= "warn: $message\n";
+    },
     mon_cmd => sub {
         my ($vmid, $command, %params) = @_;
 
@@ -219,8 +224,35 @@ $qemu_server_cpuconfig_module->mock(
     },
 );
 
+$MigrationTest::Shared::qemu_migrate_helpers_module->mock(
+    check_target_cpu_compatibility => sub {
+        my ($conf, $pid, $nodes) = @_;
+        # checking requires the running CPU, which most tests do not need to specify
+        return ({}, []) if $pid && !defined($vm_status->{runningcpu});
+        return $MigrationTest::Shared::qemu_migrate_helpers_module->original(
+            'check_target_cpu_compatibility')->(@_);
+    },
+);
+
+$MigrationTest::Shared::cluster_module->mock(
+    get_node_kv => sub {
+        my ($key, $node) = @_;
+        if ($key eq 'host-cpu-info') {
+            # the source node is 'pve0', without 'source' get_host_cpu_info() is used
+            my $info =
+                $node eq 'pve0' ? $test_cpu_info->{source} : $test_cpu_info->{nodes}->{$node};
+            return {} if !$info;
+            return { $node => encode_json($info) };
+        }
+        return {};
+    },
+);
+
 my $qemu_server_helpers_module = Test::MockModule->new("PVE::QemuServer::Helpers");
 $qemu_server_helpers_module->mock(
+    get_host_cpu_info => sub {
+        return $test_cpu_info->{source} // { vendor => 'GenuineIntel' };
+    },
     vm_running_locally => sub {
         return $vm_status->{running} && !$vm_stop_executed;
     },
diff --git a/src/test/run_qemu_migrate_tests.pl b/src/test/run_qemu_migrate_tests.pl
index 9e27d10e..1084123b 100755
--- a/src/test/run_qemu_migrate_tests.pl
+++ b/src/test/run_qemu_migrate_tests.pl
@@ -530,6 +530,8 @@ my $tests = [
     # opts           - options for the migrate() call
     # target_volids  - hash of volids on the target at the beginning
     # vm_status      - hash with running, runningmachine and optionally runningcpu
+    # cpu_info       - hash with the CPU information of the 'source' node and of each
+    #                  other node in 'nodes'
     # expected_calls - hash whose keys are calls which are required
     #                  to be made if the migration gets far enough
     # expect_die     - expect the migration call to fail, and an error message
@@ -1454,6 +1456,117 @@ my $tests = [
             },
         },
     },
+    {
+        name => '1033_running_host_cpu_other_vendor',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+        },
+        cpu_info => {
+            source => { vendor => 'AuthenticAMD' },
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel' },
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'host',
+        },
+        expected_calls => {},
+        expect_die => "can't migrate VM to 'pve1' - incompatible CPU: CPU model 'host' requires"
+            . " the same CPU vendor as on the source node (AuthenticAMD), but the node has"
+            . " GenuineIntel",
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'host',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+            },
+        },
+    },
+    {
+        name => '1033_running_host_cpu_target_without_cpu_info',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+        },
+        cpu_info => {
+            source => { vendor => 'AuthenticAMD' },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'host',
+        },
+        expected_calls => $default_expected_calls_online,
+        expect_log => [
+            "unable to check CPU compatibility of node 'pve1' - CPU information not available",
+        ],
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'host',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+            },
+        },
+    },
+    {
+        name => '1033_running_max_cpu_tcg_other_vendor',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'max',
+        },
+        cpu_info => {
+            source => { vendor => 'AuthenticAMD' },
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel' },
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'max',
+            kvm => 0,
+        },
+        expected_calls => $default_expected_calls_online,
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(
+                1033,
+                {
+                    cpu => 'max',
+                    kvm => 0,
+                },
+            ),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+            },
+        },
+    },
     {
         name => '105_replicated_to_non_replication_target',
         target => 'pve1',
@@ -1875,6 +1988,7 @@ foreach my $test (@{$tests}) {
         target => $test->{target},
         vmid => $test->{vmid},
         opts => $test->{opts},
+        cpu_info => $test->{cpu_info},
     };
 
     file_set_contents("${run_dir}/nbd_info", to_json({}));
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 03/15] fix #6535: migrate: warn about live migration between CPU vendors
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 01/15] test: migration: allow checking for warnings and errors in the log Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 02/15] migrate: block live migration of host CPU VMs between CPU vendors Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 04/15] cpu flags: factor out parsing the broadcast CPU flags of a node Jonas Theisen
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

Live migrating a VM between nodes with CPUs from different vendors is
not guaranteed to work, even with generic CPU models that do not pass
through vendor-specific features, as the CPUs still behave differently
in some regards.

Warn about this in the migration task, as a task warning so that the
task status shows it, and report it for each node in the migration
precondition API, so that it can be shown before the migration is
started. As before, VMs with the 'host' or 'max' CPU model cannot be
live migrated between vendors at all.

Also report nodes that lack the CPU information needed for a check
that would block the migration as a warning in the precondition API,
as the task log only shows this once the migration is started. This
is not done for other checks, to not warn about every live migration
to nodes running an older version.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/API2/Qemu.pm               | 42 +++++++++++++++++++++++++++---
 src/PVE/QemuMigrate.pm             |  9 ++++++-
 src/PVE/QemuMigrate/Helpers.pm     | 19 ++++++++++++++
 src/test/run_qemu_migrate_tests.pl | 33 +++++++++++++++++++++++
 4 files changed, 99 insertions(+), 4 deletions(-)

diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index 0210dd1c..9d7fcf8b 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -5604,6 +5604,29 @@ __PACKAGE__->register_method({
                 description =>
                     "Object of mapped resources with additional information such if they're live migratable.",
             },
+            'cpu-warnings' => {
+                type => 'object',
+                optional => 1,
+                description => "For each node, reasons why the VM might not run reliably on its"
+                    . " CPU after a live migration.",
+                additionalProperties => {
+                    type => 'array',
+                    items => {
+                        type => 'object',
+                        properties => {
+                            type => {
+                                type => 'string',
+                                description => "The check that reported the warning.",
+                                enum => ['cpu-vendor', 'missing-cpu-info'],
+                            },
+                            message => {
+                                type => 'string',
+                                description => "Why the VM might not run reliably.",
+                            },
+                        },
+                    },
+                },
+            },
             'has-dbus-vmstate' => {
                 type => 'boolean',
                 description => 'Whether the VM host supports migrating additional VM state, '
@@ -5676,9 +5699,15 @@ __PACKAGE__->register_method({
 
         my $cpu_issues_by_node = eval {
             my $targets = [grep { $_ ne $localnode } $nodelist->@*];
-            my ($issues) = PVE::QemuMigrate::Helpers::check_target_cpu_compatibility(
-                $vmconf, $pid, $targets,
-            );
+            my ($issues, $unchecked_nodes) =
+                PVE::QemuMigrate::Helpers::check_target_cpu_compatibility($vmconf, $pid, $targets);
+            my $message = "the node does not provide CPU information, for example as it runs"
+                . " an older version";
+            for my $node ($unchecked_nodes->@*) {
+                my $issue =
+                    { type => 'missing-cpu-info', severity => 'warning', message => $message };
+                push $issues->{$node}->@*, $issue;
+            }
             return $issues;
         } // {};
         warn "unable to check CPU compatibility of target nodes - $@" if $@;
@@ -5705,6 +5734,13 @@ __PACKAGE__->register_method({
                     [map { { type => $_->{type}, message => $_->{message} } } @cpu_errors];
             }
 
+            my @cpu_warnings =
+                grep { $_->{severity} eq 'warning' } ($cpu_issues_by_node->{$node} // [])->@*;
+            if (scalar(@cpu_warnings)) {
+                $res->{'cpu-warnings'}->{$node} =
+                    [map { { type => $_->{type}, message => $_->{message} } } @cpu_warnings];
+            }
+
             # extracting blocking resources for current node
             if (my $blocking_ha_resources = $blocking_ha_resources_by_node->{$node}) {
                 $res->{not_allowed_nodes}->{$node}->{'blocking-ha-resources'} =
diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm
index cf01b2eb..827f8143 100644
--- a/src/PVE/QemuMigrate.pm
+++ b/src/PVE/QemuMigrate.pm
@@ -322,7 +322,14 @@ sub prepare {
         my ($cpu_issues, $unchecked_nodes) =
             PVE::QemuMigrate::Helpers::check_target_cpu_compatibility($conf, $running, [$node]);
 
-        my @errors = grep { $_->{severity} eq 'error' } ($cpu_issues->{$node} // [])->@*;
+        my @errors;
+        for my $issue (($cpu_issues->{$node} // [])->@*) {
+            if ($issue->{severity} eq 'warning') {
+                log_warn("CPU of node '$node' might be incompatible: $issue->{message}");
+            } else {
+                push @errors, $issue;
+            }
+        }
         if (scalar(@errors)) {
             die "can't migrate VM to '$node' - incompatible CPU: "
                 . join('; ', map { $_->{message} } @errors) . "\n";
diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm
index f4f15b96..4e4e3ae0 100644
--- a/src/PVE/QemuMigrate/Helpers.pm
+++ b/src/PVE/QemuMigrate/Helpers.pm
@@ -187,6 +187,25 @@ my $target_cpu_checks = [
                 . " node ($source->{vendor}), but the node has $target->{vendor}";
         },
     },
+    {
+        type => 'cpu-vendor',
+        severity => 'warning',
+        needs => ['vendor'],
+        applies => sub {
+            my ($cpu) = @_;
+            return $cpu->{kvm} && !is_host_cpu_model($cpu);
+        },
+        check => sub {
+            my ($cpu, $source, $target) = @_;
+
+            return if !vendors_differ($source, $target);
+
+            # even generic CPU models expose behavior that differs between vendors
+            return
+                "live migration from $source->{vendor} to $target->{vendor} is not guaranteed"
+                . " to work, as guests can become unstable, even some time after the migration";
+        },
+    },
 ];
 
 # Returns the issues of the target node, and whether all checks that can prevent the migration
diff --git a/src/test/run_qemu_migrate_tests.pl b/src/test/run_qemu_migrate_tests.pl
index 1084123b..12ec3e90 100755
--- a/src/test/run_qemu_migrate_tests.pl
+++ b/src/test/run_qemu_migrate_tests.pl
@@ -1567,6 +1567,39 @@ my $tests = [
             },
         },
     },
+    {
+        name => '1033_running_kvm64_cpu_other_vendor',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'kvm64,enforce,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep',
+        },
+        cpu_info => {
+            source => { vendor => 'AuthenticAMD' },
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel' },
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        expected_calls => $default_expected_calls_online,
+        expect_log => [
+            "CPU of node 'pve1' might be incompatible: live migration from AuthenticAMD to"
+                . " GenuineIntel is not guaranteed to work",
+        ],
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => $vm_configs->{1033},
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+            },
+        },
+    },
     {
         name => '105_replicated_to_non_replication_target',
         target => 'pve1',
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 04/15] cpu flags: factor out parsing the broadcast CPU flags of a node
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (2 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH qemu-server 03/15] fix #6535: migrate: warn about live migration " Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 05/15] fix #2924: migrate: block live migration of host CPU VMs to nodes lacking flags Jonas Theisen
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

The CPU flags that pvestatd broadcasts need to be normalized, as nodes
running an older version also broadcast aliases of some flags, for
example 'sse4_2' and 'sse4-2' in addition to 'sse4.2'.

Factor this out, so that other users of the broadcast flags cannot
forget about it.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/QemuServer/CPUFlags.pm | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/PVE/QemuServer/CPUFlags.pm b/src/PVE/QemuServer/CPUFlags.pm
index 0d3206b2..0ba2e115 100644
--- a/src/PVE/QemuServer/CPUFlags.pm
+++ b/src/PVE/QemuServer/CPUFlags.pm
@@ -145,6 +145,20 @@ sub normalize_cpu_flag($flag) {
     return $qemu_cpu_flag_alias_map->{$flag} // $flag;
 }
 
+=head3 parse_node_cpu_flags($raw)
+
+Parse the CPU flags of a node, as C<pvestatd> broadcasts them in the C<cpuflags-$accel> node
+key-value entries, and return them normalized with C<normalize_cpu_flag()>.
+
+The broadcast format may differ from the current one, for example if the node runs an older
+version, which also broadcast the aliases of some flags.
+
+=cut
+
+sub parse_node_cpu_flags($raw) {
+    return map { normalize_cpu_flag($_) } split(' ', $raw);
+}
+
 # Understood CPU flags are written to a file at 'pve-qemu' compile time and
 # shipped below this directory by the pve-qemu-kvm package.
 my $understood_cpu_flag_dir = "/usr/share/kvm";
@@ -295,12 +309,7 @@ sub query_available_cpu_flags($accel, $vm_specific, $arch) {
     };
 
     for my $node (keys %$flags) {
-        # This depends on `pvestatd` storing the flags in space-separated format, which
-        # is the case at the time of this commit.
-        for (split(' ', $flags->{$node})) {
-            # normalize as pvestatd's stored format may drift relative to the recognized
-            # flag list, e.g. across upgrades or between QEMU CPUID-flag aliases.
-            my $flag = normalize_cpu_flag($_);
+        for my $flag (parse_node_cpu_flags($flags->{$node})) {
             my $pve_alias = undef;
             $pve_alias = 'nested-virt' if $flag eq 'svm' || $flag eq 'vmx';
             next if $vm_specific && !flag_is_vm_specific($flag) && !$pve_alias;
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 05/15] fix #2924: migrate: block live migration of host CPU VMs to nodes lacking flags
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (3 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH qemu-server 04/15] cpu flags: factor out parsing the broadcast CPU flags of a node Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 06/15] migrate: warn about live migration of host CPU VMs between CPU models Jonas Theisen
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

The 'host' and 'max' CPU models pass the flags of the host CPU through
to the guest. If the target node's CPU lacks flags that the guest might
use, the live migration often fails only near its end, with QEMU on the
target failing to set the special registers of the vCPUs, or the guest
runs into problems after the migration.

Compare the CPU flags that KVM supports on the source and the target
node, which pvestatd already broadcasts, and refuse the migration if
the target lacks any. Flags explicitly disabled for the VM and Hyper-V
enlightenments, which are not passed through, are ignored. As the
flags are broadcast independently of the other CPU information, this
also works for target nodes running an older version. The flags are
normalized, as nodes that did not query them again since an upgrade
can still broadcast aliases of some flags.

The flags of the source node are only an approximation of the flags of
the VM, as it might have been started on another node, and the flags
KVM supports also depend on the kernel version. So allow root to
override the check with the new 'allow-missing-cpu-flags' option. The
existing 'force' option is not reused for this, as the HA stack always
sets it, which would skip the check for all HA-managed VMs. Instead,
the new option is forwarded to the HA stack like other migration
options, so that it also applies to HA-managed VMs.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/API2/Qemu.pm                      |  28 ++-
 src/PVE/QemuMigrate.pm                    |  13 +-
 src/PVE/QemuMigrate/Helpers.pm            |  77 +++++++-
 src/test/MigrationTest/QemuMigrateMock.pm |   4 +
 src/test/run_qemu_migrate_tests.pl        | 212 +++++++++++++++++++++-
 5 files changed, 322 insertions(+), 12 deletions(-)

diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index 9d7fcf8b..aaaa8760 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -155,6 +155,13 @@ my $migrate_json_properties = {
             . ' successfully by the target. Using this flag can lead to dropped'
             . ' configuration options if the target is too old to parse them.',
     },
+    'allow-missing-cpu-flags' => {
+        type => 'boolean',
+        optional => 1,
+        default => 0,
+        description => "Allow live migration of VMs with CPU type 'host' or 'max' to nodes"
+            . " lacking CPU flags of this node. Only root may use this option.",
+    },
 };
 
 # Properties that will be forwarded via the HA stack to the LRM, which will then use them for its
@@ -163,6 +170,7 @@ my $migrate_json_properties = {
 my $ha_migrate_props = {
     'with-conntrack-state' => 1,
     'skip-config-check' => 1,
+    'allow-missing-cpu-flags' => 1,
 };
 
 sub ha_migrate_json_properties {
@@ -5520,12 +5528,18 @@ __PACKAGE__->register_method({
                                     type => {
                                         type => 'string',
                                         description => "The check that failed.",
-                                        enum => ['cpu-vendor'],
+                                        enum => ['cpu-vendor', 'host-cpu-flags'],
                                     },
                                     message => {
                                         type => 'string',
                                         description => "Why the node's CPU is incompatible.",
                                     },
+                                    override => {
+                                        type => 'string',
+                                        optional => 1,
+                                        description => "The migration option that allows"
+                                            . " ignoring the incompatibility.",
+                                    },
                                 },
                             },
                         },
@@ -5730,8 +5744,13 @@ __PACKAGE__->register_method({
             my @cpu_errors =
                 grep { $_->{severity} eq 'error' } ($cpu_issues_by_node->{$node} // [])->@*;
             if (scalar(@cpu_errors)) {
-                $res->{not_allowed_nodes}->{$node}->{'incompatible-cpu'} =
-                    [map { { type => $_->{type}, message => $_->{message} } } @cpu_errors];
+                $res->{not_allowed_nodes}->{$node}->{'incompatible-cpu'} = [
+                    map {
+                        my $error = { type => $_->{type}, message => $_->{message} };
+                        $error->{override} = $_->{override} if defined($_->{override});
+                        $error;
+                    } @cpu_errors
+                ];
             }
 
             my @cpu_warnings =
@@ -5806,6 +5825,9 @@ __PACKAGE__->register_method({
         raise_param_exc({ force => "Only root may use this option." })
             if $param->{force} && $authuser ne 'root@pam';
 
+        raise_param_exc({ 'allow-missing-cpu-flags' => "Only root may use this option." })
+            if $param->{'allow-missing-cpu-flags'} && $authuser ne 'root@pam';
+
         raise_param_exc({ migration_type => "Only root may use this option." })
             if $param->{migration_type} && $authuser ne 'root@pam';
 
diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm
index 827f8143..bd157845 100644
--- a/src/PVE/QemuMigrate.pm
+++ b/src/PVE/QemuMigrate.pm
@@ -324,15 +324,26 @@ sub prepare {
 
         my @errors;
         for my $issue (($cpu_issues->{$node} // [])->@*) {
+            my $override = $issue->{override};
             if ($issue->{severity} eq 'warning') {
                 log_warn("CPU of node '$node' might be incompatible: $issue->{message}");
+            } elsif (defined($override) && $self->{opts}->{$override}) {
+                log_warn("ignoring incompatible CPU of node '$node' due to '$override':"
+                    . " $issue->{message}");
             } else {
                 push @errors, $issue;
             }
         }
         if (scalar(@errors)) {
+            my $hint = '';
+            if (!grep { !defined($_->{override}) } @errors) {
+                my %overrides = map { $_->{override} => 1 } @errors;
+                $hint =
+                    " - use " . join(' and ', map { "'$_'" } sort keys %overrides) . " to override";
+            }
             die "can't migrate VM to '$node' - incompatible CPU: "
-                . join('; ', map { $_->{message} } @errors) . "\n";
+                . join('; ', map { $_->{message} } @errors)
+                . "$hint\n";
         }
 
         if (scalar($unchecked_nodes->@*)) {
diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm
index 4e4e3ae0..b13992d1 100644
--- a/src/PVE/QemuMigrate/Helpers.pm
+++ b/src/PVE/QemuMigrate/Helpers.pm
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 
 use JSON;
+use List::Util qw(min);
 
 use PVE::Cluster;
 use PVE::INotify;
@@ -128,6 +129,16 @@ my sub get_node_cpu_info {
     return ref($info) eq 'HASH' ? $info : {};
 }
 
+# Returns the CPU flags KVM supports on the node, as broadcast by pvestatd, if known.
+my sub get_node_kvm_cpu_flags {
+    my ($node) = @_;
+
+    # an empty value means that pvestatd failed to detect the flags
+    my $raw = PVE::Cluster::get_node_kv('cpuflags-kvm', $node)->{$node} or return;
+
+    return { map { $_ => 1 } PVE::QemuServer::CPUFlags::parse_node_cpu_flags($raw) };
+}
+
 # Parses a QEMU '-cpu' argument into the CPU model and its properties. Flags given without a value
 # are stored as 'on' or 'off'.
 my sub parse_qemu_cpu_string {
@@ -161,13 +172,26 @@ my sub vendors_differ {
     return defined($source_vendor) && defined($target_vendor) && $source_vendor ne $target_vendor;
 }
 
+my sub format_flag_list {
+    my ($flags) = @_;
+
+    my $max_listed = 10;
+    my $list = join(', ', $flags->@[0 .. min($max_listed, scalar($flags->@*)) - 1]);
+    $list .= " and " . (scalar($flags->@*) - $max_listed) . " more"
+        if scalar($flags->@*) > $max_listed;
+
+    return $list;
+}
+
 # Checks whether the CPU of a target node can run a running VM after a live migration.
 #
 # 'applies' returns true if the check is relevant for the VM's CPU, as parsed by
 # parse_qemu_cpu_string(), with 'kvm' set if the VM uses KVM. 'needs' lists the CPU information
-# of the target node the check requires, nodes lacking any of it are skipped. 'check' returns why
-# the target node is incompatible, if it is. With the 'error' severity, an incompatibility
-# prevents the migration, with 'warning' it is only reported.
+# of the target node the check requires, nodes lacking any of it are skipped. The CPU information
+# is in the format of get_host_cpu_info(), plus the CPU flags KVM supports as 'kvm-flags' hash.
+# 'check' returns why the target node is incompatible, if it is. With the 'error' severity, an
+# incompatibility prevents the migration, with 'warning' it is only reported. 'override' names
+# the migration option that allows ignoring an error.
 my $target_cpu_checks = [
     {
         type => 'cpu-vendor',
@@ -206,6 +230,40 @@ my $target_cpu_checks = [
                 . " to work, as guests can become unstable, even some time after the migration";
         },
     },
+    {
+        type => 'host-cpu-flags',
+        severity => 'error',
+        # the flags are only known per node, the VM might have been started on another node
+        override => 'allow-missing-cpu-flags',
+        needs => ['kvm-flags'],
+        applies => sub {
+            my ($cpu) = @_;
+            return is_host_cpu_model($cpu);
+        },
+        check => sub {
+            my ($cpu, $source, $target) = @_;
+
+            # already reported by the 'cpu-vendor' check
+            return if vendors_differ($source, $target);
+
+            my ($source_flags, $target_flags) =
+                ($source->{'kvm-flags'}, $target->{'kvm-flags'});
+            return if !$source_flags;
+
+            my @missing = sort grep {
+                # Hyper-V enlightenments are not passed through, but set explicitly
+                !m/^hv-/
+                    && !$target_flags->{$_}
+                    && ($cpu->{props}->{$_} // '') ne 'off'
+            } keys $source_flags->%*;
+            return if !scalar(@missing);
+
+            return
+                "CPU model '$cpu->{model}' passes through the flags of the host CPU, but the"
+                . " node lacks: "
+                . format_flag_list(\@missing);
+        },
+    },
 ];
 
 # Returns the issues of the target node, and whether all checks that can prevent the migration
@@ -221,8 +279,9 @@ my sub get_target_cpu_issues {
         }
 
         my $message = $check->{check}->($cpu, $source_info, $target_info) or next;
-        push $issues->@*,
-            { type => $check->{type}, severity => $check->{severity}, message => $message };
+        my $issue = { type => $check->{type}, severity => $check->{severity}, message => $message };
+        $issue->{override} = $check->{override} if defined($check->{override});
+        push $issues->@*, $issue;
     }
 
     return ($issues, $complete);
@@ -241,7 +300,8 @@ Returns a hash reference with the list of issues for each node that has any, and
 reference with the nodes that could not be checked for issues preventing the migration, because
 they lack the required CPU information, for example as they run an older version. Each issue is
 a hash with a C<type> identifying the check, a C<severity> of C<error> if the VM cannot run on
-the node or C<warning> if it might not, and a human-readable C<message>.
+the node or C<warning> if it might not, and a human-readable C<message>. If a migration option
+allows ignoring an error, C<override> names it.
 
 =cut
 
@@ -258,12 +318,15 @@ sub check_target_cpu_compatibility {
 
     # Use what this node broadcasts, as for the target nodes. The local pvestatd might not
     # broadcast it yet, for example if it was not restarted after an upgrade.
-    my $source_info = get_node_cpu_info(PVE::INotify::nodename());
+    my $local_node = PVE::INotify::nodename();
+    my $source_info = get_node_cpu_info($local_node);
     $source_info = PVE::QemuServer::Helpers::get_host_cpu_info() if !scalar(keys $source_info->%*);
+    $source_info->{'kvm-flags'} = get_node_kvm_cpu_flags($local_node);
 
     my ($issues_by_node, $unchecked_nodes) = ({}, []);
     for my $node ($nodes->@*) {
         my $target_info = get_node_cpu_info($node);
+        $target_info->{'kvm-flags'} = get_node_kvm_cpu_flags($node);
 
         my ($issues, $complete) = get_target_cpu_issues($cpu, $checks, $source_info, $target_info);
         $issues_by_node->{$node} = $issues if scalar($issues->@*);
diff --git a/src/test/MigrationTest/QemuMigrateMock.pm b/src/test/MigrationTest/QemuMigrateMock.pm
index 459a29a1..73e08227 100644
--- a/src/test/MigrationTest/QemuMigrateMock.pm
+++ b/src/test/MigrationTest/QemuMigrateMock.pm
@@ -237,6 +237,10 @@ $MigrationTest::Shared::qemu_migrate_helpers_module->mock(
 $MigrationTest::Shared::cluster_module->mock(
     get_node_kv => sub {
         my ($key, $node) = @_;
+        if ($key eq 'cpuflags-kvm') {
+            my $flags = $test_cpu_info->{'kvm-flags'}->{$node} or return {};
+            return { $node => $flags };
+        }
         if ($key eq 'host-cpu-info') {
             # the source node is 'pve0', without 'source' get_host_cpu_info() is used
             my $info =
diff --git a/src/test/run_qemu_migrate_tests.pl b/src/test/run_qemu_migrate_tests.pl
index 12ec3e90..0e33cfbc 100755
--- a/src/test/run_qemu_migrate_tests.pl
+++ b/src/test/run_qemu_migrate_tests.pl
@@ -531,7 +531,8 @@ my $tests = [
     # target_volids  - hash of volids on the target at the beginning
     # vm_status      - hash with running, runningmachine and optionally runningcpu
     # cpu_info       - hash with the CPU information of the 'source' node and of each
-    #                  other node in 'nodes'
+    #                  other node in 'nodes', and the KVM CPU flags of each node in
+    #                  'kvm-flags'
     # expected_calls - hash whose keys are calls which are required
     #                  to be made if the migration gets far enough
     # expect_die     - expect the migration call to fail, and an error message
@@ -1600,6 +1601,215 @@ my $tests = [
             },
         },
     },
+    {
+        name => '1033_running_host_cpu_missing_flags',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+        },
+        cpu_info => {
+            source => { vendor => 'GenuineIntel' },
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel' },
+            },
+            'kvm-flags' => {
+                pve0 => 'avx512f fpu hv-relaxed sse',
+                pve1 => 'fpu sse',
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'host',
+        },
+        expected_calls => {},
+        expect_die => "can't migrate VM to 'pve1' - incompatible CPU: CPU model 'host' passes"
+            . " through the flags of the host CPU, but the node lacks: avx512f - use"
+            . " 'allow-missing-cpu-flags' to override",
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'host',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+            },
+        },
+    },
+    {
+        # 'force', which the HA stack always sets, must not override the check
+        name => '1033_running_host_cpu_missing_flags_force',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+        },
+        cpu_info => {
+            source => { vendor => 'GenuineIntel' },
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel' },
+            },
+            'kvm-flags' => {
+                pve0 => 'avx512f fpu hv-relaxed sse',
+                pve1 => 'fpu sse',
+            },
+        },
+        opts => {
+            online => 1,
+            force => 1,
+        },
+        config_patch => {
+            cpu => 'host',
+        },
+        expected_calls => {},
+        expect_die => "can't migrate VM to 'pve1' - incompatible CPU: CPU model 'host' passes"
+            . " through the flags of the host CPU, but the node lacks: avx512f - use"
+            . " 'allow-missing-cpu-flags' to override",
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'host',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+            },
+        },
+    },
+    {
+        name => '1033_running_host_cpu_missing_flags_allowed',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+        },
+        cpu_info => {
+            source => { vendor => 'GenuineIntel' },
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel' },
+            },
+            'kvm-flags' => {
+                pve0 => 'avx512f fpu hv-relaxed sse',
+                pve1 => 'fpu sse',
+            },
+        },
+        opts => {
+            online => 1,
+            'allow-missing-cpu-flags' => 1,
+        },
+        config_patch => {
+            cpu => 'host',
+        },
+        expected_calls => $default_expected_calls_online,
+        expect_log => [
+            "ignoring incompatible CPU of node 'pve1' due to 'allow-missing-cpu-flags': CPU"
+                . " model 'host' passes through the flags of the host CPU, but the node lacks:"
+                . " avx512f",
+        ],
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'host',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+            },
+        },
+    },
+    {
+        # nodes running an older version broadcast their KVM CPU flags, but no 'host-cpu-info'
+        name => '1033_running_host_cpu_missing_flags_without_cpu_info',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+        },
+        cpu_info => {
+            source => { vendor => 'GenuineIntel' },
+            'kvm-flags' => {
+                pve0 => 'avx512f fpu hv-relaxed sse',
+                pve1 => 'fpu sse',
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'host',
+        },
+        expected_calls => {},
+        expect_die => "can't migrate VM to 'pve1' - incompatible CPU: CPU model 'host' passes"
+            . " through the flags of the host CPU, but the node lacks: avx512f - use"
+            . " 'allow-missing-cpu-flags' to override",
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'host',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+            },
+        },
+    },
+    {
+        # nodes that did not query their flags since an upgrade still broadcast aliases
+        name => '1033_running_host_cpu_flag_aliases',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+        },
+        cpu_info => {
+            source => { vendor => 'GenuineIntel' },
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel' },
+            },
+            'kvm-flags' => {
+                pve0 => 'fpu lahf-lm lahf_lm sse sse4-2 sse4.2 sse4_2',
+                pve1 => 'fpu lahf-lm sse sse4.2',
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'host',
+        },
+        expected_calls => $default_expected_calls_online,
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'host',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+            },
+        },
+    },
     {
         name => '105_replicated_to_non_replication_target',
         target => 'pve1',
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 06/15] migrate: warn about live migration of host CPU VMs between CPU models
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (4 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH qemu-server 05/15] fix #2924: migrate: block live migration of host CPU VMs to nodes lacking flags Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 07/15] migrate: factor out whether the running virtual CPU is kept Jonas Theisen
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

Even if the target node's CPU supports all flags of the source node's
CPU, a guest with the 'host' or 'max' CPU model can run into problems
after a live migration between different physical CPU models, as they
can still behave differently, for example regarding errata. The
documentation advises against this setup for that reason.

Broadcast the CPU model name as part of the node's CPU information and
warn if it differs between the source and the target node.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/API2/Qemu.pm               |  2 +-
 src/PVE/QemuMigrate/Helpers.pm     | 23 ++++++++++++++
 src/PVE/QemuServer/Helpers.pm      |  3 ++
 src/test/run_qemu_migrate_tests.pl | 49 ++++++++++++++++++++++++++++++
 4 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index aaaa8760..f55cb641 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -5631,7 +5631,7 @@ __PACKAGE__->register_method({
                             type => {
                                 type => 'string',
                                 description => "The check that reported the warning.",
-                                enum => ['cpu-vendor', 'missing-cpu-info'],
+                                enum => ['cpu-vendor', 'missing-cpu-info', 'host-cpu-model'],
                             },
                             message => {
                                 type => 'string',
diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm
index b13992d1..0a0f3787 100644
--- a/src/PVE/QemuMigrate/Helpers.pm
+++ b/src/PVE/QemuMigrate/Helpers.pm
@@ -264,6 +264,29 @@ my $target_cpu_checks = [
                 . format_flag_list(\@missing);
         },
     },
+    {
+        type => 'host-cpu-model',
+        severity => 'warning',
+        needs => ['model-name'],
+        applies => sub {
+            my ($cpu) = @_;
+            return is_host_cpu_model($cpu);
+        },
+        check => sub {
+            my ($cpu, $source, $target) = @_;
+
+            # already reported by the 'cpu-vendor' check
+            return if vendors_differ($source, $target);
+
+            my ($source_model, $target_model) =
+                ($source->{'model-name'}, $target->{'model-name'});
+            return if !defined($source_model) || $source_model eq $target_model;
+
+            # same flags do not imply the same behavior, for example regarding errata
+            return "CPU model '$cpu->{model}' is only reliable for live migration between"
+                . " identical CPUs, but the node has '$target_model' instead of '$source_model'";
+        },
+    },
 ];
 
 # Returns the issues of the target node, and whether all checks that can prevent the migration
diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm
index 14f822cc..3932eb12 100644
--- a/src/PVE/QemuServer/Helpers.pm
+++ b/src/PVE/QemuServer/Helpers.pm
@@ -371,6 +371,8 @@ encoded as JSON. The returned hash contains:
 
 =item C<vendor>: the CPU vendor ID, for example C<GenuineIntel> or C<AuthenticAMD>
 
+=item C<model-name>: the CPU model name, for example C<AMD EPYC 7302 16-Core Processor>
+
 =back
 
 Properties that cannot be determined are missing. Consumers of the broadcast information must
@@ -386,6 +388,7 @@ sub get_host_cpu_info {
 
     my $info = {};
     $info->{vendor} = $cpuinfo->{vendor} if $known->($cpuinfo->{vendor});
+    $info->{'model-name'} = $cpuinfo->{model} if $known->($cpuinfo->{model});
 
     return $info;
 }
diff --git a/src/test/run_qemu_migrate_tests.pl b/src/test/run_qemu_migrate_tests.pl
index 0e33cfbc..50f38388 100755
--- a/src/test/run_qemu_migrate_tests.pl
+++ b/src/test/run_qemu_migrate_tests.pl
@@ -1810,6 +1810,55 @@ my $tests = [
             },
         },
     },
+    {
+        name => '1033_running_host_cpu_other_model',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'host,+kvm_pv_eoi,+kvm_pv_unhalt',
+        },
+        cpu_info => {
+            source => {
+                vendor => 'AuthenticAMD',
+                'model-name' => 'AMD EPYC 7302 16-Core Processor',
+            },
+            nodes => {
+                pve1 => {
+                    vendor => 'AuthenticAMD',
+                    'model-name' => 'AMD EPYC 7313 16-Core Processor',
+                },
+            },
+            'kvm-flags' => {
+                pve0 => 'fpu sse',
+                pve1 => 'fpu sse',
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'host',
+        },
+        expected_calls => $default_expected_calls_online,
+        expect_log => [
+            "CPU of node 'pve1' might be incompatible: CPU model 'host' is only reliable for"
+                . " live migration between identical CPUs, but the node has 'AMD EPYC 7313"
+                . " 16-Core Processor' instead of 'AMD EPYC 7302 16-Core Processor'",
+        ],
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'host',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+            },
+        },
+    },
     {
         name => '105_replicated_to_non_replication_target',
         target => 'pve1',
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 07/15] migrate: factor out whether the running virtual CPU is kept
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (5 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH qemu-server 06/15] migrate: warn about live migration of host CPU VMs between CPU models Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 08/15] migrate: block migration if the target cannot run the kept virtual CPU Jonas Theisen
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

For abstracted CPU configurations, a live migration starts the target
instance with the QEMU CPU of the running instance. Factor out this
condition, so that checks whether the target can run that CPU can use
the same one as the migration itself.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/QemuMigrate.pm         |  2 +-
 src/PVE/QemuMigrate/Helpers.pm | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm
index bd157845..bd3f7257 100644
--- a/src/PVE/QemuMigrate.pm
+++ b/src/PVE/QemuMigrate.pm
@@ -235,7 +235,7 @@ sub prepare {
         $self->{forcemachine} = PVE::QemuServer::Machine::qemu_machine_pxe($vmid, $conf);
 
         # To support abstracted CPU configurations, keep QEMU's "-cpu" parameter intact.
-        if ($conf->{cpu} && PVE::QemuServer::CPUConfig::is_abstracted($conf->{cpu})) {
+        if (PVE::QemuMigrate::Helpers::is_running_cpu_kept($conf)) {
             $self->{forcecpu} = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid);
         }
 
diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm
index 0a0f3787..67f3c0e3 100644
--- a/src/PVE/QemuMigrate/Helpers.pm
+++ b/src/PVE/QemuMigrate/Helpers.pm
@@ -310,6 +310,22 @@ my sub get_target_cpu_issues {
     return ($issues, $complete);
 }
 
+=head3 is_running_cpu_kept
+
+    my $kept = is_running_cpu_kept($conf);
+
+Returns whether a live migration of the VM with the configuration C<$conf> starts the target
+instance with the QEMU CPU of the running instance, instead of generating it again from the
+configuration. This is the case for abstracted CPU configurations, as their QEMU CPU depends on
+more than the configuration.
+
+=cut
+
+sub is_running_cpu_kept {
+    my ($conf) = @_;
+    return $conf->{cpu} && PVE::QemuServer::CPUConfig::is_abstracted($conf->{cpu}) ? 1 : 0;
+}
+
 =head3 check_target_cpu_compatibility
 
     my ($issues_by_node, $unchecked_nodes) = check_target_cpu_compatibility($conf, $pid, $nodes);
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 08/15] migrate: block migration if the target cannot run the kept virtual CPU
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (6 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH qemu-server 07/15] migrate: factor out whether the running virtual CPU is kept Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 09/15] helpers: add helper to query the host's TSC frequency and scaling support Jonas Theisen
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

For VMs with an abstracted CPU configuration, for example with a custom
CPU model or the 'nested-virt' flag, the target is started with the
QEMU CPU of the running instance, instead of generating it again from
the configuration. That QEMU CPU can contain flags that KVM on the
target does not support, for example the Intel-only 'hv-evmcs'
enlightenment that is enabled for Windows 11 guests on Intel hosts.
QEMU on an AMD target then refuses to start:

  kvm: Hyper-V enlightened VMCS (hv-evmcs) is not supported by kernel

and the migration fails only after its preparation.

Check upfront whether KVM on the target supports all enabled Hyper-V
enlightenments of the kept CPU, which QEMU always requires, and all of
its other enabled flags if 'enforce' is set. This uses the CPU flags
that pvestatd already broadcasts for each node. Only flags that KVM
supports on the source node are considered, so that QEMU CPU
properties that are not CPU flags are not reported as missing.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/API2/Qemu.pm               |  3 +-
 src/PVE/QemuMigrate/Helpers.pm     | 39 +++++++++++++-
 src/test/run_qemu_migrate_tests.pl | 85 ++++++++++++++++++++++++++++++
 3 files changed, 125 insertions(+), 2 deletions(-)

diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index f55cb641..5e14a1bb 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -5528,7 +5528,8 @@ __PACKAGE__->register_method({
                                     type => {
                                         type => 'string',
                                         description => "The check that failed.",
-                                        enum => ['cpu-vendor', 'host-cpu-flags'],
+                                        enum =>
+                                            ['cpu-vendor', 'host-cpu-flags', 'kept-cpu-flags'],
                                     },
                                     message => {
                                         type => 'string',
diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm
index 67f3c0e3..37fa10d4 100644
--- a/src/PVE/QemuMigrate/Helpers.pm
+++ b/src/PVE/QemuMigrate/Helpers.pm
@@ -186,7 +186,8 @@ my sub format_flag_list {
 # Checks whether the CPU of a target node can run a running VM after a live migration.
 #
 # 'applies' returns true if the check is relevant for the VM's CPU, as parsed by
-# parse_qemu_cpu_string(), with 'kvm' set if the VM uses KVM. 'needs' lists the CPU information
+# parse_qemu_cpu_string(), with 'kvm' set if the VM uses KVM and 'kept' set if the target is
+# started with the same QEMU CPU, see is_running_cpu_kept(). 'needs' lists the CPU information
 # of the target node the check requires, nodes lacking any of it are skipped. The CPU information
 # is in the format of get_host_cpu_info(), plus the CPU flags KVM supports as 'kvm-flags' hash.
 # 'check' returns why the target node is incompatible, if it is. With the 'error' severity, an
@@ -287,6 +288,41 @@ my $target_cpu_checks = [
                 . " identical CPUs, but the node has '$target_model' instead of '$source_model'";
         },
     },
+    {
+        type => 'kept-cpu-flags',
+        severity => 'error',
+        needs => ['kvm-flags'],
+        applies => sub {
+            my ($cpu) = @_;
+            return $cpu->{kept};
+        },
+        check => sub {
+            my ($cpu, $source, $target) = @_;
+
+            my ($source_flags, $target_flags) =
+                ($source->{'kvm-flags'}, $target->{'kvm-flags'});
+            return if !$source_flags;
+
+            my $props = $cpu->{props};
+            my $enforce = PVE::JSONSchema::parse_boolean($props->{enforce} // 'off');
+
+            # QEMU refuses to start with unsupported Hyper-V enlightenments, and with any other
+            # unsupported flag only if 'enforce' is set. Requiring support on the source skips
+            # properties that are no CPU flags.
+            my @missing = sort grep {
+                PVE::JSONSchema::parse_boolean($props->{$_})
+                    && ($enforce || m/^hv-/)
+                    && $source_flags->{$_}
+                    && !$target_flags->{$_}
+            } keys $props->%*;
+            return if !scalar(@missing);
+
+            return
+                "the VM keeps its current virtual CPU when migrated, but KVM on the node does"
+                . " not support: "
+                . format_flag_list(\@missing);
+        },
+    },
 ];
 
 # Returns the issues of the target node, and whether all checks that can prevent the migration
@@ -351,6 +387,7 @@ sub check_target_cpu_compatibility {
 
     my $cpu = parse_qemu_cpu_string(PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid));
     $cpu->{kvm} = $conf->{kvm} // 1;
+    $cpu->{kept} = is_running_cpu_kept($conf);
 
     my $checks = [grep { $_->{applies}->($cpu) } $target_cpu_checks->@*];
     return ({}, []) if !scalar($checks->@*);
diff --git a/src/test/run_qemu_migrate_tests.pl b/src/test/run_qemu_migrate_tests.pl
index 50f38388..57aa59b1 100755
--- a/src/test/run_qemu_migrate_tests.pl
+++ b/src/test/run_qemu_migrate_tests.pl
@@ -1859,6 +1859,91 @@ my $tests = [
             },
         },
     },
+    {
+        name => '1033_running_kept_cpu_supported_flags',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu =>
+                'kvm64,enforce,+vmx,hv_evmcs,hv_relaxed,hv_spinlocks=0x1fff,+kvm_pv_eoi',
+        },
+        cpu_info => {
+            source => { vendor => 'GenuineIntel' },
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel' },
+            },
+            'kvm-flags' => {
+                pve0 => 'fpu hv-evmcs hv-relaxed hv-spinlocks kvm-pv-eoi sse vmx',
+                pve1 => 'fpu hv-evmcs hv-relaxed kvm-pv-eoi sse vmx',
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'kvm64,flags=+nested-virt',
+        },
+        expected_calls => $default_expected_calls_online,
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'kvm64,flags=+nested-virt',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu =>
+                    'kvm64,enforce,+vmx,hv_evmcs,hv_relaxed,hv_spinlocks=0x1fff,+kvm_pv_eoi',
+            },
+        },
+    },
+    {
+        name => '1033_running_kept_cpu_unsupported_flags',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu =>
+                'kvm64,enforce,+vmx,hv_evmcs,hv_relaxed,hv_spinlocks=0x1fff,+kvm_pv_eoi',
+        },
+        cpu_info => {
+            source => { vendor => 'GenuineIntel' },
+            nodes => {
+                pve1 => { vendor => 'AuthenticAMD' },
+            },
+            'kvm-flags' => {
+                pve0 => 'fpu hv-evmcs hv-relaxed hv-spinlocks kvm-pv-eoi sse vmx',
+                pve1 => 'fpu hv-relaxed kvm-pv-eoi sse svm',
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'kvm64,flags=+nested-virt',
+        },
+        expected_calls => {},
+        expect_die =>
+            "can't migrate VM to 'pve1' - incompatible CPU: the VM keeps its current virtual"
+            . " CPU when migrated, but KVM on the node does not support: hv-evmcs, vmx",
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'kvm64,flags=+nested-virt',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu =>
+                    'kvm64,enforce,+vmx,hv_evmcs,hv_relaxed,hv_spinlocks=0x1fff,+kvm_pv_eoi',
+            },
+        },
+    },
     {
         name => '105_replicated_to_non_replication_target',
         target => 'pve1',
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 09/15] helpers: add helper to query the host's TSC frequency and scaling support
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (7 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH qemu-server 08/15] migrate: block migration if the target cannot run the kept virtual CPU Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 10/15] cpu config: add hv-reenlightenment flag and set TSC frequency for it Jonas Theisen
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

Guests whose time stamp counter (TSC) frequency must not change across
a live migration need to know the TSC frequency of the host they are
started on, and whether the hosts in a cluster can scale the TSC
frequency for guests.

Query both directly from KVM, as there is no other interface that
reliably exposes them: upstream Linux does not export the TSC frequency
to user space, and the TSC scaling CPU flag is shown in different
places of /proc/cpuinfo for Intel and AMD CPUs, regardless of whether
KVM uses it.

KVM_GET_TSC_KHZ is a vCPU ioctl, so a temporary VM with a single vCPU
is created. This is cheap, as no guest memory is set up, and the
result is cached, as it cannot change while the host is running.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/QemuServer/Helpers.pm | 53 +++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm
index 3932eb12..098d71eb 100644
--- a/src/PVE/QemuServer/Helpers.pm
+++ b/src/PVE/QemuServer/Helpers.pm
@@ -3,6 +3,7 @@ package PVE::QemuServer::Helpers;
 use strict;
 use warnings;
 
+use Fcntl qw(O_RDWR);
 use File::stat;
 use IO::File;
 
@@ -359,6 +360,58 @@ sub get_host_phys_address_bits {
     return; # undef, cannot really do anything..
 }
 
+# KVM ioctl request numbers and capabilities, see include/uapi/linux/kvm.h in Linux
+my $KVM_CREATE_VM = 0xae01;
+my $KVM_CHECK_EXTENSION = 0xae03;
+my $KVM_CREATE_VCPU = 0xae41;
+my $KVM_GET_TSC_KHZ = 0xaea3;
+my $KVM_CAP_TSC_CONTROL = 60;
+my $KVM_CAP_GET_TSC_KHZ = 61;
+
+my $_host_tsc_info;
+
+=head3 get_host_tsc_info
+
+    my $tsc_info = get_host_tsc_info();
+    my ($khz, $scaling) = $tsc_info->@{qw(khz scaling)};
+
+Returns a hash reference with information about the time stamp counter (TSC) of this host, as
+KVM reports it. C<khz> is the TSC frequency in kHz that KVM uses for new vCPUs, or undefined if
+KVM cannot report it. C<scaling> is true if KVM can run vCPUs with a different TSC frequency.
+
+The values are cached, as they cannot change while the host is running.
+
+Dies if C</dev/kvm> is not available.
+
+=cut
+
+sub get_host_tsc_info {
+    return $_host_tsc_info if defined($_host_tsc_info);
+
+    sysopen(my $kvm_fh, '/dev/kvm', O_RDWR) or die "unable to open /dev/kvm - $!\n";
+
+    my $check_extension = sub {
+        my ($cap) = @_;
+        return int(ioctl($kvm_fh, $KVM_CHECK_EXTENSION, $cap) // 0);
+    };
+
+    my $info = { scaling => $check_extension->($KVM_CAP_TSC_CONTROL) ? 1 : 0 };
+
+    # KVM_GET_TSC_KHZ is a vCPU ioctl, so it needs a temporary VM with a single vCPU
+    if ($check_extension->($KVM_CAP_GET_TSC_KHZ)) {
+        my $vm_fd = ioctl($kvm_fh, $KVM_CREATE_VM, 0) // die "unable to create KVM VM - $!\n";
+        open(my $vm_fh, '+<&=', int($vm_fd)) or die "unable to open KVM VM fd - $!\n";
+
+        my $vcpu_fd = ioctl($vm_fh, $KVM_CREATE_VCPU, 0) // die "unable to create KVM vCPU - $!\n";
+        open(my $vcpu_fh, '+<&=', int($vcpu_fd)) or die "unable to open KVM vCPU fd - $!\n";
+
+        my $khz = ioctl($vcpu_fh, $KVM_GET_TSC_KHZ, 0) // die "unable to get TSC frequency - $!\n";
+        $info->{khz} = int($khz) if int($khz) > 0;
+    }
+
+    return $_host_tsc_info = $info;
+}
+
 =head3 get_host_cpu_info
 
     my $info = get_host_cpu_info();
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 10/15] cpu config: add hv-reenlightenment flag and set TSC frequency for it
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (8 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH qemu-server 09/15] helpers: add helper to query the host's TSC frequency and scaling support Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH qemu-server 11/15] migrate: block migration to nodes with incompatible TSC for re-enlightenment Jonas Theisen
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

Re-enlightenment notifications let nested Hyper-V guests, for example
Windows with WSL2 or VBS enabled, pass a stable clock source on to
their own guests across live migrations.

KVM does not emulate the old TSC frequency after a migration, so QEMU
refuses to load the migration stream of a guest that enabled these
notifications if no TSC frequency was set explicitly. Set it to the
host's TSC frequency, as reported by KVM, whenever the flag is enabled
for the VM or by a custom CPU model.

Treat the CPU configuration as abstracted if the flag is set, so that
the TSC frequency of the running instance is kept for live migration,
snapshots with RAM and hibernation, as the frequency of the host a VM
is resumed on can differ.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/QemuServer/CPUConfig.pm               | 18 +++++++++++++
 src/PVE/QemuServer/CPUFlags.pm                |  8 ++++++
 src/test/QemuServerTest/CommandLineMocks.pm   |  3 +++
 src/test/cfg2cmd/cpu-hv-reenlightenment.conf  |  6 +++++
 .../cfg2cmd/cpu-hv-reenlightenment.conf.cmd   | 26 +++++++++++++++++++
 5 files changed, 61 insertions(+)
 create mode 100644 src/test/cfg2cmd/cpu-hv-reenlightenment.conf
 create mode 100644 src/test/cfg2cmd/cpu-hv-reenlightenment.conf.cmd

diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm
index 414682a6..d629a2c6 100644
--- a/src/PVE/QemuServer/CPUConfig.pm
+++ b/src/PVE/QemuServer/CPUConfig.pm
@@ -718,6 +718,8 @@ determined from the configuration alone. Possible abstractions:
 
 =item abstract flag: for example, nested-virt changes with the host
 
+=item host-dependent setting: for example, hv-reenlightenment sets the TSC frequency of the host
+
 =back
 
 =cut
@@ -732,6 +734,7 @@ sub is_abstracted($cpu_property_string) {
     for my $flag (split(";", $cpu_conf->{flags})) {
         if ($flag =~ $cpu_flag_supported_re) {
             return 1 if $2 eq 'nested-virt';
+            return 1 if $2 eq 'hv-reenlightenment' && $1 eq '+';
         }
     }
     return;
@@ -965,6 +968,21 @@ sub get_cpu_options(
         $vm_flags,
         $pve_forced_flags,
     );
+
+    # Without an explicit TSC frequency, QEMU refuses to migrate a guest that enabled
+    # re-enlightenment notifications, as KVM does not emulate the old frequency afterwards.
+    my $reenlightenment = $resolved_flags->{'hv-reenlightenment'};
+    if ($kvm && $arch eq 'x86_64' && $reenlightenment && $reenlightenment->{op} ne '-') {
+        my $tsc_khz = PVE::QemuServer::Helpers::get_host_tsc_info()->{khz}
+            or die "unable to determine the host TSC frequency required for"
+            . " 'hv-reenlightenment'\n";
+        $resolved_flags->{'tsc-frequency'} = {
+            op => '',
+            value => $tsc_khz * 1000,
+            reason => "required by hv-reenlightenment",
+        };
+    }
+
     $cpu_str .= print_cpu_flags($resolved_flags);
 
     my $using_phys_bits_above_40;
diff --git a/src/PVE/QemuServer/CPUFlags.pm b/src/PVE/QemuServer/CPUFlags.pm
index 0ba2e115..bfdee207 100644
--- a/src/PVE/QemuServer/CPUFlags.pm
+++ b/src/PVE/QemuServer/CPUFlags.pm
@@ -76,6 +76,14 @@ my $supported_vm_specific_cpu_flags_by_arch = {
             description =>
                 "Improve performance for nested virtualization. Only supported on Intel" . " CPUs.",
         },
+        {
+            name => 'hv-reenlightenment',
+            description =>
+                "Allow nested Hyper-V guests, for example with WSL2 or VBS, to keep a stable"
+                . " clock source across live migrations. Sets the TSC frequency of the VM to"
+                . " the frequency of the host it is started on, so live migration only works"
+                . " to hosts with TSC scaling support or a TSC frequency within 250 ppm.",
+        },
         {
             name => 'aes',
             description => "Activate AES instruction set for HW acceleration.",
diff --git a/src/test/QemuServerTest/CommandLineMocks.pm b/src/test/QemuServerTest/CommandLineMocks.pm
index 7fd4cc23..d0cd31c2 100644
--- a/src/test/QemuServerTest/CommandLineMocks.pm
+++ b/src/test/QemuServerTest/CommandLineMocks.pm
@@ -395,6 +395,9 @@ $qemu_server_helpers->mock(
     get_host_phys_address_bits => sub {
         return 46;
     },
+    get_host_tsc_info => sub {
+        return { khz => 2999999, scaling => 1 };
+    },
     kvm_user_version => sub {
         return get_test_qemu_version();
     },
diff --git a/src/test/cfg2cmd/cpu-hv-reenlightenment.conf b/src/test/cfg2cmd/cpu-hv-reenlightenment.conf
new file mode 100644
index 00000000..7e8150df
--- /dev/null
+++ b/src/test/cfg2cmd/cpu-hv-reenlightenment.conf
@@ -0,0 +1,6 @@
+# TEST: Test that enabling hv-reenlightenment sets the TSC frequency of the host
+cpu: x86-64-v2-AES,flags=+hv-reenlightenment
+memory: 768
+numa: 0
+ostype: win11
+sockets: 1
diff --git a/src/test/cfg2cmd/cpu-hv-reenlightenment.conf.cmd b/src/test/cfg2cmd/cpu-hv-reenlightenment.conf.cmd
new file mode 100644
index 00000000..c3d8e49c
--- /dev/null
+++ b/src/test/cfg2cmd/cpu-hv-reenlightenment.conf.cmd
@@ -0,0 +1,26 @@
+/usr/bin/kvm \
+  -id 8006 \
+  -name vm8006 \
+  -no-shutdown \
+  -chardev 'socket,id=qmp,path=/var/run/qemu-server/8006.qmp,server=on,wait=off' \
+  -object 'monitor-qmp,chardev=qmp,id=monitor-qmp' \
+  -chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect-ms=5000' \
+  -object 'monitor-qmp,chardev=qmp-event,id=monitor-qmp-event' \
+  -pidfile /var/run/qemu-server/8006.pid \
+  -daemonize \
+  -smp '1,sockets=1,cores=1,maxcpus=1' \
+  -nodefaults \
+  -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
+  -vnc 'unix:/var/run/qemu-server/8006.vnc,password=on' \
+  -global 'kvm-pit.lost_tick_policy=discard' \
+  -cpu 'qemu64,+aes,-cet-ibt,-cet-ss,enforce,+hv-reenlightenment,hv_ipi,hv_relaxed,hv_reset,hv_runtime,hv_spinlocks=0x1fff,hv_stimer,hv_synic,hv_time,hv_vapic,hv_vpindex,+kvm_pv_eoi,+kvm_pv_unhalt,+pni,+popcnt,+sse4.1,+sse4.2,+ssse3,tsc-frequency=2999999000' \
+  -m 768 \
+  -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' \
+  -device 'pci-bridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f' \
+  -device 'piix3-usb-uhci,id=uhci,bus=pci.0,addr=0x1.0x2' \
+  -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' \
+  -device 'VGA,id=vga,bus=pci.0,addr=0x2,edid=off' \
+  -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' \
+  -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
+  -rtc 'driftfix=slew,base=localtime' \
+  -machine 'hpet=off,type=pc-i440fx-5.1+pve0'
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH qemu-server 11/15] migrate: block migration to nodes with incompatible TSC for re-enlightenment
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (9 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH qemu-server 10/15] cpu config: add hv-reenlightenment flag and set TSC frequency for it Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH manager 12/15] pvestatd: broadcast host CPU information relevant for live migration Jonas Theisen
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

A VM with 'hv-reenlightenment' runs with the TSC frequency of the host
it was started on. QEMU on the target node can only use it if KVM
there supports TSC scaling, or if the target's TSC frequency is within
250 ppm, which KVM accepts without scaling. QEMU hard-codes this
bound [0], matching the default of KVM's 'tsc_tolerance_ppm' module
parameter [1]. Otherwise the target instance fails to start and the
migration is aborted only after its preparation, for example after
local disks were already allocated on the target.

Broadcast the TSC frequency and scaling support as part of the node's
CPU information, and check this upfront. Target nodes that do not
broadcast this information yet are not blocked, but a warning is
logged, as for the other checks.

[0]: https://gitlab.com/qemu-project/qemu/-/blob/v11.1.0/target/i386/kvm/kvm.c#L886
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kvm/x86.c?h=v7.0#n164

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/PVE/API2/Qemu.pm               |   8 +-
 src/PVE/QemuMigrate/Helpers.pm     |  30 +++++
 src/PVE/QemuServer/Helpers.pm      |  12 ++
 src/test/run_qemu_migrate_tests.pl | 183 +++++++++++++++++++++++++++++
 4 files changed, 231 insertions(+), 2 deletions(-)

diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index 5e14a1bb..17911368 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -5528,8 +5528,12 @@ __PACKAGE__->register_method({
                                     type => {
                                         type => 'string',
                                         description => "The check that failed.",
-                                        enum =>
-                                            ['cpu-vendor', 'host-cpu-flags', 'kept-cpu-flags'],
+                                        enum => [
+                                            'cpu-vendor',
+                                            'host-cpu-flags',
+                                            'kept-cpu-flags',
+                                            'tsc-frequency',
+                                        ],
                                     },
                                     message => {
                                         type => 'string',
diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm
index 37fa10d4..df23d605 100644
--- a/src/PVE/QemuMigrate/Helpers.pm
+++ b/src/PVE/QemuMigrate/Helpers.pm
@@ -323,6 +323,36 @@ my $target_cpu_checks = [
                 . format_flag_list(\@missing);
         },
     },
+    {
+        type => 'tsc-frequency',
+        severity => 'error',
+        needs => ['tsc-scaling'],
+        applies => sub {
+            my ($cpu) = @_;
+            my $props = $cpu->{props};
+            return PVE::JSONSchema::parse_boolean($props->{'hv-reenlightenment'} // 'off')
+                && $props->{'tsc-frequency'};
+        },
+        check => sub {
+            my ($cpu, $source, $target) = @_;
+
+            return if $target->{'tsc-scaling'};
+
+            my $vm_khz = int($cpu->{props}->{'tsc-frequency'} / 1000);
+            my $requirement = "'hv-reenlightenment' requires TSC scaling support or a TSC"
+                . " frequency within 250 ppm of the VM's $vm_khz kHz";
+
+            my $target_khz = $target->{'tsc-khz'}
+                or return "$requirement, but the node's TSC frequency is unknown";
+
+            # without TSC scaling, KVM can only set frequencies within 250 ppm, which QEMU
+            # considers to be within NTP correction bounds
+            my $tolerance = int($target_khz * 250 / 1_000_000);
+            return if abs($vm_khz - $target_khz) <= $tolerance;
+
+            return "$requirement, but the node has $target_khz kHz without TSC scaling";
+        },
+    },
 ];
 
 # Returns the issues of the target node, and whether all checks that can prevent the migration
diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm
index 098d71eb..8b5f0cd8 100644
--- a/src/PVE/QemuServer/Helpers.pm
+++ b/src/PVE/QemuServer/Helpers.pm
@@ -426,6 +426,10 @@ encoded as JSON. The returned hash contains:
 
 =item C<model-name>: the CPU model name, for example C<AMD EPYC 7302 16-Core Processor>
 
+=item C<tsc-khz>: the TSC frequency in kHz that KVM uses for new vCPUs
+
+=item C<tsc-scaling>: whether KVM can run vCPUs with a different TSC frequency
+
 =back
 
 Properties that cannot be determined are missing. Consumers of the broadcast information must
@@ -443,6 +447,14 @@ sub get_host_cpu_info {
     $info->{vendor} = $cpuinfo->{vendor} if $known->($cpuinfo->{vendor});
     $info->{'model-name'} = $cpuinfo->{model} if $known->($cpuinfo->{model});
 
+    my $tsc_info = eval { get_host_tsc_info() };
+    warn "unable to query TSC information - $@" if $@;
+
+    if ($tsc_info) {
+        $info->{'tsc-khz'} = $tsc_info->{khz} if defined($tsc_info->{khz});
+        $info->{'tsc-scaling'} = $tsc_info->{scaling} ? 1 : 0;
+    }
+
     return $info;
 }
 
diff --git a/src/test/run_qemu_migrate_tests.pl b/src/test/run_qemu_migrate_tests.pl
index 57aa59b1..538a55f3 100755
--- a/src/test/run_qemu_migrate_tests.pl
+++ b/src/test/run_qemu_migrate_tests.pl
@@ -1944,6 +1944,189 @@ my $tests = [
             },
         },
     },
+    {
+        name => '1033_running_hv_reenlightenment_tsc_within_bounds',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+        },
+        cpu_info => {
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel', 'tsc-khz' => 3000500, 'tsc-scaling' => 0 },
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'kvm64,flags=+hv-reenlightenment',
+        },
+        expected_calls => $default_expected_calls_online,
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'kvm64,flags=+hv-reenlightenment',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+            },
+        },
+    },
+    {
+        name => '1033_running_hv_reenlightenment_tsc_scaling',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+        },
+        cpu_info => {
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel', 'tsc-khz' => 2400000, 'tsc-scaling' => 1 },
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'kvm64,flags=+hv-reenlightenment',
+        },
+        expected_calls => $default_expected_calls_online,
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'kvm64,flags=+hv-reenlightenment',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+            },
+        },
+    },
+    {
+        name => '1033_running_hv_reenlightenment_tsc_mismatch',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+        },
+        cpu_info => {
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel', 'tsc-khz' => 2400000, 'tsc-scaling' => 0 },
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'kvm64,flags=+hv-reenlightenment',
+        },
+        expected_calls => {},
+        expect_die => "can't migrate VM to 'pve1' - incompatible CPU: 'hv-reenlightenment'"
+            . " requires TSC scaling support or a TSC frequency within 250 ppm of the VM's"
+            . " 2999999 kHz, but the node has 2400000 kHz without TSC scaling",
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'kvm64,flags=+hv-reenlightenment',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+            },
+        },
+    },
+    {
+        name => '1033_running_hv_reenlightenment_tsc_unknown',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+        },
+        cpu_info => {
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel', 'tsc-scaling' => 0 },
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'kvm64,flags=+hv-reenlightenment',
+        },
+        expected_calls => {},
+        expect_die => "can't migrate VM to 'pve1' - incompatible CPU: 'hv-reenlightenment'"
+            . " requires TSC scaling support or a TSC frequency within 250 ppm of the VM's"
+            . " 2999999 kHz, but the node's TSC frequency is unknown",
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'kvm64,flags=+hv-reenlightenment',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+            },
+        },
+    },
+    {
+        name => '1033_running_hv_reenlightenment_target_without_tsc_info',
+        target => 'pve1',
+        vmid => 1033,
+        vm_status => {
+            running => 1,
+            runningmachine => 'pc-q35-5.0+pve0',
+            runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+        },
+        cpu_info => {
+            nodes => {
+                pve1 => { vendor => 'GenuineIntel' },
+            },
+            'kvm-flags' => {
+                pve0 => 'fpu hv-reenlightenment sse',
+                pve1 => 'fpu hv-reenlightenment sse',
+            },
+        },
+        opts => {
+            online => 1,
+        },
+        config_patch => {
+            cpu => 'kvm64,flags=+hv-reenlightenment',
+        },
+        expected_calls => $default_expected_calls_online,
+        expect_log => [
+            "unable to check CPU compatibility of node 'pve1' - CPU information not available",
+        ],
+        expected => {
+            source_volids => {},
+            target_volids => {},
+            vm_config => get_patched_config(1033, {
+                    cpu => 'kvm64,flags=+hv-reenlightenment',
+            }),
+            vm_status => {
+                running => 1,
+                runningmachine => 'pc-q35-5.0+pve0',
+                runningcpu => 'kvm64,+hv-reenlightenment,tsc-frequency=2999999000',
+            },
+        },
+    },
     {
         name => '105_replicated_to_non_replication_target',
         target => 'pve1',
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH manager 12/15] pvestatd: broadcast host CPU information relevant for live migration
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (10 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH qemu-server 11/15] migrate: block migration to nodes with incompatible TSC for re-enlightenment Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH manager 13/15] ui: migrate: show why the CPU of the target node is incompatible Jonas Theisen
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

qemu-server checks whether the CPU of a target node can run a VM after
a live migration, for example whether it supports the TSC frequency
a VM with 'hv-reenlightenment' requires, or has the same vendor and
model as the source for VMs with the 'host' CPU model.

Broadcast the information qemu-server provides for this, currently the
CPU vendor and model name, TSC frequency and TSC scaling support of the
node, so that the source node of a migration can check this. The
information cannot change while pvestatd runs, so it is only queried
once, but broadcast again if the node key-value entry got lost.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 PVE/Service/pvestatd.pm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index cec66e00..91d244b3 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -21,6 +21,7 @@ use PVE::NodeConfig;
 use PVE::Cluster qw(cfs_read_file);
 use PVE::Storage;
 use PVE::QemuServer;
+use PVE::QemuServer::Helpers;
 use PVE::QemuServer::Monitor;
 use PVE::LXC;
 use PVE::CGroup;
@@ -166,6 +167,25 @@ my sub broadcast_static_node_info {
     }
 }
 
+# the host CPU cannot change while pvestatd is running
+my $host_cpu_info;
+
+my sub broadcast_host_cpu_info {
+    if (!defined($host_cpu_info)) {
+        $host_cpu_info = eval { PVE::QemuServer::Helpers::get_host_cpu_info() };
+        if (my $err = $@) {
+            syslog('err', "unable to query host CPU information - $err");
+            return;
+        }
+    }
+
+    my $info = JSON->new->canonical->encode($host_cpu_info);
+
+    # re-broadcast if the entry got lost, for example after a restart of pmxcfs
+    my $old = PVE::Cluster::get_node_kv('host-cpu-info', $nodename)->{$nodename};
+    PVE::Cluster::broadcast_node_kv('host-cpu-info', $info) if ($old // '') ne $info;
+}
+
 my ($cached_ip_links, $cached_ip_link_last_update) = (undef, 0);
 my $MAX_IP_LINK_CACHE_AGE_SECONDS = 15 * 60; # every 15 minutes
 
@@ -291,6 +311,7 @@ sub update_node_status {
     PVE::PullMetric::update($pull_txn, 'node', $node_metric, $ctime);
 
     broadcast_static_node_info($maxcpu, $meminfo->{memtotal});
+    broadcast_host_cpu_info();
 }
 
 sub auto_ballooning {
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH manager 13/15] ui: migrate: show why the CPU of the target node is incompatible
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (11 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH manager 12/15] pvestatd: broadcast host CPU information relevant for live migration Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH manager 14/15] fix #6535: ui: migrate: show CPU warnings for the target node Jonas Theisen
  2026-11-18 15:40 ` [PATCH manager 15/15] api: nodes: migrateall: skip VMs whose CPU is incompatible with the target Jonas Theisen
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

Show the reasons the migration precondition API reports for target
nodes whose CPU cannot run a VM after a live migration, instead of
only failing once the migration task runs.

If root can override all of these reasons with migration options, offer
a checkbox to ignore the incompatibility, which sets these options and
shows the reasons as warnings instead. Which options to set is taken
from the API, so that further overridable checks need no UI changes.
The checkbox is also shown for HA-managed VMs, as the migration API
forwards the override options to the HA stack.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 www/manager6/window/Migrate.js | 54 ++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/www/manager6/window/Migrate.js b/www/manager6/window/Migrate.js
index 15ce34f8..68d93a6f 100644
--- a/www/manager6/window/Migrate.js
+++ b/www/manager6/window/Migrate.js
@@ -29,6 +29,8 @@ Ext.define('PVE.window.Migrate', {
                 allowedNodes: undefined,
                 overwriteLocalResourceCheck: false,
                 hasLocalResources: false,
+                ignoreCpuIncompatibility: false,
+                cpuOverrides: [],
                 withConntrackState: true,
                 bothHaveDbusVmstate: false,
                 configCheck: true,
@@ -64,6 +66,7 @@ Ext.define('PVE.window.Migrate', {
                     return false;
                 }
             },
+            cpuOverrideCheckboxHidden: (get) => !get('migration.cpuOverrides').length,
             conntrackStateCheckboxHidden: (get) =>
                 !get('running') ||
                 get('vmtype') !== 'qemu' ||
@@ -147,6 +150,12 @@ Ext.define('PVE.window.Migrate', {
                 params.force = 1;
             }
 
+            if (vm.get('migration.ignoreCpuIncompatibility')) {
+                for (const override of vm.get('migration.cpuOverrides')) {
+                    params[override] = 1;
+                }
+            }
+
             if (vm.get('migration.bothHaveDbusVmstate') && vm.get('migration.withConntrackState')) {
                 params['with-conntrack-state'] = 1;
             }
@@ -306,6 +315,30 @@ Ext.define('PVE.window.Migrate', {
                 migration.preconditions.push({ text, severity: 'error' });
             }
 
+            let cpuBlockers = disallowed['incompatible-cpu'] ?? [];
+            // the override options are reserved for root
+            let canOverrideCpu =
+                Proxmox.UserName === 'root@pam' &&
+                cpuBlockers.length > 0 &&
+                cpuBlockers.every((blocker) => blocker.override);
+            migration.cpuOverrides = canOverrideCpu
+                ? [...new Set(cpuBlockers.map((blocker) => blocker.override))]
+                : [];
+
+            for (const cpuBlocker of cpuBlockers) {
+                const text = Ext.String.format(
+                    gettext('CPU of selected target is incompatible: {0}'),
+                    cpuBlocker.message,
+                );
+
+                if (canOverrideCpu && migration.ignoreCpuIncompatibility) {
+                    migration.preconditions.push({ text, severity: 'warning' });
+                } else {
+                    migration.possible = false;
+                    migration.preconditions.push({ text, severity: 'error' });
+                }
+            }
+
             let blockingResources = [];
             let mappedResources = migrateStats['mapped-resource-info'] ?? {};
 
@@ -695,6 +728,27 @@ Ext.define('PVE.window.Migrate', {
                                 },
                             },
                         },
+                        {
+                            xtype: 'proxmoxcheckbox',
+                            name: 'ignoreCpuIncompatibility',
+                            fieldLabel: gettext('Ignore CPU incompatibility'),
+                            autoEl: {
+                                tag: 'div',
+                                'data-qtip': gettext(
+                                    'Migrate even if the CPU of the selected target is incompatible. The VM might crash or fail to migrate.',
+                                ),
+                            },
+                            bind: {
+                                hidden: '{cpuOverrideCheckboxHidden}',
+                                value: '{migration.ignoreCpuIncompatibility}',
+                            },
+                            listeners: {
+                                change: {
+                                    fn: 'checkMigratePreconditions',
+                                    extraArg: true,
+                                },
+                            },
+                        },
                         {
                             xtype: 'proxmoxcheckbox',
                             name: 'withConntrackState',
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH manager 14/15] fix #6535: ui: migrate: show CPU warnings for the target node
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (12 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH manager 13/15] ui: migrate: show why the CPU of the target node is incompatible Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  2026-11-18 15:40 ` [PATCH manager 15/15] api: nodes: migrateall: skip VMs whose CPU is incompatible with the target Jonas Theisen
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

Show the warnings the migration precondition API reports for the CPU
of the selected target node, for example when live migrating between
CPU vendors, which is not guaranteed to work.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 www/manager6/window/Migrate.js | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/www/manager6/window/Migrate.js b/www/manager6/window/Migrate.js
index 68d93a6f..209d2005 100644
--- a/www/manager6/window/Migrate.js
+++ b/www/manager6/window/Migrate.js
@@ -339,6 +339,15 @@ Ext.define('PVE.window.Migrate', {
                 }
             }
 
+            for (const cpuWarning of migrateStats['cpu-warnings']?.[target] ?? []) {
+                const text = Ext.String.format(
+                    gettext('CPU of selected target might be incompatible: {0}'),
+                    cpuWarning.message,
+                );
+
+                migration.preconditions.push({ text, severity: 'warning' });
+            }
+
             let blockingResources = [];
             let mappedResources = migrateStats['mapped-resource-info'] ?? {};
 
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH manager 15/15] api: nodes: migrateall: skip VMs whose CPU is incompatible with the target
  2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
                   ` (13 preceding siblings ...)
  2026-11-18 15:40 ` [PATCH manager 14/15] fix #6535: ui: migrate: show CPU warnings for the target node Jonas Theisen
@ 2026-11-18 15:40 ` Jonas Theisen
  14 siblings, 0 replies; 16+ messages in thread
From: Jonas Theisen @ 2026-11-18 15:40 UTC (permalink / raw)
  To: pve-devel

The migration precondition API reports target nodes whose CPU cannot
run a VM after a live migration. Skip such VMs with the reason in the
log, like for the other failed preconditions, instead of starting
a migration task that fails right away.

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 PVE/API2/Nodes.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 07b3ce1f..7a753139 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -2663,6 +2663,11 @@ my $create_migrate_worker = sub {
                 $invalidConditions .= "\n  Has unavailable resources: ";
                 $invalidConditions .= join(', ', $unavail_resources->@*);
             }
+
+            if (my $incompatible_cpu = $not_allowed_nodes->{$target}->{'incompatible-cpu'}) {
+                $invalidConditions .= "\n  Has incompatible CPU: ";
+                $invalidConditions .= join('; ', map { $_->{message} } $incompatible_cpu->@*);
+            }
         }
 
         if ($invalidConditions && $invalidConditions ne '') {
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-11-18 15:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 15:40 [PATCH manager/qemu-server 00/15] check the target node's CPU before live migrating a VM Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 01/15] test: migration: allow checking for warnings and errors in the log Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 02/15] migrate: block live migration of host CPU VMs between CPU vendors Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 03/15] fix #6535: migrate: warn about live migration " Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 04/15] cpu flags: factor out parsing the broadcast CPU flags of a node Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 05/15] fix #2924: migrate: block live migration of host CPU VMs to nodes lacking flags Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 06/15] migrate: warn about live migration of host CPU VMs between CPU models Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 07/15] migrate: factor out whether the running virtual CPU is kept Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 08/15] migrate: block migration if the target cannot run the kept virtual CPU Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 09/15] helpers: add helper to query the host's TSC frequency and scaling support Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 10/15] cpu config: add hv-reenlightenment flag and set TSC frequency for it Jonas Theisen
2026-11-18 15:40 ` [PATCH qemu-server 11/15] migrate: block migration to nodes with incompatible TSC for re-enlightenment Jonas Theisen
2026-11-18 15:40 ` [PATCH manager 12/15] pvestatd: broadcast host CPU information relevant for live migration Jonas Theisen
2026-11-18 15:40 ` [PATCH manager 13/15] ui: migrate: show why the CPU of the target node is incompatible Jonas Theisen
2026-11-18 15:40 ` [PATCH manager 14/15] fix #6535: ui: migrate: show CPU warnings for the target node Jonas Theisen
2026-11-18 15:40 ` [PATCH manager 15/15] api: nodes: migrateall: skip VMs whose CPU is incompatible with the target Jonas Theisen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal