find common flags && vendor between differents hosts if vendor are different (amd/intel), return default vendor
Signed-off-by: Alexandre Derumier <aderum...@odiso.com> --- PVE/QemuServer/CPUConfig.pm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm index 63e57d4..3f24b31 100644 --- a/PVE/QemuServer/CPUConfig.pm +++ b/PVE/QemuServer/CPUConfig.pm @@ -741,6 +741,38 @@ sub find_best_cpumodel { } } +sub find_hosts_common_flags { + my ($hosts_cpuinfo) = @_; + + my $common_vendor = undef; + my $common_flags = {}; + + my $hosts_flags = {}; + my $last_vendor = undef; + foreach my $cpuinfo (@$hosts_cpuinfo) { + my $flags = get_host_cpu_flags($cpuinfo); + foreach my $flag (keys %$flags) { + $hosts_flags->{$flag}++; + } + + if ($last_vendor && $cpuinfo->{vendor} ne $last_vendor) { + $common_vendor = 'default'; + } else { + $last_vendor = $cpuinfo->{vendor}; + $common_vendor = $last_vendor; + } + } + + my $nb_hosts = @{$hosts_cpuinfo}; + foreach my $flag (keys %$hosts_flags) { + if ($hosts_flags->{$flag} == $nb_hosts) { + $common_flags->{$flag} = 1; + } + } + + return ($common_flags, $common_vendor); +} + __PACKAGE__->register(); __PACKAGE__->init(); -- 2.30.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel