dom0/core: shutdown right VM (based on XID) in case of failed qrexec startup

The user can restart the VM in the meantime (especially when first startup
failed). Basing here on name will kill the new one VM instead of dead one.
This commit is contained in:
Marek Marczykowski 2013-01-19 18:05:57 +01:00
parent 52e16037f2
commit 8600ea07b8

View File

@ -1508,7 +1508,7 @@ class QubesVm(object):
qrexec_env['QREXEC_STARTUP_TIMEOUT'] = str(self.qrexec_timeout)
retcode = subprocess.call ([qrexec_daemon_path, str(xid), self.default_user], env=qrexec_env)
if (retcode != 0) :
self.force_shutdown()
self.force_shutdown(xid=xid)
raise OSError ("ERROR: Cannot execute qrexec_daemon!")
def start(self, debug_console = False, verbose = False, preparing_dvm = False, start_guid = True, notify_function = None):
@ -1614,19 +1614,18 @@ class QubesVm(object):
return xid
def shutdown(self, force=False):
def shutdown(self, force=False, xid = None):
if dry_run:
return
subprocess.call (['/usr/sbin/xl', 'shutdown', self.name])
subprocess.call (['/usr/sbin/xl', 'shutdown', str(xid) if xid is not None else self.name])
#xc.domain_destroy(self.get_xid())
def force_shutdown(self):
def force_shutdown(self, xid = None):
if dry_run:
return
subprocess.call (['/usr/sbin/xl', 'destroy', self.name])
#xc.domain_destroy(self.get_xid())
subprocess.call (['/usr/sbin/xl', 'destroy', str(xid) if xid is not None else self.name])
def pause(self):
if dry_run:
@ -2059,11 +2058,11 @@ class QubesProxyVm(QubesNetVm):
self.write_netvm_domid_entry()
return retcode
def force_shutdown(self):
def force_shutdown(self, **kwargs):
if dry_run:
return
self.netvm.remove_external_ip_permission(self.get_xid())
super(QubesProxyVm, self).force_shutdown()
self.netvm.remove_external_ip_permission(kwargs['xid'] if 'xid' in kwargs else self.get_xid())
super(QubesProxyVm, self).force_shutdown(**kwargs)
def create_xenstore_entries(self, xid = None):
if dry_run: