From 8600ea07b8ad590c77189f058a12df6766d05294 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Sat, 19 Jan 2013 18:05:57 +0100 Subject: [PATCH] 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. --- dom0/qvm-core/qubes.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 947486c8..aa3f1235 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -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: