dom0/qmemman: add support for config file
This commit is contained in:
parent
5924d2fcc3
commit
2e6e9bfab9
13
dom0/misc/qmemman.conf
Normal file
13
dom0/misc/qmemman.conf
Normal file
@ -0,0 +1,13 @@
|
||||
# The only section in this file
|
||||
[global]
|
||||
# vm-min-mem - give at least this amount of RAM for dynamically managed VM
|
||||
# Default: 200M
|
||||
vm-min-mem = 200M
|
||||
|
||||
# dom0-mem-boost - additional memory given to dom0 for disk caches etc
|
||||
# Default: 350M
|
||||
dom0-mem-boost = 350M
|
||||
|
||||
# cache-margin-factor - calculate VM preferred memory as (used memory)*cache-margin-factor
|
||||
# Default: 1.3
|
||||
cache-margin-factor = 1.3
|
@ -1,5 +1,11 @@
|
||||
import string
|
||||
|
||||
# This are only defaults - can be overriden by QMemmanServer with values from
|
||||
# config file
|
||||
CACHE_FACTOR = 1.3
|
||||
MIN_PREFMEM = 200*1024*1024
|
||||
DOM0_MEM_BOOST = 350*1024*1024
|
||||
|
||||
#untrusted meminfo size is taken from xenstore key, thus its size is limited
|
||||
#so splits do not require excessive memory
|
||||
def parse_meminfo(untrusted_meminfo):
|
||||
@ -57,8 +63,6 @@ def refresh_meminfo_for_domain(domain, untrusted_xenstore_key):
|
||||
domain.mem_used = domain.meminfo['MemTotal'] - domain.meminfo['MemFree'] - domain.meminfo['Cached'] - domain.meminfo['Buffers'] + domain.meminfo['SwapTotal'] - domain.meminfo['SwapFree']
|
||||
|
||||
def prefmem(domain):
|
||||
CACHE_FACTOR = 1.3
|
||||
MIN_PREFMEM = 200*1024*1024
|
||||
#dom0 is special, as it must have large cache, for vbds. Thus, give it a special boost
|
||||
if domain.id == '0':
|
||||
return min(domain.mem_used*CACHE_FACTOR + 350*1024*1024, domain.memory_maximum)
|
||||
|
@ -6,6 +6,12 @@ import xen.lowlevel.xs
|
||||
import sys
|
||||
import os
|
||||
from qmemman import SystemState
|
||||
import qmemman_algo
|
||||
from ConfigParser import SafeConfigParser
|
||||
from optparse import OptionParser
|
||||
from qubesutils import parse_size
|
||||
|
||||
config_path = '/etc/qubes/qmemman.conf'
|
||||
|
||||
system_state = SystemState()
|
||||
global_lock = thread.allocate_lock()
|
||||
@ -113,5 +119,23 @@ def start_server():
|
||||
class QMemmanServer:
|
||||
@staticmethod
|
||||
def main():
|
||||
usage = "usage: %prog [options]"
|
||||
parser = OptionParser(usage)
|
||||
parser.add_option("-c", "--config", action="store", dest="config", default=config_path)
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
config = SafeConfigParser({
|
||||
'vm-min-mem': str(qmemman_algo.MIN_PREFMEM),
|
||||
'dom0-mem-boost': str(qmemman_algo.DOM0_MEM_BOOST),
|
||||
'cache-margin-factor': str(qmemman_algo.CACHE_FACTOR)
|
||||
})
|
||||
config.read(options.config)
|
||||
if config.has_section('global'):
|
||||
qmemman_algo.MIN_PREFMEM = parse_size(config.get('global', 'vm-min-mem'))
|
||||
qmemman_algo.DOM0_MEM_BOOST = parse_size(config.get('global', 'dom0-mem-boost'))
|
||||
qmemman_algo.CACHE_FACTOR = config.getfloat('global', 'cache-margin-factor')
|
||||
|
||||
print "values: %s, %s, %s" % (str(qmemman_algo.MIN_PREFMEM), str(qmemman_algo.DOM0_MEM_BOOST), str(qmemman_algo.CACHE_FACTOR))
|
||||
|
||||
thread.start_new_thread(start_server, tuple([]))
|
||||
XS_Watcher().watch_loop()
|
||||
|
@ -92,6 +92,9 @@ cp qvm-core/__init__.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
|
||||
cp qmemman/qmemman*py $RPM_BUILD_ROOT%{python_sitearch}/qubes
|
||||
cp qmemman/qmemman*py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
|
||||
|
||||
mkdir -p $RPM_BUILD_DIR/etc/qubes
|
||||
cp dom0/misc/qmemman.conf $RPM_BUILD_DIR%{_sysconfdir}/qubes/
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes
|
||||
cp aux-tools/patch_appvm_initramfs.sh $RPM_BUILD_ROOT/usr/lib/qubes
|
||||
cp aux-tools/unbind_pci_device.sh $RPM_BUILD_ROOT/usr/lib/qubes
|
||||
@ -307,6 +310,7 @@ fi
|
||||
/etc/init.d/qubes_core
|
||||
/etc/init.d/qubes_netvm
|
||||
/etc/init.d/qubes_setupdvm
|
||||
%config(noreplace) %{_sysconfdir}/qubes/qmemman.conf
|
||||
/usr/bin/qvm-*
|
||||
/usr/bin/qubes-*
|
||||
/usr/bin/qclipd
|
||||
|
Loading…
Reference in New Issue
Block a user