Do not use qmemman when not present (installed) on particular VMM

This commit is contained in:
Marek Marczykowski-Górecki 2013-07-22 04:17:30 +02:00
parent 72e415a807
commit 69d1ae645f
2 changed files with 39 additions and 25 deletions

View File

@ -44,7 +44,12 @@ from qubes.qubes import dry_run,vmm
from qubes.qubes import register_qubes_vm_class from qubes.qubes import register_qubes_vm_class
from qubes.qubes import QubesVmCollection,QubesException,QubesHost,QubesVmLabels from qubes.qubes import QubesVmCollection,QubesException,QubesHost,QubesVmLabels
from qubes.qubes import defaults,system_path,vm_files,qubes_max_qid from qubes.qubes import defaults,system_path,vm_files,qubes_max_qid
from qubes.qmemman_client import QMemmanClient qmemman_present = False
try:
from qubes.qmemman_client import QMemmanClient
qmemman_present = True
except ImportError:
pass
import qubes.qubesutils import qubes.qubesutils
@ -968,9 +973,9 @@ class QubesVm(object):
self.qdb.write("/qubes-debug-mode", str(int(self.debug))) self.qdb.write("/qubes-debug-mode", str(int(self.debug)))
# Fix permissions
# TODO: Currently whole qmemman is quite Xen-specific, so stay with # TODO: Currently whole qmemman is quite Xen-specific, so stay with
# xenstore for it until decided otherwise # xenstore for it until decided otherwise
if qmemman_present:
vmm.xs.set_permissions('', '/local/domain/{0}/memory'.format(self.xid), vmm.xs.set_permissions('', '/local/domain/{0}/memory'.format(self.xid),
[{ 'dom': xid }]) [{ 'dom': xid }])
@ -1730,6 +1735,7 @@ class QubesVm(object):
if mem_required is None: if mem_required is None:
mem_required = int(self.memory) * 1024 * 1024 mem_required = int(self.memory) * 1024 * 1024
if qmemman_present:
qmemman_client = QMemmanClient() qmemman_client = QMemmanClient()
try: try:
got_memory = qmemman_client.request_memory(mem_required) got_memory = qmemman_client.request_memory(mem_required)
@ -1783,6 +1789,7 @@ class QubesVm(object):
# constructing the domain after its main process exits # constructing the domain after its main process exits
# so we close() when we know the domain is up # so we close() when we know the domain is up
# the successful unpause is some indicator of it # the successful unpause is some indicator of it
if qmemman_present:
qmemman_client.close() qmemman_client.close()
if self._start_guid_first and start_guid and not preparing_dvm and os.path.exists('/var/run/shm.id'): if self._start_guid_first and start_guid and not preparing_dvm and os.path.exists('/var/run/shm.id'):

View File

@ -29,7 +29,12 @@ import time
from qubes.qubes import QubesVm,QubesVmLabel,register_qubes_vm_class from qubes.qubes import QubesVm,QubesVmLabel,register_qubes_vm_class
from qubes.qubes import QubesDispVmLabels from qubes.qubes import QubesDispVmLabels
from qubes.qubes import dry_run,vmm from qubes.qubes import dry_run,vmm
from qubes.qmemman_client import QMemmanClient qmemman_present = False
try:
from qubes.qmemman_client import QMemmanClient
qmemman_present = True
except ImportError:
pass
class QubesDisposableVm(QubesVm): class QubesDisposableVm(QubesVm):
""" """
@ -130,6 +135,7 @@ class QubesDisposableVm(QubesVm):
# refresh config file # refresh config file
domain_config = self.create_config_file() domain_config = self.create_config_file()
if qmemman_present:
mem_required = int(self.memory) * 1024 * 1024 mem_required = int(self.memory) * 1024 * 1024
print >>sys.stderr, "time=%s, getting %d memory" % (str(time.time()), mem_required) print >>sys.stderr, "time=%s, getting %d memory" % (str(time.time()), mem_required)
qmemman_client = QMemmanClient() qmemman_client = QMemmanClient()
@ -175,6 +181,7 @@ class QubesDisposableVm(QubesVm):
# constructing the domain after its main process exits # constructing the domain after its main process exits
# so we close() when we know the domain is up # so we close() when we know the domain is up
# the successful unpause is some indicator of it # the successful unpause is some indicator of it
if qmemman_present:
qmemman_client.close() qmemman_client.close()
if self._start_guid_first and kwargs.get('start_guid', True) and os.path.exists('/var/run/shm.id'): if self._start_guid_first and kwargs.get('start_guid', True) and os.path.exists('/var/run/shm.id'):