]> git.proxmox.com Git - qemu-server.git/commitdiff
fix #2318: allow phys-bits CPU setting
authorStefan Reiter <s.reiter@proxmox.com>
Tue, 7 Apr 2020 13:56:19 +0000 (15:56 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 7 Apr 2020 15:27:58 +0000 (17:27 +0200)
Can be specified for a particular VM or via a custom CPU model (VM takes
precedence).

QEMU's default limit only allows up to 1TB of RAM per VM. Increasing the
physical address bits available to a VM can fix this.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
PVE/QemuServer/CPUConfig.pm

index af31b2b08abddf024249605cb9b952a92283349f..b08588ee39e0e1cad7be4bc167dbd57ee0fb5642 100644 (file)
@@ -149,8 +149,36 @@ my $cpu_fmt = {
        pattern => qr/$cpu_flag_any_re(;$cpu_flag_any_re)*/,
        optional => 1,
     },
+    'phys-bits' => {
+       type => 'string',
+       format => 'pve-phys-bits',
+       description => "The physical memory address bits that are reported to"
+                    . " the guest OS. Should be smaller or equal to the host's."
+                    . " Set to 'host' to use value from host CPU, but note that"
+                    . " doing so will break live migration to CPUs with other values.",
+       optional => 1,
+    },
 };
 
+PVE::JSONSchema::register_format('pve-phys-bits', \&parse_phys_bits);
+sub parse_phys_bits {
+    my ($str, $noerr) = @_;
+
+    my $err_msg = "value must be an integer between 8 and 64 or 'host'\n";
+
+    if ($str !~ m/^(host|\d{1,2})$/) {
+       die $err_msg if !$noerr;
+       return undef;
+    }
+
+    if ($str =~ m/^\d+$/ && (int($str) < 8 || int($str) > 64)) {
+       die $err_msg if !$noerr;
+       return undef;
+    }
+
+    return $str;
+}
+
 # $cpu_fmt describes both the CPU config passed as part of a VM config, as well
 # as the definition of a custom CPU model. There are some slight differences
 # though, which we catch in the custom verification function below.
@@ -472,6 +500,19 @@ sub get_cpu_options {
     $cpu_str .= resolve_cpu_flags($pve_flags, $hv_flags, $custom_cputype_flags,
                              $vm_flags, $pve_forced_flags);
 
+    my $phys_bits = '';
+    foreach my $conf ($custom_cpu, $cpu) {
+       next if !defined($conf);
+       my $conf_val = $conf->{'phys-bits'};
+       next if !$conf_val;
+       if ($conf_val eq 'host') {
+           $phys_bits = ",host-phys-bits=true";
+       } else {
+           $phys_bits = ",phys-bits=$conf_val";
+       }
+    }
+    $cpu_str .= $phys_bits;
+
     return ('-cpu', $cpu_str);
 }