Merge branch 'master' of git.qubes-os.org:/var/lib/qubes/git/marmarek/core
This commit is contained in:
commit
6ae56d7e18
@ -30,10 +30,10 @@ start()
|
||||
xl sched-credit -d 0 -w 512
|
||||
cp /var/lib/qubes/qubes.xml /var/lib/qubes/backup/qubes-$(date +%F-%T).xml
|
||||
|
||||
/usr/lib/qubes/qmemman_daemon.py >/var/log/qubes/qmemman.log 2>/var/log/qubes/qmemman.errs &
|
||||
/usr/lib/qubes/qmemman_daemon.py
|
||||
MEM_CHANGE_THRESHOLD_KB=30000
|
||||
MEMINFO_DELAY_USEC=100000
|
||||
/usr/lib/qubes/meminfo-writer $MEM_CHANGE_THRESHOLD_KB $MEMINFO_DELAY_USEC &
|
||||
/usr/lib/qubes/meminfo-writer $MEM_CHANGE_THRESHOLD_KB $MEMINFO_DELAY_USEC
|
||||
|
||||
# Hide mounted devices from qubes-block list (at first udev run, only / is mounted)
|
||||
for dev in `xenstore-list /local/domain/0/qubes-block-devices`; do
|
||||
|
@ -12,6 +12,8 @@ from optparse import OptionParser
|
||||
from qubesutils import parse_size
|
||||
|
||||
config_path = '/etc/qubes/qmemman.conf'
|
||||
SOCK_PATH='/var/run/qubes/qmemman.sock'
|
||||
LOG_PATH='/var/log/qubes/qmemman.log'
|
||||
|
||||
system_state = SystemState()
|
||||
global_lock = thread.allocate_lock()
|
||||
@ -105,15 +107,7 @@ class QMemmanReqHandler(SocketServer.BaseRequestHandler):
|
||||
self.request.send(resp)
|
||||
|
||||
|
||||
def start_server():
|
||||
SOCK_PATH='/var/run/qubes/qmemman.sock'
|
||||
try:
|
||||
os.unlink(SOCK_PATH)
|
||||
except:
|
||||
pass
|
||||
os.umask(0)
|
||||
server = SocketServer.UnixStreamServer(SOCK_PATH, QMemmanReqHandler)
|
||||
os.umask(077)
|
||||
def start_server(server):
|
||||
server.serve_forever()
|
||||
|
||||
class QMemmanServer:
|
||||
@ -124,6 +118,19 @@ class QMemmanServer:
|
||||
parser.add_option("-c", "--config", action="store", dest="config", default=config_path)
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
logfd = os.open(LOG_PATH, os.O_WRONLY|os.O_APPEND|os.O_CREAT, 0644)
|
||||
if logfd < 0:
|
||||
print sys.stderr, "ERROR: Failed to open log file (%s)" % LOG_PATH
|
||||
exit(1)
|
||||
# reinitialize python stdout/err
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
os.dup2(logfd, 1)
|
||||
os.dup2(logfd, 2)
|
||||
os.close(logfd)
|
||||
devnull = os.open('/dev/null', os.O_RDONLY)
|
||||
os.dup2(devnull, 0)
|
||||
|
||||
config = SafeConfigParser({
|
||||
'vm-min-mem': str(qmemman_algo.MIN_PREFMEM),
|
||||
'dom0-mem-boost': str(qmemman_algo.DOM0_MEM_BOOST),
|
||||
@ -137,5 +144,13 @@ class QMemmanServer:
|
||||
|
||||
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()
|
||||
try:
|
||||
os.unlink(SOCK_PATH)
|
||||
except:
|
||||
pass
|
||||
os.umask(0)
|
||||
server = SocketServer.UnixStreamServer(SOCK_PATH, QMemmanReqHandler)
|
||||
os.umask(077)
|
||||
if os.fork() == 0:
|
||||
thread.start_new_thread(start_server, tuple([server]))
|
||||
XS_Watcher().watch_loop()
|
||||
|
@ -154,6 +154,17 @@ int main(int argc, char **argv)
|
||||
perror("xs_domain_open");
|
||||
exit(1);
|
||||
}
|
||||
if (argc == 3) {
|
||||
/* if not waiting for signal, fork after first info written to xenstore */
|
||||
n = pread(fd, buf, sizeof(buf), 0);
|
||||
buf[n] = 0;
|
||||
meminfo_data = parse(buf);
|
||||
if (meminfo_data)
|
||||
send_to_qmemman(xs, meminfo_data);
|
||||
if (fork() > 0)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
n = pread(fd, buf, sizeof(buf), 0);
|
||||
buf[n] = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user