[pve-devel] [PATCH v9 qemu-server 5/6] fix #2318: allow phys-bits and host-phys-bits CPU settings

Fabian Ebner f.ebner at proxmox.com
Tue Apr 7 09:08:37 CEST 2020


On 06.04.20 15:01, Stefan Reiter wrote:
> On 06/04/2020 14:34, Fabian Ebner wrote:
>> On 26.03.20 16:13, Stefan Reiter wrote:
>>> 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 at proxmox.com>
>>> ---
>>>   PVE/QemuServer/CPUConfig.pm | 24 ++++++++++++++++++++++++
>>>   1 file changed, 24 insertions(+)
>>>
>>> diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm
>>> index fa09f4b..2b2529d 100644
>>> --- a/PVE/QemuServer/CPUConfig.pm
>>> +++ b/PVE/QemuServer/CPUConfig.pm
>>> @@ -149,6 +149,19 @@ my $cpu_fmt = {
>>>       pattern => qr/$cpu_flag_any_re(;$cpu_flag_any_re)*/,
>>>       optional => 1,
>>>       },
>>> +    'phys-bits' => {
>>> +    type => 'integer',
>>> +    minimum => 8,
>>> +    maximum => 64,
>>> +    description => "The physical memory address bits that are 
>>> reported to the guest OS. Should be smaller or equal to the host's.",
>>> +    optional => 1,
>>> +    },
>>> +    'host-phys-bits' => {
>>> +    type => 'boolean',
>>> +    default => 0,
>>> +    description => "Whether to report the host's physical memory 
>>> address bits. Overrides 'phys-bits' when set.",
>>
>> Is it better to die when both are set, so that a user gets informed 
>> about the clashing options?
>>
> 
> Actually, how do you feel about making this a single 'string' option 
> 'phys-bits' and allowing /^(host|\d{1,2})$/ ? Would mean that min/max(?) 
> int values had to be checked manually, but I think it would make it 
> clearer for the user.
> 

Sounds good to me, then the dichotomy is explicit. And for checking, a 
'pve-phys-bits' format and verifier routine (which also does the min/max 
check) could be introduced. Then get_cpu_options already knows it'll 
either get "host" or a valid integer for pyhs-bits and doesn't have to 
check itself.

>>> +    optional => 1,
>>> +    },
>>>   };
>>>   # $cpu_fmt describes both the CPU config passed as part of a VM 
>>> config, as well
>>> @@ -472,6 +485,17 @@ 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);
>>> +    if ($conf->{'host-phys-bits'}) {
>>> +        $phys_bits = ",host-phys-bits=true";
>>> +    } elsif ($conf->{'phys-bits'}) {
>>> +        $phys_bits = ",phys-bits=$conf->{'phys-bits'}";
>>> +    }
>>> +    }
>>> +    $cpu_str .= $phys_bits;
>>> +
>>>       return ('-cpu', $cpu_str);
>>>   }
>>>




More information about the pve-devel mailing list