]> git.proxmox.com Git - qemu-server.git/commitdiff
Use default values from load_defaults() when none is specified in conf
authorEmmanuel Kasper <e.kasper@proxmox.com>
Tue, 12 Dec 2017 10:56:15 +0000 (11:56 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 15 Dec 2017 12:05:59 +0000 (13:05 +0100)
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 <e.kasper@proxmox.com>
PVE/QemuServer.pm

index 1d1ae29310781cf81bfe2e1db75ba2ab93d30184..42c412a72e4aafc53cfbfbff37de7f48cb7f9b75 100644 (file)
@@ -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;