git://git.onelab.eu
/
util-vserver-pl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
21f5bb2
)
Optimize the 0.0.0.0 case, and get it working on 2.3 kernels.
author
Daniel Hokka Zakrisson
<dhokka@cs.princeton.edu>
Sat, 24 Oct 2009 21:38:07 +0000
(21:38 +0000)
committer
Daniel Hokka Zakrisson
<dhokka@cs.princeton.edu>
Sat, 24 Oct 2009 21:38:07 +0000
(21:38 +0000)
python/vserver.py
patch
|
blob
|
history
diff --git
a/python/vserver.py
b/python/vserver.py
index
8aa410e
..
081fd8a
100644
(file)
--- a/
python/vserver.py
+++ b/
python/vserver.py
@@
-129,6
+129,26
@@
class VServerConfig:
os.path.walk(self.dir, add_to_cache, self.cache)
os.path.walk(self.dir, add_to_cache, self.cache)
+def adjust_lim(goal, curr):
+ gh = goal[0]
+ gs = goal[1]
+ gm = goal[2]
+ soft = curr[0]
+ hard = curr[1]
+ if gm != VC_LIM_KEEP:
+ if gm > soft:
+ soft = gm
+ if gm > hard:
+ hard = gm
+ if gs != VC_LIM_KEEP:
+ if gs > soft:
+ soft = gs
+ if gh != VC_LIM_KEEP:
+ if gh > hard:
+ hard = gh
+ return (soft, hard)
+
+
class VServer:
INITSCRIPTS = [('/etc/rc.vinit', 'start'),
class VServer:
INITSCRIPTS = [('/etc/rc.vinit', 'start'),
@@
-181,6
+201,9
@@
class VServer:
resource_type = RLIMITS[type]
try:
vserverimpl.setrlimit(self.ctx, resource_type, hard, soft, min)
resource_type = RLIMITS[type]
try:
vserverimpl.setrlimit(self.ctx, resource_type, hard, soft, min)
+ lim = resource.getrlimit(resource_type)
+ lim = adjust_lim((hard, soft, min), lim)
+ resource.setrlimit(resource_type, lim)
except OSError, e:
self.log("Error: setrlimit(%d, %s, %d, %d, %d): %s"
% (self.ctx, type.lower(), hard, soft, min))
except OSError, e:
self.log("Error: setrlimit(%d, %s, %d, %d, %d): %s"
% (self.ctx, type.lower(), hard, soft, min))