From 99ffed089cf742c84cb6bbba4d89bbdfac525cb3 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 5 Dec 2011 13:36:13 +0100 Subject: [PATCH] dom0: start guid as soon as possible (#377) --- dom0/qvm-core/qubes.py | 22 ++++++++++++++++++++++ dom0/qvm-core/qubesutils.py | 22 +--------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 96f2398d..f841811e 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -1049,6 +1049,26 @@ class QubesVm(object): raise QubesException ("Network attach timed out!") time.sleep(0.2) + def start_guid(self, verbose = True, notify_function = None): + if verbose: + print >> sys.stderr, "--> Starting Qubes GUId..." + xid = self.get_xid() + + retcode = subprocess.call ([qubes_guid_path, "-d", str(xid), "-c", self.label.color, "-i", self.label.icon, "-l", str(self.label.index)]) + if (retcode != 0) : + raise QubesException("Cannot start qubes_guid!") + + if verbose: + print >> sys.stderr, "--> Waiting for qubes-session..." + + subprocess.call([qrexec_client_path, "-d", str(xid), "user:echo $$ >> /tmp/qubes-session-waiter; [ ! -f /tmp/qubes-session-env ] && exec sleep 365d"]) + + retcode = subprocess.call([qubes_clipd_path]) + if retcode != 0: + print >> sys.stderr, "ERROR: Cannot start qclipd!" + if notify_function is not None: + notify_function("error", "ERROR: Cannot start the Qubes Clipboard Notifier!") + def start(self, debug_console = False, verbose = False, preparing_dvm = False): if dry_run: return @@ -1125,6 +1145,8 @@ class QubesVm(object): self.force_shutdown() raise OSError ("ERROR: Cannot execute qrexec_daemon!") + self.start_guid(verbose=verbose) + if preparing_dvm: if verbose: print >> sys.stderr, "--> Preparing config template for DispVM" diff --git a/dom0/qvm-core/qubesutils.py b/dom0/qvm-core/qubesutils.py index 37ed1b00..a66fb81a 100644 --- a/dom0/qvm-core/qubesutils.py +++ b/dom0/qvm-core/qubesutils.py @@ -229,26 +229,6 @@ def block_detach(vm, frontend = "xvdi", vm_xid = None): xl_cmd = [ '/usr/sbin/xl', 'block-detach', str(vm_xid), str(frontend)] subprocess.check_call(xl_cmd) -def start_guid(vm, verbose = True, notify_function = None): - if verbose: - print >> sys.stderr, "--> Starting Qubes GUId..." - xid = vm.get_xid() - - retcode = subprocess.call ([qubes_guid_path, "-d", str(xid), "-c", vm.label.color, "-i", vm.label.icon, "-l", str(vm.label.index)]) - if (retcode != 0) : - raise QubesException("Cannot start qubes_guid!") - - if verbose: - print >> sys.stderr, "--> Waiting for qubes-session..." - - subprocess.call([qrexec_client_path, "-d", str(xid), "user:echo $$ >> /tmp/qubes-session-waiter; [ ! -f /tmp/qubes-session-env ] && exec sleep 365d"]) - - retcode = subprocess.call([qubes_clipd_path]) - if retcode != 0: - print >> sys.stderr, "ERROR: Cannot start qclipd!" - if notify_function is not None: - notify_function("error", "ERROR: Cannot start the Qubes Clipboard Notifier!") - def run_in_vm(vm, command, verbose = True, autostart = False, notify_function = None, passio = False, localcmd = None): assert vm is not None @@ -270,7 +250,7 @@ def run_in_vm(vm, command, verbose = True, autostart = False, notify_function = xid = vm.get_xid() if os.getenv("DISPLAY") is not None and not os.path.isfile("/var/run/qubes/guid_running.{0}".format(xid)): - start_guid(vm, verbose = verbose, notify_function = notify_function) + vm.start_guid(verbose = verbose, notify_function = notify_function) args = [qrexec_client_path, "-d", str(xid), command] if localcmd is not None: