From 69fe1ea229e5d2c3a6ecc3fc3c5438790bfc8b05 Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Wed, 23 Dec 2015 12:27:11 -0500
Subject: [PATCH] Merge branch 'jnorell/ispconfig3-master'

---
 install/sql/ispconfig3.sql                       |    2 
 install/sql/incremental/upd_dev_collection.sql   |    3 +
 interface/web/vm/openvz_template_edit.php        |    2 
 interface/web/vm/templates/openvz.conf.tpl       |   84 +++++++++++++++++++++++++++++++++++++----
 interface/lib/plugins/vm_openvz_plugin.inc.php   |    4 +-
 remoting_client/examples/openvz_template_add.php |    4 +-
 6 files changed, 84 insertions(+), 15 deletions(-)

diff --git a/install/sql/incremental/upd_dev_collection.sql b/install/sql/incremental/upd_dev_collection.sql
index 4c23d5f..8c0258b 100644
--- a/install/sql/incremental/upd_dev_collection.sql
+++ b/install/sql/incremental/upd_dev_collection.sql
@@ -189,3 +189,6 @@
   ADD COLUMN `custom` text;
 
 ALTER TABLE `web_domain` ADD `ssl_letsencrypt` enum('n','y') NOT NULL DEFAULT 'n' AFTER `ssl`;
+
+ALTER TABLE `openvz_template` CHANGE `vmguarpages` `vmguarpages` varchar(255) DEFAULT '65536:unlimited';
+ALTER TABLE `openvz_template` CHANGE `privvmpages` `privvmpages` varchar(255) DEFAULT '131072:139264';
diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql
index 77a12b4..1c56118 100644
--- a/install/sql/ispconfig3.sql
+++ b/install/sql/ispconfig3.sql
@@ -1112,7 +1112,7 @@
 -- Dumping data for table `openvz_template`
 --
 
-INSERT INTO `openvz_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `diskspace`, `traffic`, `bandwidth`, `ram`, `ram_burst`, `cpu_units`, `cpu_num`, `cpu_limit`, `io_priority`, `active`, `description`, `numproc`, `numtcpsock`, `numothersock`, `vmguarpages`, `kmemsize`, `tcpsndbuf`, `tcprcvbuf`, `othersockbuf`, `dgramrcvbuf`, `oomguarpages`, `privvmpages`, `lockedpages`, `shmpages`, `physpages`, `numfile`, `avnumproc`, `numflock`, `numpty`, `numsiginfo`, `dcachesize`, `numiptent`, `swappages`, `hostname`, `nameserver`, `create_dns`, `capability`, `features`, `iptables`, `custom`) VALUES(1, 1, 1, 'riud', 'riud', '', 'small', 10, -1, -1, 256, 512, 1000, 4, 400, 4, 'y', '', '999999:999999', '7999992:7999992', '7999992:7999992', '65536:65536', '2147483646:2147483646', '214748160:396774400', '214748160:396774400', '214748160:396774400', '214748160:396774400', '65536:65536', '131072:131072', '999999:999999', '65536:65536', '0:2147483647', '23999976:23999976', '180:180', '999999:999999', '500000:500000', '999999:999999', '2147483646:2147483646', '999999:999999', '256000:256000', 'v{VEID}.test.tld', '8.8.8.8 8.8.4.4', 'n', '', '', '', '');
+INSERT INTO `openvz_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `diskspace`, `traffic`, `bandwidth`, `ram`, `ram_burst`, `cpu_units`, `cpu_num`, `cpu_limit`, `io_priority`, `active`, `description`, `numproc`, `numtcpsock`, `numothersock`, `vmguarpages`, `kmemsize`, `tcpsndbuf`, `tcprcvbuf`, `othersockbuf`, `dgramrcvbuf`, `oomguarpages`, `privvmpages`, `lockedpages`, `shmpages`, `physpages`, `numfile`, `avnumproc`, `numflock`, `numpty`, `numsiginfo`, `dcachesize`, `numiptent`, `swappages`, `hostname`, `nameserver`, `create_dns`, `capability`, `features`, `iptables`, `custom`) VALUES(1, 1, 1, 'riud', 'riud', '', 'small', 10, -1, -1, 256, 512, 1000, 4, 400, 4, 'y', '', '999999:999999', '7999992:7999992', '7999992:7999992', '65536:unlimited', '2147483646:2147483646', '214748160:396774400', '214748160:396774400', '214748160:396774400', '214748160:396774400', '65536:65536', '131072:139264', '999999:999999', '65536:65536', '0:2147483647', '23999976:23999976', '180:180', '999999:999999', '500000:500000', '999999:999999', '2147483646:2147483646', '999999:999999', '256000:256000', 'v{VEID}.test.tld', '8.8.8.8 8.8.4.4', 'n', '', '', '', '');
 
 -- --------------------------------------------------------
 
