core: improve handling QubesDB startup errors

Kill the VM when QubesDB initialization fails, in any way, not only
QubesDB daemon itself.
This commit is contained in:
Marek Marczykowski-Górecki 2015-10-13 23:49:32 +02:00
parent 5c549e1134
commit 75168c8aef
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -1759,7 +1759,6 @@ class QubesVm(object):
str(self.xid), str(self.xid),
self.name]) self.name])
if retcode != 0: if retcode != 0:
self.force_shutdown()
raise OSError("ERROR: Cannot execute qubesdb-daemon!") raise OSError("ERROR: Cannot execute qubesdb-daemon!")
def request_memory(self, mem_required = None): def request_memory(self, mem_required = None):
@ -1833,31 +1832,35 @@ class QubesVm(object):
self.libvirt_domain.createWithFlags(libvirt.VIR_DOMAIN_START_PAUSED) self.libvirt_domain.createWithFlags(libvirt.VIR_DOMAIN_START_PAUSED)
if verbose: try:
print >> sys.stderr, "--> Starting Qubes DB..." if verbose:
self.start_qubesdb() print >> sys.stderr, "--> Starting Qubes DB..."
self.start_qubesdb()
xid = self.xid xid = self.xid
self.log.debug('xid={}'.format(xid)) self.log.debug('xid={}'.format(xid))
if preparing_dvm: if preparing_dvm:
self.services['qubes-dvm'] = True self.services['qubes-dvm'] = True
if verbose: if verbose:
print >> sys.stderr, "--> Setting Qubes DB info for the VM..." print >> sys.stderr, "--> Setting Qubes DB info for the VM..."
self.create_qubesdb_entries() self.create_qubesdb_entries()
if verbose: if verbose:
print >> sys.stderr, "--> Updating firewall rules..." print >> sys.stderr, "--> Updating firewall rules..."
netvm = self.netvm netvm = self.netvm
while netvm is not None: while netvm is not None:
if netvm.is_proxyvm() and netvm.is_running(): if netvm.is_proxyvm() and netvm.is_running():
netvm.write_iptables_qubesdb_entry() netvm.write_iptables_qubesdb_entry()
netvm = netvm.netvm netvm = netvm.netvm
# fire hooks # fire hooks
for hook in self.hooks_start: for hook in self.hooks_start:
hook(self, verbose = verbose, preparing_dvm = preparing_dvm, hook(self, verbose = verbose, preparing_dvm = preparing_dvm,
start_guid = start_guid, notify_function = notify_function) start_guid = start_guid, notify_function = notify_function)
except:
self.force_shutdown()
raise
if verbose: if verbose:
print >> sys.stderr, "--> Starting the VM..." print >> sys.stderr, "--> Starting the VM..."