From 5ebd163fd36360778df90664f5a7e0b7cfe66c5a Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 6 Jun 2011 01:17:28 +0200 Subject: [PATCH] dom0: check RLIMIT_MEMLOCK before starting VM (and fix if possible) --- dom0/qvm-core/qubes.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 07771975..d9e7d101 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -31,6 +31,7 @@ import re import shutil import uuid import time +import resource from datetime import datetime from qmemman_client import QMemmanClient @@ -868,6 +869,14 @@ class QubesVm(object): if verbose: print "--> Loading the VM (type = {0})...".format(self.type) + limit_memlock = resource.getrlimit(resource.RLIMIT_MEMLOCK) + # try to increase limit if needed + if limit_memlock[0] < int(self.memory) * 1024: + # intentionally don't catch exceptions - if it fails - there is no + # memory for new VM + resource.setrlimit(resource.RLIMIT_MEMLOCK, + (int(self.memory) * 1024, limit_memlock[1])) + mem_required = int(self.memory) * 1024 * 1024 qmemman_client = QMemmanClient() if not qmemman_client.request_memory(mem_required):