[pve-devel] [RFC PATCH qemu-server 1/7] memory: cleanup
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue Dec 20 12:49:20 CET 2016
Note that hugepages comparisons are changed from numeric to
string since it's an enum string value which could be "any"
where the '==' comparison would trigger a warning.
---
PVE/QemuServer/Memory.pm | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm
index 0e4c830..67276d9 100644
--- a/PVE/QemuServer/Memory.pm
+++ b/PVE/QemuServer/Memory.pm
@@ -37,18 +37,18 @@ sub get_numa_guest_to_host_map {
return map { $_ => $_ } (0..($sockets-1));
}
-sub foreach_dimm{
+sub foreach_dimm {
my ($conf, $vmid, $memory, $sockets, $func) = @_;
my $dimm_id = 0;
my $current_size = 0;
my $dimm_size = 0;
- if($conf->{hugepages} && $conf->{hugepages} == 1024) {
- $current_size = 1024 * $sockets;
+ if($conf->{hugepages} && $conf->{hugepages} eq '1024') {
+ $current_size = $STATICMEM * $sockets;
$dimm_size = 1024;
} else {
- $current_size = 1024;
+ $current_size = $STATICMEM;
$dimm_size = 512;
}
@@ -76,7 +76,7 @@ sub foreach_reverse_dimm {
my $current_size = 0;
my $dimm_size = 0;
- if($conf->{hugepages} && $conf->{hugepages} == 1024) {
+ if($conf->{hugepages} && $conf->{hugepages} eq '1024') {
$current_size = 8355840;
$dimm_size = 131072;
} else {
@@ -114,7 +114,7 @@ sub qemu_memory_hotplug {
return $value if $value == $memory;
my $static_memory = $STATICMEM;
- $static_memory = $static_memory * $sockets if ($conf->{hugepages} && $conf->{hugepages} == 1024);
+ $static_memory *= $sockets if ($conf->{hugepages} && $conf->{hugepages} eq '1024');
die "memory can't be lower than $static_memory MB" if $value < $static_memory;
die "you cannot add more memory than $MAX_MEM MB!\n" if $memory > $MAX_MEM;
@@ -226,7 +226,7 @@ sub config {
$sockets = $conf->{sockets} if $conf->{sockets};
$static_memory = $STATICMEM;
- $static_memory = $static_memory * $sockets if ($conf->{hugepages} && $conf->{hugepages} == 1024);
+ $static_memory *= $sockets if ($conf->{hugepages} && $conf->{hugepages} eq '1024');
die "minimum memory must be ${static_memory}MB\n" if($memory < $static_memory);
push @$cmd, '-m', "size=${static_memory},slots=255,maxmem=${MAX_MEM}M";
@@ -435,7 +435,7 @@ sub hugepages_topology {
if ($hotplug_features->{memory}) {
$static_memory = $STATICMEM;
- $static_memory = $static_memory * $sockets if ($conf->{hugepages} && $conf->{hugepages} == 1024);
+ $static_memory *= $sockets if ($conf->{hugepages} && $conf->{hugepages} eq '1024');
} else {
$static_memory = $memory;
}
--
2.1.4
More information about the pve-devel
mailing list