From a7cc09071f95b98d30cba1c7225238450f1ecf06 Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Tue, 8 Mar 2011 13:03:55 +0100 Subject: [PATCH] Make qubes_restore rexec-aware. --- dom0/qvm-tools/qvm-start | 15 +++++++----- dom0/restore/qubes_prepare_saved_domain.sh | 2 +- dom0/restore/qubes_restore.c | 27 +++++++++++++++++++++- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/dom0/qvm-tools/qvm-start b/dom0/qvm-tools/qvm-start index f8f155fd..8a3d277e 100755 --- a/dom0/qvm-tools/qvm-start +++ b/dom0/qvm-tools/qvm-start @@ -35,6 +35,8 @@ 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, @@ -71,13 +73,14 @@ def main(): print "ERROR: Cannot start qubes_guid!" exit (1) - if options.verbose: - print "--> Starting Qubes rexec..." + 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) + 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 1d1bf0c3..f427f59d 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 --dvm ; then +if ! qvm-start $1 --no-guid --no-rexec --dvm ; then exit 1 fi diff --git a/dom0/restore/qubes_restore.c b/dom0/restore/qubes_restore.c index 3788fb66..bafa55c4 100644 --- a/dom0/restore/qubes_restore.c +++ b/dom0/restore/qubes_restore.c @@ -182,6 +182,29 @@ int xend_connect() return s; } +void start_rexec(int domid) +{ + int pid, status; + char dstr[40]; + snprintf(dstr, sizeof(dstr), "%d", domid); + switch (pid = fork()) { + case -1: + perror("fork"); + exit(1); + case 0: + execl("/usr/lib/qubes/qrexec_daemon", "qrexec_daemon", + dstr, NULL); + perror("execl"); + exit(1); + default:; + } + if (waitpid(pid, &status, 0) < 0) { + perror("waitpid"); + exit(1); + } +} + + void start_guid(int domid, int argc, char **argv) { int i; @@ -197,6 +220,7 @@ void start_guid(int domid, int argc, char **argv) execv("/usr/bin/qubes_guid", guid_args); perror("execv"); } + // modify the savefile. fd = fd to the open savefile, // buf - already read 1st page of the savefile // pattern - pattern to search for @@ -452,10 +476,11 @@ int main(int argc, char **argv) resp = recv_resp(fd); // printf("%s\n", resp); fprintf(stderr, "time=%s, creating xenstore entries\n", gettime()); -#endif +#endif setup_xenstore(netvm_id, domid, dispid, name); fprintf(stderr, "time=%s, starting qubes_guid\n", gettime()); rm_fast_flag(); + start_rexec(domid); start_guid(domid, argc, argv); return 0; }