From 2eb48d066ec3144b9e564c2d2ad1c445706aa112 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Fri, 30 Jul 2010 11:51:14 -0500 Subject: patch that allows specifying max tmpfs size to tmpfs plugin Add a 'max_fs_size' parameter to the tmpfs plugin that allows specification of sizes greater than default (50% of RAM). Signed-off-by: Clark Williams --- etc/mock/site-defaults.cfg | 3 ++- py/mock.py | 4 +++- py/mock/plugins/tmpfs.py | 9 +++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/etc/mock/site-defaults.cfg b/etc/mock/site-defaults.cfg index fdff7ff..6dc4d33 100644 --- a/etc/mock/site-defaults.cfg +++ b/etc/mock/site-defaults.cfg @@ -75,7 +75,8 @@ # config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/host/path', '/bind/mount/path/in/chroot/' )) # # config_opts['plugin_conf']['tmpfs_enable'] = False -# config_opts['plugin_conf']['tmpfs_opts'] = {'required_ram_mb': 1024} +# config_opts['plugin_conf']['tmpfs_opts']['required_ram_mb'] = 1024 +# config_opts['plugin_conf']['tmpfs_opts']['max_fs_size'] = '512m' ############################################################################# # diff --git a/py/mock.py b/py/mock.py index 436dbd0..dd002de 100755 --- a/py/mock.py +++ b/py/mock.py @@ -270,7 +270,9 @@ def setup_default_config_opts(config_opts, unprivUid): # ('/another/host/path', '/another/bind/mount/path/in/chroot/'), ]}, 'tmpfs_enable': False, - 'tmpfs_opts': {'required_ram_mb': 900}, + 'tmpfs_opts': { + 'required_ram_mb': 900, + 'max_fs_size': None}, } # dependent on guest OS diff --git a/py/mock/plugins/tmpfs.py b/py/mock/plugins/tmpfs.py index cf89bc1..1708275 100644 --- a/py/mock/plugins/tmpfs.py +++ b/py/mock/plugins/tmpfs.py @@ -33,6 +33,11 @@ class Tmpfs(object): def __init__(self, rootObj, conf): self.rootObj = rootObj self.conf = conf + self.maxSize = self.conf['max_fs_size'] + if self.maxSize: + self.optArgs = ['-o', 'size=' + self.maxSize] + else: + self.optArgs = [] rootObj.addHook("preinit", self._tmpfsPreInitHook) rootObj.addHook("postbuild", self._tmpfsPostBuildHook) rootObj.addHook("initfailed", self._tmpfsPostBuildHook) @@ -40,8 +45,8 @@ class Tmpfs(object): decorate(traceLog()) def _tmpfsPreInitHook(self): getLog().info("mounting tmpfs.") - mountCmd = ["mount", "-n", "-t", "tmpfs", "mock_chroot_tmpfs", - self.rootObj.makeChrootPath()] + mountCmd = ["mount", "-n", "-t", "tmpfs"] + self.optArgs + \ + ["mock_chroot_tmpfs", self.rootObj.makeChrootPath()] mock.util.do(mountCmd, shell=False) decorate(traceLog()) -- cgit