From: Emmanuel Kasper Date: Tue, 12 Dec 2017 10:56:15 +0000 (+0100) Subject: Use default values from load_defaults() when none is specified in conf X-Git-Url: https://git.proxmox.com/?p=qemu-server.git;a=commitdiff_plain;h=3618ee99aa4db4487b606ab90f6ac11ed9240245 Use default values from load_defaults() when none is specified in conf This also fixes a bug where VMs with no memory defined in the config where reported as using 0MB instead of 512. Signed-off-by: Emmanuel Kasper --- diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 1d1ae29..42c412a 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2591,6 +2591,8 @@ sub vmstatus { my $storecfg = PVE::Storage::config(); my $list = vzlist(); + my $defaults = load_defaults(); + my ($uptime) = PVE::ProcFSTools::read_proc_uptime(1); my $cpucount = $cpuinfo->{cpus} || 1; @@ -2616,16 +2618,19 @@ sub vmstatus { $d->{maxdisk} = 0; } - $d->{cpus} = ($conf->{sockets} || 1) * ($conf->{cores} || 1); + $d->{cpus} = ($conf->{sockets} || $defaults->{sockets}) + * ($conf->{cores} || $defaults->{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}*(1024*1024) + : $defaults->{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} + : $defaults->{shares}; } $d->{uptime} = 0;