[pve-devel] [PATCH qemu-server] Use schema default values as default values
Emmanuel Kasper
e.kasper at proxmox.com
Mon Oct 23 10:45:11 CEST 2017
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;
--
2.11.0
More information about the pve-devel
mailing list