Do not use qmemman when not present (installed) on particular VMM
This commit is contained in:
parent
72e415a807
commit
69d1ae645f
@ -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,11 +973,11 @@ 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
|
||||||
vmm.xs.set_permissions('', '/local/domain/{0}/memory'.format(self.xid),
|
if qmemman_present:
|
||||||
[{ 'dom': xid }])
|
vmm.xs.set_permissions('', '/local/domain/{0}/memory'.format(self.xid),
|
||||||
|
[{ 'dom': xid }])
|
||||||
|
|
||||||
# fire hooks
|
# fire hooks
|
||||||
for hook in self.hooks_create_xenstore_entries:
|
for hook in self.hooks_create_xenstore_entries:
|
||||||
@ -1730,14 +1735,15 @@ 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
|
||||||
qmemman_client = QMemmanClient()
|
if qmemman_present:
|
||||||
try:
|
qmemman_client = QMemmanClient()
|
||||||
got_memory = qmemman_client.request_memory(mem_required)
|
try:
|
||||||
except IOError as e:
|
got_memory = qmemman_client.request_memory(mem_required)
|
||||||
raise IOError("ERROR: Failed to connect to qmemman: %s" % str(e))
|
except IOError as e:
|
||||||
if not got_memory:
|
raise IOError("ERROR: Failed to connect to qmemman: %s" % str(e))
|
||||||
qmemman_client.close()
|
if not got_memory:
|
||||||
raise MemoryError ("ERROR: insufficient memory to start VM '%s'" % self.name)
|
qmemman_client.close()
|
||||||
|
raise MemoryError ("ERROR: insufficient memory to start VM '%s'" % self.name)
|
||||||
|
|
||||||
# Bind pci devices to pciback driver
|
# Bind pci devices to pciback driver
|
||||||
for pci in self.pcidevs:
|
for pci in self.pcidevs:
|
||||||
@ -1783,7 +1789,8 @@ 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
|
||||||
qmemman_client.close()
|
if qmemman_present:
|
||||||
|
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'):
|
||||||
self.start_guid(verbose=verbose, notify_function=notify_function, before_qrexec=True)
|
self.start_guid(verbose=verbose, notify_function=notify_function, before_qrexec=True)
|
||||||
|
@ -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,16 +135,17 @@ class QubesDisposableVm(QubesVm):
|
|||||||
# refresh config file
|
# refresh config file
|
||||||
domain_config = self.create_config_file()
|
domain_config = self.create_config_file()
|
||||||
|
|
||||||
mem_required = int(self.memory) * 1024 * 1024
|
if qmemman_present:
|
||||||
print >>sys.stderr, "time=%s, getting %d memory" % (str(time.time()), mem_required)
|
mem_required = int(self.memory) * 1024 * 1024
|
||||||
qmemman_client = QMemmanClient()
|
print >>sys.stderr, "time=%s, getting %d memory" % (str(time.time()), mem_required)
|
||||||
try:
|
qmemman_client = QMemmanClient()
|
||||||
got_memory = qmemman_client.request_memory(mem_required)
|
try:
|
||||||
except IOError as e:
|
got_memory = qmemman_client.request_memory(mem_required)
|
||||||
raise IOError("ERROR: Failed to connect to qmemman: %s" % str(e))
|
except IOError as e:
|
||||||
if not got_memory:
|
raise IOError("ERROR: Failed to connect to qmemman: %s" % str(e))
|
||||||
qmemman_client.close()
|
if not got_memory:
|
||||||
raise MemoryError ("ERROR: insufficient memory to start VM '%s'" % self.name)
|
qmemman_client.close()
|
||||||
|
raise MemoryError ("ERROR: insufficient memory to start VM '%s'" % self.name)
|
||||||
|
|
||||||
# dispvm cannot have PCI devices
|
# dispvm cannot have PCI devices
|
||||||
assert (len(self.pcidevs) == 0), "DispVM cannot have PCI devices"
|
assert (len(self.pcidevs) == 0), "DispVM cannot have PCI devices"
|
||||||
@ -175,7 +181,8 @@ 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
|
||||||
qmemman_client.close()
|
if qmemman_present:
|
||||||
|
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'):
|
||||||
self.start_guid(verbose=verbose,
|
self.start_guid(verbose=verbose,
|
||||||
|
Loading…
Reference in New Issue
Block a user