From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 239F01FF0BC for ; Wed, 02 Dec 2026 16:21:48 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 27E28219EA; Wed, 02 Dec 2026 16:20:03 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v4 13/21] migrate: block live migration if the target cannot run the virtual CPU Date: Wed, 2 Dec 2026 16:18:09 +0100 Message-ID: <20261202151831.414110-14-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261202151831.414110-1-j.theisen@proxmox.com> References: <20261202151831.414110-1-j.theisen@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1796224745322 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.054 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 4CUU7EGJIBSTCW7F6CV7MO4GSR56VXNQ X-Message-ID-Hash: 4CUU7EGJIBSTCW7F6CV7MO4GSR56VXNQ X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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. It can contain flags that KVM on the target does not support, like the Intel-only 'hv-evmcs' enlightenment 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. The same applies to all CPU models that do not pass through the host CPU, like 'x86-64-v3' or 'Skylake-Server'. Their QEMU CPU is generated again, mostly with the same flags, and as 'enforce' is set for them, QEMU on the target refuses to start if KVM lacks any flag the model enables, including its defaults. Hyper-V enlightenments are required regardless of 'enforce', so this also applies to those PVE enables for Windows guests with 'host' and 'max'. Check upfront whether KVM on the target supports all enabled Hyper-V enlightenments of the virtual CPU, and all its other enabled flags if 'enforce' is set. This is not needed with TCG, which emulates all flags. The default flags of a CPU model are queried from QEMU of the running VM, the flags of the target from the pvestatd broadcast. The precondition API reports all missing flags as details. Skipped are: - the automatically enabled 'hv-evmcs' on non-Intel targets, as a regenerated CPU only enables it on Intel, unless set for the VM - flags KVM on the source does not support, and other flags than enlightenments that QEMU does not recognize as flags, as they are QEMU CPU properties, like 'host-phys-bits'; enlightenments only if the source broadcasts any, as nodes broadcast none if their flags were detected before qemu-server 9.1.17 If the target broadcasts no enlightenments, its support is unknown, so missing ones only cause a warning. As PVE sets 'enforce' for 'max' with KVM as well, flags set for such VMs are reported by this check, and no longer by the overridable check of the flags passed through by 'host' and 'max', as QEMU on the target would refuse to start anyway. Signed-off-by: Jonas Theisen --- src/PVE/API2/Qemu.pm | 4 +- src/PVE/QemuMigrate/Helpers.pm | 130 ++++++++++++- src/test/MigrationTest/QemuMigrateMock.pm | 15 +- src/test/run_api_tests.pl | 4 + src/test/run_qemu_migrate_tests.pl | 217 +++++++++++++++++++++- 5 files changed, 359 insertions(+), 11 deletions(-) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index c78aa374..68f85afd 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -5626,7 +5626,8 @@ __PACKAGE__->register_method({ type => { type => 'string', description => "The check that failed.", - enum => ['cpu-vendor', 'host-cpu-flags'], + enum => + ['cpu-vendor', 'host-cpu-flags', 'vm-cpu-flags'], }, message => { type => 'string', @@ -5737,6 +5738,7 @@ __PACKAGE__->register_method({ 'missing-cpu-info', 'host-cpu-flags', 'host-cpu-model', + 'vm-cpu-flags', 'cpu-check-failed', ], }, diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm index 1e675721..20534b71 100644 --- a/src/PVE/QemuMigrate/Helpers.pm +++ b/src/PVE/QemuMigrate/Helpers.pm @@ -275,8 +275,11 @@ my sub get_missing_host_cpu_flags { my @flags = grep { !$understood || $understood->{$_} } keys $source_flags->%*; my @missing = sort grep { - # Hyper-V enlightenments are not passed through, but set explicitly + # Hyper-V enlightenments are not passed through, but set explicitly. Flags that QEMU + # requires due to 'enforce' are reported by the 'vm-cpu-flags' check, as overriding it + # would only let QEMU on the target refuse to start. !m/^hv-/ + && !($cpu->{enforce} && $cpu->{flags}->{$_}) && !$target_flags->{$_} && (PVE::JSONSchema::parse_boolean($cpu->{props}->{$_} // 'on') // 1) } @flags; @@ -286,6 +289,50 @@ my sub get_missing_host_cpu_flags { return ($other, $info); } +# Returns the flags of the VM's virtual CPU that KVM on the target node does not support, and those +# whose support is unknown, as the node does not report them. +my sub get_missing_vm_cpu_flags { + my ($cpu, $source, $target) = @_; + + my ($source_flags, $target_flags) = ($source->{'kvm-flags'}, $target->{'kvm-flags'}); + + # Flags detected before qemu-server 9.1.17 do not include Hyper-V enlightenments. + my ($source_reports_hv, $target_reports_hv) = + map { + scalar(grep { m/^hv-/ } keys $_->%*) + } $source_flags, $target_flags; + + # The automatic hv-evmcs of a CPU that is generated again is only enabled on Intel targets. + my $target_omits_evmcs = $cpu->{'automatic-evmcs'} + && (!defined($target->{vendor}) + || !PVE::QemuServer::CPUConfig::is_hyperv_evmcs_vendor($target->{vendor})); + + my $understood = $source->{'understood-flags'}; + + my ($missing, $unknown) = ([], []); + for my $flag (sort keys $cpu->{flags}->%*) { + next if $target_flags->{$flag}; + if ($flag =~ m/^hv-/) { + # QEMU refuses to start with unsupported Hyper-V enlightenments, regardless of + # 'enforce' and whether the CPU model passes through the host CPU + next if $flag eq 'hv-evmcs' && $target_omits_evmcs; + # skips properties that are no enlightenments, as far as the source reports them + next if $source_reports_hv && !$source_flags->{$flag}; + push(($target_reports_hv ? $missing : $unknown)->@*, $flag); + } elsif ( + $cpu->{enforce} + && $source_flags->{$flag} + && (!$understood || $understood->{$flag}) + ) { + # Other flags only with 'enforce'. Like for the CPU model's flags, this skips + # properties that are no CPU flags, such as 'host-phys-bits'. + push $missing->@*, $flag; + } + } + + return ($missing, $unknown); +} + # Checks whether the CPU of a target node can run a running VM after a live migration. Each check # has: # - 'type', identifying the check @@ -300,6 +347,11 @@ my sub get_missing_host_cpu_flags { # # The VM's CPU is parsed by parse_qemu_cpu_string(), with: # - 'kvm' set if the VM uses KVM +# - 'enforce' set if QEMU refuses to start without all enabled flags +# - 'automatic-evmcs' set if hv-evmcs is enabled automatically and the CPU is generated again on +# the target, which then enables it depending on its CPU vendor +# - the enabled flags as 'flags' hash, including the flags the CPU model enables by default if +# 'enforce' is set # # The CPU information of the nodes is in the format of get_host_cpu_info(), plus: # - the CPU flags KVM supports as 'kvm-flags' hash @@ -416,6 +468,47 @@ my $target_cpu_checks = [ return ($message, $details); }, }, + { + type => 'vm-cpu-flags', + severity => 'error', + needs => ['kvm-flags'], + applies => sub { + my ($cpu) = @_; + # With TCG, all flags are emulated. + return $cpu->{kvm}; + }, + check => sub { + my ($cpu, $source, $target) = @_; + + my ($missing) = get_missing_vm_cpu_flags($cpu, $source, $target); + return if !scalar($missing->@*); + + my $message = "KVM on the node does not support flags of the VM's virtual CPU: " + . format_flag_list($missing); + return ($message, { 'missing-flags' => $missing }); + }, + }, + { + type => 'vm-cpu-flags', + severity => 'warning', + needs => ['kvm-flags'], + applies => sub { + my ($cpu) = @_; + return $cpu->{kvm}; + }, + check => sub { + my ($cpu, $source, $target) = @_; + + my (undef, $unknown) = get_missing_vm_cpu_flags($cpu, $source, $target); + return if !scalar($unknown->@*); + + my $message = + "KVM on the node might not support flags of the VM's virtual CPU, as the node" + . " does not report them, for example as they were detected by an older version: " + . format_flag_list($unknown); + return ($message, { 'missing-flags' => $unknown }); + }, + }, ]; # Returns the issues of the target node. If it lacks CPU information needed by a check that can @@ -462,6 +555,18 @@ my sub get_target_cpu_issues { return $issues; } +# Returns the flags a CPU model enables by default, as QEMU of the running VM defines them. +my sub get_cpu_model_flags { + my ($vmid, $model, $understood) = @_; + + my $expansion = + mon_cmd($vmid, 'query-cpu-model-expansion', type => 'full', model => { name => $model }); + + # the expansion also includes CPU properties that are no flags + return [grep { !$understood || $understood->{$_} } + PVE::QemuServer::CPUFlags::get_cpu_expansion_flags($expansion)]; +} + =head3 is_running_cpu_kept my $kept = is_running_cpu_kept($conf); @@ -509,6 +614,27 @@ sub check_target_cpu_compatibility { my $cpu = parse_qemu_cpu_string(PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid)); my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf); $cpu->{kvm} = $conf->{kvm} // PVE::QemuServer::CPUConfig::is_native_arch($arch); + $cpu->{enforce} = PVE::JSONSchema::parse_boolean($cpu->{props}->{enforce} // 'off'); + + my $understood = get_understood_cpu_flags(); + + $cpu->{flags} = {}; + if ($cpu->{enforce} && $cpu->{kvm} && !is_host_cpu_model($cpu)) { + my $model_flags = eval { get_cpu_model_flags($vmid, $cpu->{model}, $understood) }; + warn "unable to query the flags of CPU model '$cpu->{model}' - $@" if $@; + $cpu->{flags}->{$_} = 1 for ($model_flags // [])->@*; + } + for my $prop (keys $cpu->{props}->%*) { + my $enabled = PVE::JSONSchema::parse_boolean($cpu->{props}->{$prop}); + next if !defined($enabled); + $enabled ? ($cpu->{flags}->{$prop} = 1) : delete($cpu->{flags}->{$prop}); + } + + if ($cpu->{flags}->{'hv-evmcs'} && !is_running_cpu_kept($conf)) { + my $cpu_conf = $conf->{cpu} ? parse_property_string('pve-vm-cpu-conf', $conf->{cpu}) : {}; + my $vm_flags = $cpu_conf->{flags} // ''; + $cpu->{'automatic-evmcs'} = 1 if !grep { $_ eq '+hv-evmcs' } split(/;/, $vm_flags); + } my $checks = [grep { $_->{applies}->($cpu) } $target_cpu_checks->@*]; return {} if !scalar($checks->@*); @@ -519,7 +645,7 @@ sub check_target_cpu_compatibility { 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); - $source_info->{'understood-flags'} = get_understood_cpu_flags(); + $source_info->{'understood-flags'} = $understood; my $issues_by_node = {}; for my $node ($nodes->@*) { diff --git a/src/test/MigrationTest/QemuMigrateMock.pm b/src/test/MigrationTest/QemuMigrateMock.pm index b6e035b8..6554c37e 100644 --- a/src/test/MigrationTest/QemuMigrateMock.pm +++ b/src/test/MigrationTest/QemuMigrateMock.pm @@ -239,6 +239,15 @@ $MigrationTest::Shared::qemu_migrate_helpers_module->mock( return $MigrationTest::Shared::qemu_migrate_helpers_module->original( 'check_target_cpu_compatibility')->(@_); }, + mon_cmd => sub { + my ($vmid, $command, %params) = @_; + + if ($command eq 'query-cpu-model-expansion') { + my $flags = $test_cpu_info->{'model-flags'}->{ $params{model}->{name} } // []; + return { model => { props => { map { $_ => JSON::true } $flags->@* } } }; + } + die "mon_cmd (mocked) - implement me: $command"; + }, ); $MigrationTest::Shared::cluster_module->mock( @@ -262,8 +271,10 @@ $MigrationTest::Shared::cluster_module->mock( my $qemu_server_cpuflags_module = Test::MockModule->new("PVE::QemuServer::CPUFlags"); $qemu_server_cpuflags_module->mock( query_understood_cpu_flags => sub { - return [ - qw(avx512f fpu gds-no hv-relaxed its-no lahf-lm srso-no sse sse4.2 tsa-l1-no tsx-ctrl)]; + return [qw( + abm aes avx avx2 avx512f avx512vl fpu gds-no hv-relaxed its-no kvm-pv-eoi lahf-lm pcid + srso-no sse sse4.2 svm tsa-l1-no tsx-ctrl vmx + )]; }, ); diff --git a/src/test/run_api_tests.pl b/src/test/run_api_tests.pl index bc8686e1..195e889c 100755 --- a/src/test/run_api_tests.pl +++ b/src/test/run_api_tests.pl @@ -363,6 +363,8 @@ subtest 'migration preconditions of the CPU of a running VM' => sub { check_local_resources => sub { return ([], {}, { map { $_ => [] } $nodes->@* }); }, + # the expansion of the CPU model, which enables no flags by default + mon_cmd => sub { return { model => { props => {} } }; }, ); my $cpu_flags_module = Test::MockModule->new('PVE::QemuServer::CPUFlags'); $cpu_flags_module->mock( @@ -422,6 +424,8 @@ subtest 'migration preconditions of the CPU of a running VM' => sub { $cpu_reasons->('kvm64,enforce,+avx512f,+kvm_pv_eoi,+kvm_pv_unhalt'), { 'other-vendor' => ['warning: cpu-vendor'], + 'missing-flag' => ['vm-cpu-flags'], + 'no-cpu-info' => ['warning: missing-cpu-info'], }, 'reasons for another CPU model', ); diff --git a/src/test/run_qemu_migrate_tests.pl b/src/test/run_qemu_migrate_tests.pl index 1e17090e..2b9f812a 100755 --- a/src/test/run_qemu_migrate_tests.pl +++ b/src/test/run_qemu_migrate_tests.pl @@ -564,18 +564,19 @@ my $lacks_avx512f = # Returns a test of the CPU checks for a live migration of VM 1033 to 'pve1'. The VM is configured # with the CPU 'cpu' and further settings in 'config', and runs with the QEMU CPU 'runningcpu'. -# 'cpu_info' overrides $default_cpu_info. Without 'expect_die', the migration must succeed. -# Warnings and errors about the CPU must be expected. Other keys are passed through. +# 'cpu_info' overrides $default_cpu_info. Without 'expect_die', the migration must succeed, and the +# target keeps the QEMU CPU if 'cpu_kept' is set. Warnings and errors about the CPU must be +# expected. Other keys are passed through. sub cpu_migration_test { my (%test) = @_; - my $runningcpu = delete $test{runningcpu}; + my ($runningcpu, $cpu_kept) = delete @test{qw(runningcpu cpu_kept)}; my $config_patch = { (delete($test{config}) // {})->%* }; my $cpu = delete $test{cpu}; $config_patch->{cpu} = $cpu if defined($cpu); my $expected_status = { running => 1, runningmachine => 'pc-q35-5.0+pve0' }; - $expected_status->{runningcpu} = $runningcpu if $test{expect_die}; + $expected_status->{runningcpu} = $runningcpu if $test{expect_die} || $cpu_kept; return { target => 'pve1', @@ -608,8 +609,9 @@ 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', and the KVM CPU flags of each node in - # 'kvm-flags'. With 'check-error', the CPU check fails with it. + # other node in 'nodes', the KVM CPU flags of each node in + # 'kvm-flags', and the flags each CPU model enables by default in + # 'model-flags'. With 'check-error', the CPU check fails with it. # See cpu_migration_test() for tests of the CPU checks. # expected_calls - hash whose keys are calls which are required # to be made if the migration gets far enough @@ -1805,6 +1807,209 @@ my $tests = [ . " 2.00GHz'", ], ), + cpu_migration_test( + name => '1033_running_kept_cpu_supported_flags', + cpu => 'kvm64,flags=+nested-virt', + runningcpu => 'kvm64,enforce,+vmx,hv_evmcs,hv_relaxed,hv_spinlocks=0x1fff,+kvm_pv_eoi', + cpu_kept => 1, + cpu_info => { + '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', + }, + }, + ), + cpu_migration_test( + name => '1033_running_kept_cpu_unsupported_flags', + cpu => 'kvm64,flags=+nested-virt', + runningcpu => 'kvm64,enforce,+vmx,hv_evmcs,hv_relaxed,hv_spinlocks=0x1fff,+kvm_pv_eoi', + cpu_info => { + 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', + }, + }, + expect_die => "can't migrate VM to 'pve1' - incompatible CPU: KVM on the node does not" + . " support flags of the VM's virtual CPU: hv-evmcs, vmx", + ), + cpu_migration_test( + # hv-evmcs is only enabled on Intel hosts, so the target generates the CPU without it + name => '1033_running_builtin_cpu_hv_evmcs_other_vendor', + cpu => 'x86-64-v2-AES', + config => { ostype => 'win11' }, + runningcpu => 'qemu64,+aes,enforce,hv_evmcs,hv_relaxed,+kvm_pv_eoi,+sse4.2', + cpu_info => { + nodes => { pve1 => { vendor => 'AuthenticAMD' } }, + 'kvm-flags' => { + pve0 => 'aes fpu hv-evmcs hv-relaxed kvm-pv-eoi sse sse4.2 vmx', + pve1 => 'aes fpu hv-relaxed kvm-pv-eoi sse sse4.2 svm', + }, + }, + expect_log => [ + "CPU of node 'pve1' might be incompatible: live migration from GenuineIntel to" + . " AuthenticAMD is not guaranteed to work", + ], + ), + cpu_migration_test( + # 'max' with KVM also sets 'enforce', so QEMU requires flags set for the VM regardless of + # the override for 'host-cpu-flags' + name => '1033_running_max_cpu_missing_vm_flag', + cpu => 'max,flags=+pcid', + runningcpu => 'max,enforce,+kvm_pv_eoi,+kvm_pv_unhalt,+pcid', + opts => { 'allow-missing-cpu-flags' => 1 }, + cpu_info => { + 'kvm-flags' => { pve0 => 'fpu pcid sse', pve1 => 'fpu sse' }, + }, + expect_die => "can't migrate VM to 'pve1' - incompatible CPU: KVM on the node does not" + . " support flags of the VM's virtual CPU: pcid", + ), + cpu_migration_test( + # an Intel target enables hv-evmcs as well when generating the CPU + name => '1033_running_builtin_cpu_hv_evmcs_unsupported', + cpu => 'x86-64-v2-AES', + config => { ostype => 'win11' }, + runningcpu => 'qemu64,+aes,enforce,hv_evmcs,hv_relaxed,+kvm_pv_eoi,+sse4.2', + cpu_info => { + 'kvm-flags' => { + pve0 => 'aes fpu hv-evmcs hv-relaxed kvm-pv-eoi sse sse4.2 vmx', + pve1 => 'aes fpu hv-relaxed kvm-pv-eoi sse sse4.2 vmx', + }, + }, + expect_die => "can't migrate VM to 'pve1' - incompatible CPU: KVM on the node does not" + . " support flags of the VM's virtual CPU: hv-evmcs", + ), + cpu_migration_test( + # hv-evmcs set for the VM is also enabled on other targets + name => '1033_running_builtin_cpu_vm_hv_evmcs_other_vendor', + cpu => 'x86-64-v2-AES,flags=+hv-evmcs', + config => { ostype => 'win11' }, + runningcpu => 'qemu64,+aes,enforce,+hv-evmcs,hv_evmcs,hv_relaxed,+kvm_pv_eoi,+sse4.2', + cpu_info => { + nodes => { pve1 => { vendor => 'AuthenticAMD' } }, + 'kvm-flags' => { + pve0 => 'aes fpu hv-evmcs hv-relaxed kvm-pv-eoi sse sse4.2 vmx', + pve1 => 'aes fpu hv-relaxed kvm-pv-eoi sse sse4.2 svm', + }, + }, + expect_die => "can't migrate VM to 'pve1' - incompatible CPU: KVM on the node does not" + . " support flags of the VM's virtual CPU: hv-evmcs", + ), + cpu_migration_test( + # QEMU applies flags with '-' last, so the VM does not use hv-evmcs + name => '1033_running_kept_cpu_hv_evmcs_disabled', + cpu => 'x86-64-v2-AES,flags=+nested-virt;-hv-evmcs', + config => { ostype => 'win11' }, + runningcpu => + 'qemu64,+aes,enforce,-hv-evmcs,hv_evmcs,hv_relaxed,+kvm_pv_eoi,+sse4.2,+vmx', + cpu_kept => 1, + cpu_info => { + 'kvm-flags' => { + pve0 => 'aes fpu hv-evmcs hv-relaxed kvm-pv-eoi sse sse4.2 vmx', + pve1 => 'aes fpu hv-relaxed kvm-pv-eoi sse sse4.2 vmx', + }, + }, + ), + cpu_migration_test( + # KVM requires the enlightenments, even though 'host' does not set 'enforce' + name => '1033_running_host_cpu_missing_hv_flags', + cpu => 'host', + config => { ostype => 'win11' }, + runningcpu => 'host,hv_relaxed,hv_stimer,hv_synic,+kvm_pv_eoi,+kvm_pv_unhalt', + cpu_info => { + 'kvm-flags' => { + pve0 => 'fpu hv-relaxed hv-stimer hv-synic sse', + pve1 => 'fpu hv-relaxed hv-synic sse', + }, + }, + expect_die => "can't migrate VM to 'pve1' - incompatible CPU: KVM on the node does not" + . " support flags of the VM's virtual CPU: hv-stimer", + ), + cpu_migration_test( + # flags detected before qemu-server 9.1.17 include no Hyper-V enlightenments + name => '1033_running_host_cpu_hv_flags_target_without_hv_info', + cpu => 'host', + config => { ostype => 'win11' }, + runningcpu => 'host,hv_relaxed,hv_stimer,hv_synic,+kvm_pv_eoi,+kvm_pv_unhalt', + cpu_info => { + 'kvm-flags' => { + pve0 => 'fpu hv-relaxed hv-stimer hv-synic sse', + pve1 => 'fpu sse', + }, + }, + expect_log => [ + "CPU of node 'pve1' might be incompatible: KVM on the node might not support flags" + . " of the VM's virtual CPU, as the node does not report them, for example as they" + . " were detected by an older version: hv-relaxed, hv-stimer, hv-synic", + ], + ), + cpu_migration_test( + # with TCG, all flags are emulated + name => '1033_running_kept_cpu_tcg_target_without_kvm_flags', + cpu => 'custom-mycpu', + config => { kvm => 0 }, + runningcpu => 'kvm64,enforce,+sse4.2', + cpu_kept => 1, + cpu_info => { + 'kvm-flags' => { pve1 => undef }, + }, + ), + cpu_migration_test( + name => '1033_running_builtin_cpu_missing_flags', + cpu => 'x86-64-v3', + runningcpu => + 'qemu64,enforce,+abm,+aes,+avx,+avx2,+kvm_pv_eoi,+sse4.2,vendor=GenuineIntel', + cpu_info => { + 'kvm-flags' => { + pve0 => 'abm aes avx avx2 fpu kvm-pv-eoi sse sse4.2', + pve1 => 'abm aes avx fpu kvm-pv-eoi sse sse4.2', + }, + }, + expect_die => "can't migrate VM to 'pve1' - incompatible CPU: KVM on the node does not" + . " support flags of the VM's virtual CPU: avx2", + ), + cpu_migration_test( + # QEMU CPU properties that are no flags do not depend on KVM + name => '1033_running_builtin_cpu_property_not_flag', + cpu => 'x86-64-v3', + runningcpu => 'qemu64,enforce,+avx,host-phys-bits=on,+kvm_pv_eoi,vendor=GenuineIntel', + cpu_info => { + 'kvm-flags' => { + pve0 => 'avx fpu host-phys-bits kvm-pv-eoi sse', + pve1 => 'avx fpu kvm-pv-eoi sse', + }, + }, + ), + cpu_migration_test( + name => '1033_running_named_cpu_missing_model_flags', + cpu => 'Skylake-Server', + runningcpu => 'Skylake-Server,enforce,+kvm_pv_eoi,-avx512vl', + cpu_info => { + 'kvm-flags' => { + pve0 => 'avx512f avx512vl fpu kvm-pv-eoi migratable sse sse4.2', + pve1 => 'fpu kvm-pv-eoi sse', + }, + 'model-flags' => { + 'Skylake-Server' => [qw(avx512f avx512vl fpu migratable sse sse4_2)], + }, + }, + expect_die => "can't migrate VM to 'pve1' - incompatible CPU: KVM on the node does not" + . " support flags of the VM's virtual CPU: avx512f, sse4.2", + ), + cpu_migration_test( + name => '1033_running_named_cpu_supported_model_flags', + cpu => 'Skylake-Server', + runningcpu => 'Skylake-Server,enforce,+kvm_pv_eoi,-avx512vl', + cpu_info => { + 'kvm-flags' => { + pve0 => 'avx512f fpu kvm-pv-eoi migratable sse sse4.2', + pve1 => 'avx512f fpu kvm-pv-eoi sse sse4.2', + }, + 'model-flags' => { + 'Skylake-Server' => [qw(avx512f avx512vl fpu migratable sse sse4_2)], + }, + }, + ), { name => '105_replicated_to_non_replication_target', target => 'pve1', -- 2.47.3