Commit 103a7e62 authored by Dietmar Maurer's avatar Dietmar Maurer

cleanup and fix openvz vswap handling

parent 81fe53f6
......@@ -713,7 +713,7 @@ __PACKAGE__->register_method({
my $stcfg = cfs_read_file("storage.cfg");
if ($veconf->{ve_private} && $conf->{ve_private}->{value}) {
if ($veconf->{ve_private} && $veconf->{ve_private}->{value}) {
my $path = PVE::OpenVZ::get_privatedir($veconf, $param->{vmid});
my ($vtype, $volid) = PVE::Storage::path_to_volume_id($stcfg, $path);
my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1) if $volid;
......@@ -737,16 +737,7 @@ __PACKAGE__->register_method({
}
}
if (defined($conf->{swappages})) {
$conf->{memory} = $veconf->{physpages}->{lim} ?
int(($veconf->{physpages}->{lim} * 4)/ 1024) : 512;
$conf->{swap} = $veconf->{swappages}->{lim} ?
int(($veconf->{swappages}->{lim} * 4)/1024) : 0;
} else {
$conf->{memory} = $veconf->{vmguarpages}->{bar} ?
int(($veconf->{vmguarpages}->{bar} * 4)/ 1024) : 512;
$conf->{swap} = 0;
}
($conf->{memory}, $conf->{swap}) = PVE::OpenVZ::ovz_config_extract_mem_swap($veconf, 1024*1024);
my $diskspace = $veconf->{diskspace}->{bar} || LONG_MAX;
if ($diskspace == LONG_MAX) {
......
......@@ -209,18 +209,10 @@ sub vmstatus {
$d->{disk} = 0;
$d->{maxdisk} = int($conf->{diskspace}->{bar} * 1024);
if (defined($conf->{swappages})) {
$d->{mem} = 0;
$d->{maxmem} = int((($conf->{physpages}->{lim} +
$conf->{swappages}->{lim})* 4096));
$d->{swap} = 0;
$d->{maxswap} = int((($conf->{swappages}->{lim})* 4096));
} else {
$d->{mem} = 0;
$d->{maxmem} = int($conf->{vmguarpages}->{bar} * 4096);
$d->{swap} = 0;
$d->{maxswap} = 0;
}
$d->{mem} = 0;
$d->{swap} = 0;
($d->{maxmem}, $d->{maxswap}) = ovz_config_extract_mem_swap($conf);
$d->{nproc} = 0;
$d->{failcnt} = 0;
......@@ -365,7 +357,7 @@ my $confdesc = {
optional => 1,
type => 'integer',
description => "Amount of SWAP for the VM in MB.",
minimum => 16,
minimum => 0,
default => 512,
},
disk => {
......@@ -879,29 +871,52 @@ sub create_config_line {
}
}
sub ovz_config_extract_mem_swap {
my ($veconf, $unit) = @_;
$unit = 1 if !$unit;
my ($mem, $swap) = (int((512*1024*1024 + $unit - 1)/$unit), 0);
my $maxpages = ($res_unlimited / 4096);
if ($veconf->{swappages}) {
if ($veconf->{physpages} && $veconf->{physpages}->{lim} &&
($veconf->{physpages}->{lim} < $maxpages)) {
$mem = int(($veconf->{physpages}->{lim} * 4096 + $unit - 1) / $unit);
}
if ($veconf->{swappages}->{lim} && ($veconf->{swappages}->{lim} < $maxpages)) {
$swap = int (($veconf->{swappages}->{lim} * 4096 + $unit - 1) / $unit);
}
} else {
if ($veconf->{vmguarpages} && $veconf->{vmguarpages}->{bar} &&
($veconf->{vmguarpages}->{bar} < $maxpages)) {
$mem = int(($veconf->{vmguarpages}->{bar} * 4096 + $unit - 1) / $unit);
}
}
return ($mem, $swap);
}
sub update_ovz_config {
my ($vmid, $veconf, $param) = @_;
my $changes = [];
# test if barrier or limit changed
my $push_bl_changes = sub {
my ($name, $bar, $lim) = @_;
my $old = format_res_bar_lim($name, $veconf->{$name});
my $old = format_res_bar_lim($name, $veconf->{$name})
if $veconf->{$name} && defined($veconf->{$name}->{bar});
my $new = format_res_bar_lim($name, { bar => $bar, lim => $lim });
if ($old ne $new) {
if (!$old || ($old ne $new)) {
$veconf->{$name}->{bar} = $bar;
$veconf->{$name}->{lim} = $lim;
push @$changes, "--$name", $new;
}
};
my $mem = $veconf->{physpages}->{lim} ?
int (($veconf->{physpages}->{lim} * 4) / 1024) : 512;
my $swap = $veconf->{swappages}->{lim} ?
int (($veconf->{swappages}->{lim} * 4) / 1024) : 0;
my ($mem, $swap) = ovz_config_extract_mem_swap($veconf, 1024*1024);
my $disk = ($veconf->{diskspace}->{bar} || $res_unlimited) / (1024*1024);
my $cpuunits = $veconf->{cpuunits}->{value} || 1000;
my $quotatime = $veconf->{quotatime}->{value} || 0;
......
pve-manager (2.0-36) unstable; urgency=low
* cleanup and fix openvz vswap handling
-- Proxmox Support Team <support@proxmox.com> Wed, 29 Feb 2012 09:20:58 +0100
pve-manager (2.0-35) unstable; urgency=low
* avoid warning in pvestatd for containers with old config files
......
......@@ -2,7 +2,7 @@ RELEASE=2.0
VERSION=2.0
PACKAGE=pve-manager
PACKAGERELEASE=35
PACKAGERELEASE=36
BINDIR=${DESTDIR}/usr/bin
PERLLIBDIR=${DESTDIR}/usr/share/perl5
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment