[pve-devel] [PATCH qemu-server] Use schema default values as default values

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Nov 20 14:38:28 CET 2017


On Wed, Nov 15, 2017 at 11:58:29AM +0100, Emmanuel Kasper wrote:
> Any feedback on this ?

there already is a "load_defaults" in QemuServer.pm, I'd re-use that.
what about options with default values besides those four?

> 
> On 10/23/2017 10:45 AM, Emmanuel Kasper wrote:
> > This fix a bug where VMs where the memory parameter was not
> > set where reported as having 0MB instead of 512 via `qm list`
> > 
> > Signed-off-by: Emmanuel Kasper <e.kasper at proxmox.com>
> > ---
> >  PVE/QemuServer.pm | 14 +++++++++++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> > 
> > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> > index 2b6fda9..6706e75 100644
> > --- a/PVE/QemuServer.pm
> > +++ b/PVE/QemuServer.pm
> > @@ -2576,6 +2576,11 @@ sub vmstatus {
> >  
> >      my $cpucount = $cpuinfo->{cpus} || 1;
> >  
> > +    my $def_sockets = $confdesc->{sockets}->{default};
> > +    my $def_cores = $confdesc->{cores}->{default};
> > +    my $def_memory = $confdesc->{memory}->{default};
> > +    my $def_shares = $confdesc->{shares}->{default};
> > +
> >      foreach my $vmid (keys %$list) {
> >  	next if $opt_vmid && ($vmid ne $opt_vmid);
> >  
> > @@ -2597,16 +2602,19 @@ sub vmstatus {
> >  	    $d->{maxdisk} = 0;
> >  	}
> >  
> > -	$d->{cpus} = ($conf->{sockets} || 1) * ($conf->{cores} || 1);
> > +	$d->{cpus} = ($conf->{sockets} || $def_sockets)
> > +	    * ($conf->{cores} || $def_cores);
> >  	$d->{cpus} = $cpucount if $d->{cpus} > $cpucount;
> >  	$d->{cpus} = $conf->{vcpus} if $conf->{vcpus};
> >  
> >  	$d->{name} = $conf->{name} || "VM $vmid";
> > -	$d->{maxmem} = $conf->{memory} ? $conf->{memory}*(1024*1024) : 0;
> > +	$d->{maxmem} = ($conf->{memory} ? $conf->{memory} : $def_memory)
> > +	    * (1024*1024);
> >  
> >  	if ($conf->{balloon}) {
> >  	    $d->{balloon_min} = $conf->{balloon}*(1024*1024);
> > -	    $d->{shares} = defined($conf->{shares}) ? $conf->{shares} : 1000;
> > +	    $d->{shares} = defined($conf->{shares}) ? $conf->{shares}
> > +		: $def_shares;
> >  	}
> >  
> >  	$d->{uptime} = 0;
> > 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list