From d6bdb85883d858dbc942543a2ae2b5b11f37140d Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Thu, 31 Mar 2011 11:11:39 +0200 Subject: [PATCH 1/2] Start qrexec_daemon in vm.start() Instead of three separate places - qvm-start, qvm-run, manager. --- dom0/qvm-core/qubes.py | 9 +++++++++ dom0/qvm-tools/qvm-run | 9 --------- dom0/qvm-tools/qvm-start | 12 ------------ dom0/restore/qubes_prepare_saved_domain.sh | 2 +- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 59f3a416..ea3e3b5a 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -46,6 +46,7 @@ if not dry_run: qubes_guid_path = "/usr/bin/qubes_guid" +qrexec_daemon_path = "/usr/lib/qubes/qrexec_daemon" qubes_base_dir = "/var/lib/qubes" @@ -618,6 +619,14 @@ class QubesVm(object): print "--> Starting the VM..." xend_session.session.xenapi.VM.unpause (self.session_uuid) + if not preparing_dvm: + if verbose: + print "--> Starting the qrexec daemon..." + retcode = subprocess.call ([qrexec_daemon_path, str(xid)]) + if (retcode != 0) : + self.force_shutdown() + raise OSError ("ERROR: Cannot execute qrexec_daemon!") + # perhaps we should move it before unpause and fork? if debug_console: from xen.xm import console diff --git a/dom0/qvm-tools/qvm-run b/dom0/qvm-tools/qvm-run index fe2ca357..bafe3a79 100755 --- a/dom0/qvm-tools/qvm-run +++ b/dom0/qvm-tools/qvm-run @@ -34,7 +34,6 @@ import os.path qubes_guid_path = "/usr/bin/qubes_guid" qubes_clipd_path = "/usr/bin/qclipd" -qrexec_daemon_path = "/usr/lib/qubes/qrexec_daemon" qrexec_client_path = "/usr/lib/qubes/qrexec_client" notify_object = None @@ -114,14 +113,6 @@ def vm_run_cmd(vm, cmd, options): tray_notify_error ("ERROR: Cannot start qubes_guid!") exit (1) - if options.verbose: - print "--> Starting Qubes rexec daemon..." - - retcode = subprocess.call ([qrexec_daemon_path, str(xid)]) - if (retcode != 0) : - print "ERROR: Cannot start qrexec_daemon!" - exit (1) - actually_execute(str(xid), cmd, options); else: # VM already running... diff --git a/dom0/qvm-tools/qvm-start b/dom0/qvm-tools/qvm-start index 8a3d277e..ff23e80a 100755 --- a/dom0/qvm-tools/qvm-start +++ b/dom0/qvm-tools/qvm-start @@ -27,7 +27,6 @@ import subprocess import os qubes_guid_path = "/usr/bin/qubes_guid" -qrexec_daemon_path = "/usr/lib/qubes/qrexec_daemon" def main(): usage = "usage: %prog [options] " @@ -35,8 +34,6 @@ def main(): parser.add_option ("-q", "--quiet", action="store_false", dest="verbose", default=True) parser.add_option ("--no-guid", action="store_true", dest="noguid", default=False, help="Do not start the GUId") - parser.add_option ("--no-rexec", action="store_true", dest="norexec", default=False, - help="Do not start rexec") parser.add_option ("--console", action="store_true", dest="debug_console", default=False, help="Attach debugging console to the newly started VM") parser.add_option ("--dvm", action="store_true", dest="preparing_dvm", default=False, @@ -73,14 +70,5 @@ def main(): print "ERROR: Cannot start qubes_guid!" exit (1) - if not options.norexec: - if options.verbose: - print "--> Starting Qubes rexec..." - - retcode = subprocess.call ([qrexec_daemon_path, str(xid)]) - if (retcode != 0) : - print "ERROR: Cannot start qrexec_daemon!" - exit (1) - main() diff --git a/dom0/restore/qubes_prepare_saved_domain.sh b/dom0/restore/qubes_prepare_saved_domain.sh index d920603e..a1bf0770 100755 --- a/dom0/restore/qubes_prepare_saved_domain.sh +++ b/dom0/restore/qubes_prepare_saved_domain.sh @@ -21,7 +21,7 @@ if ! [ -d $VMDIR ] ; then echo $VMDIR does not exist ? exit 1 fi -if ! qvm-start $1 --no-guid --no-rexec --dvm ; then +if ! qvm-start $1 --no-guid --dvm ; then exit 1 fi From b7698de251828d6391f63f28d454d6de5fbfeca6 Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Thu, 31 Mar 2011 11:23:44 +0200 Subject: [PATCH 2/2] qrexec_daemon: print dots when waiting for agent --- qrexec/qrexec_daemon.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/qrexec/qrexec_daemon.c b/qrexec/qrexec_daemon.c index 1916254c..ee964437 100644 --- a/qrexec/qrexec_daemon.c +++ b/qrexec/qrexec_daemon.c @@ -53,6 +53,7 @@ int server_fd; void handle_usr1(int x) { + fprintf(stderr, "connected\n"); exit(0); } @@ -77,7 +78,11 @@ void init(int xid) case 0: break; default: - pause(); + fprintf(stderr, "Waiting for VM's qrexec agent."); + for (;;) { + sleep(1); + fprintf(stderr, "."); + } exit(0); } close(0); @@ -126,9 +131,9 @@ void flush_client(int fd) { int i; struct server_header s_hdr; - + if (fork_and_flush_stdin(fd, &clients[fd].buffer)) - children_count++; + children_count++; close(fd); clients[fd].state = CLIENT_INVALID; buffer_free(&clients[fd].buffer);