diff --git a/interface/lib/plugins/vm_openvz_plugin.inc.php b/interface/lib/plugins/vm_openvz_plugin.inc.php
index 3249793..281fae4 100644
--- a/interface/lib/plugins/vm_openvz_plugin.inc.php
+++ b/interface/lib/plugins/vm_openvz_plugin.inc.php
@@ -178,11 +178,11 @@
 		$tpl->setVar('bootorder', $vm['bootorder']);
 		$tpl->setVar('kmemsize', $vm_template['kmemsize']);
 		$tpl->setVar('lockedpages', $vm_template['lockedpages']);
-		$tpl->setVar('privvmpages', $burst_ram.':'.$burst_ram);
+		$tpl->setVar('privvmpages', $burst_ram.':'.$burst_ram*1.0625);
 		$tpl->setVar('shmpages', $guar_ram.':'.$guar_ram);
 		$tpl->setVar('numproc', $vm_template['numproc']);
 		$tpl->setVar('physpages', $vm_template['physpages']);
-		$tpl->setVar('vmguarpages', $guar_ram.':'.$guar_ram);
+		$tpl->setVar('vmguarpages', $guar_ram.':unlimited');
 		$tpl->setVar('oomguarpages', $guar_ram.':'.$guar_ram);
 		$tpl->setVar('numtcpsock', $vm_template['numtcpsock']);
 		$tpl->setVar('numflock', $vm_template['numflock']);
diff --git a/interface/web/vm/openvz_template_edit.php b/interface/web/vm/openvz_template_edit.php
index 097e55b..c9c2400 100644
--- a/interface/web/vm/openvz_template_edit.php
+++ b/interface/web/vm/openvz_template_edit.php
@@ -63,7 +63,7 @@
 		$guar_ram = $app->functions->intval($this->dataRecord['ram']*256);
 		$burst_ram = $app->functions->intval($this->dataRecord['ram_burst']*256);
 		$sql = "UPDATE openvz_template SET shmpages = ?,vmguarpages = ?, oomguarpages = ?,privvmpages = ? WHERE template_id = ?";
-		$app->db->query($sql, $guar_ram . ':' . $guar_ram, $guar_ram . ':' . $guar_ram, $guar_ram . ':' . $guar_ram, $burst_ram . ':' . $burst_ram, $this->id);
+		$app->db->query($sql, $guar_ram . ':' . $guar_ram, $guar_ram . ':unlimited', $guar_ram . ':' . $guar_ram, $burst_ram . ':' . $burst_ram*1.0625, $this->id);
 	}
 
 }
diff --git a/interface/web/vm/templates/openvz.conf.tpl b/interface/web/vm/templates/openvz.conf.tpl
index ed4943f..7b099b1 100644
--- a/interface/web/vm/templates/openvz.conf.tpl
+++ b/interface/web/vm/templates/openvz.conf.tpl
@@ -5,37 +5,98 @@
 # Parameters
 ONBOOT="{tmpl_var name='onboot'}"
 BOOTORDER="{tmpl_var name='bootorder'}"
-KMEMSIZE="{tmpl_var name='kmemsize'}"
-LOCKEDPAGES="{tmpl_var name='lockedpages'}"
-PRIVVMPAGES="{tmpl_var name='privvmpages'}"
-SHMPAGES="{tmpl_var name='shmpages'}"
-NUMPROC="{tmpl_var name='numproc'}"
+
+# VSwap requires RAM and SWAP, all other memory parameters are optional.
+<tmpl_if name='physpages'>
+# RAM
 PHYSPAGES="{tmpl_var name='physpages'}"
+</tmpl_if>
+<tmpl_if name='swappages'>
+# SWAP
+SWAPPAGES="{tmpl_var name='swappages'}"
+</tmpl_if>
+
+<tmpl_if name='kmemsize'>
+KMEMSIZE="{tmpl_var name='kmemsize'}"
+</tmpl_if>
+<tmpl_if name='lockedpages'>
+LOCKEDPAGES="{tmpl_var name='lockedpages'}"
+</tmpl_if>
+<tmpl_if name='privvmpages'>
+PRIVVMPAGES="{tmpl_var name='privvmpages'}"
+</tmpl_if>
+<tmpl_if name='shmpages'>
+SHMPAGES="{tmpl_var name='shmpages'}"
+</tmpl_if>
+<tmpl_if name='vmguarpages'>
 VMGUARPAGES="{tmpl_var name='vmguarpages'}"
+</tmpl_if>
+<tmpl_if name='oomguarpages'>
 OOMGUARPAGES="{tmpl_var name='oomguarpages'}"
+</tmpl_if>
+# alternative meminfo: "pages:256000"
+MEMINFO="privvmpages:1"
+
+<tmpl_if name='vmguarpages'>
+NUMPROC="{tmpl_var name='numproc'}"
+</tmpl_if>
+<tmpl_if name='numtcpsock'>
 NUMTCPSOCK="{tmpl_var name='numtcpsock'}"
+</tmpl_if>
+<tmpl_if name='numflock'>
 NUMFLOCK="{tmpl_var name='numflock'}"
+</tmpl_if>
+<tmpl_if name='numpty'>
 NUMPTY="{tmpl_var name='numpty'}"
+</tmpl_if>
+<tmpl_if name='numsiginfo'>
 NUMSIGINFO="{tmpl_var name='numsiginfo'}"
+</tmpl_if>
+<tmpl_if name='tcpsndbuf'>
 TCPSNDBUF="{tmpl_var name='tcpsndbuf'}"
+</tmpl_if>
+<tmpl_if name='tcprcvbuf'>
 TCPRCVBUF="{tmpl_var name='tcprcvbuf'}"
+</tmpl_if>
+<tmpl_if name='othersockbuf'>
 OTHERSOCKBUF="{tmpl_var name='othersockbuf'}"
+</tmpl_if>
+<tmpl_if name='dgramrcvbuf'>
 DGRAMRCVBUF="{tmpl_var name='dgramrcvbuf'}"
+</tmpl_if>
+<tmpl_if name='numothersock'>
 NUMOTHERSOCK="{tmpl_var name='numothersock'}"
+</tmpl_if>
+<tmpl_if name='dcachesize'>
 DCACHESIZE="{tmpl_var name='dcachesize'}"
+</tmpl_if>
+<tmpl_if name='numfile'>
 NUMFILE="{tmpl_var name='numfile'}"
+</tmpl_if>
+<tmpl_if name='avnumproc'>
 AVNUMPROC="{tmpl_var name='avnumproc'}"
+</tmpl_if>
+<tmpl_if name='numiptent'>
 NUMIPTENT="{tmpl_var name='numiptent'}"
+</tmpl_if>
 
 DISKSPACE="{tmpl_var name='diskspace'}"
 DISKINODES="{tmpl_var name='diskinodes'}"
 QUOTAUGIDLIMIT="10000"
-IOPRIO="{tmpl_var name='io_priority'}"
 QUOTATIME="0"
+<tmpl_if name='io_priority'>
+IOPRIO="{tmpl_var name='io_priority'}"
+</tmpl_if>
 
+<tmpl_if name='cpu_num'>
 CPUS="{tmpl_var name='cpu_num'}"
+</tmpl_if>
+<tmpl_if name='cpu_units'>
 CPUUNITS="{tmpl_var name='cpu_units'}"
+</tmpl_if>
+<tmpl_if name='cpu_limit'>
 CPULIMIT="{tmpl_var name='cpu_limit'}"
+</tmpl_if>
 
 VE_ROOT="/vz/root/$VEID"
 VE_PRIVATE="/vz/private/$VEID"
@@ -44,11 +105,16 @@
 HOSTNAME="{tmpl_var name='hostname'}"
 IP_ADDRESS="{tmpl_var name='ip_address'}"
 NAMESERVER="{tmpl_var name='nameserver'}"
-# alternative meminfo: "pages:256000"
-MEMINFO="privvmpages:1"
-# SWAPPAGES="{tmpl_var name='swappages'}"
 
+<tmpl_if name='capability'>
 CAPABILITY="{tmpl_var name='capability'}"
+</tmpl_if>
+<tmpl_if name='features'>
 FEATURES="{tmpl_var name='features'}"
+</tmpl_if>
+<tmpl_if name='iptables'>
 IPTABLES="{tmpl_var name='iptables'}"
+</tmpl_if>
+<tmpl_if name='custom'>
 {tmpl_var name='custom'}
+</tmpl_if>
diff --git a/remoting_client/examples/openvz_template_add.php b/remoting_client/examples/openvz_template_add.php
index 74eb1b9..b602000 100644
--- a/remoting_client/examples/openvz_template_add.php
+++ b/remoting_client/examples/openvz_template_add.php
@@ -32,14 +32,14 @@
 		'numproc' => '999999:999999',
 		'numtcpsock' => '7999992:7999992',
 		'numothersock' => '7999992:7999992',
-		'vmguarpages' => '65536:65536',
+		'vmguarpages' => '65536:unlimited',
 		'kmemsize' => '2147483646:2147483646',
 		'tcpsndbuf' => '214748160:396774400',
 		'tcprcvbuf' => '214748160:396774400',
 		'othersockbuf' => '214748160:396774400',
 		'dgramrcvbuf' => '214748160:396774400',
 		'oomguarpages' => '65536:65536',
-		'privvmpages' => '131072:131072',
+		'privvmpages' => '131072:139264',
 		'lockedpages' => '999999:999999',
 		'shmpages' => '65536:65536',
 		'physpages' => '0:2147483647',

--
Gitblit v1.9.1