WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] tools: xl: add option to run in foreground but still

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] tools: xl: add option to run in foreground but still monitor for reboot etc
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Wed, 4 May 2011 16:36:05 +0100
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Delivery-date: Wed, 04 May 2011 08:37:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1304521205.26692.32.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1304521205.26692.32.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1304523348 -3600
# Node ID 6f20fdf37a97db6ff6ce4690057b8fd6662582f5
# Parent  f033c864926375fd545af71a2f0229c00c4354a7
tools: xl: add option to run in foreground but still monitor for reboot etc

Split daemonization option out from monitoring a domain for reboot
etc. The 'e' option continues to disable both and a new 'F'(oreground)
option disables only daemonization.

When I'm debugging xl in the foreground this is often the behaviour I
would like.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r f033c8649263 -r 6f20fdf37a97 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Tue May 03 14:57:55 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Wed May 04 16:35:48 2011 +0100
@@ -1268,6 +1268,7 @@ static int preserve_domain(libxl_ctx *ct
 struct domain_create {
     int debug;
     int daemonize;
+    int monitor; /* handle guest reboots etc */
     int paused;
     int dryrun;
     int quiet;
@@ -1347,6 +1348,7 @@ static int create_domain(struct domain_c
 
     int debug = dom_info->debug;
     int daemonize = dom_info->daemonize;
+    int monitor = dom_info->monitor;
     int paused = dom_info->paused;
     const char *config_file = dom_info->config_file;
     const char *extra_config = dom_info->extra_config;
@@ -1354,7 +1356,7 @@ static int create_domain(struct domain_c
     int migrate_fd = dom_info->migrate_fd;
 
     int fd, i;
-    int need_daemon = 1;
+    int need_daemon = daemonize;
     int ret, rc;
     libxl_waiter *w1 = NULL, *w2 = NULL;
     void *config_data = 0;
@@ -1537,7 +1539,7 @@ start:
         libxl_domain_unpause(ctx, domid);
 
     ret = domid; /* caller gets success in parent */
-    if (!daemonize)
+    if (!daemonize && !monitor)
         goto out;
 
     if (need_daemon) {
@@ -2722,7 +2724,7 @@ static void core_dump_domain(const char 
     if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(-1); }
 }
 
-static void migrate_receive(int debug, int daemonize)
+static void migrate_receive(int debug, int daemonize, int monitor)
 {
     int rc, rc2;
     char rc_buf;
@@ -2743,6 +2745,7 @@ static void migrate_receive(int debug, i
     memset(&dom_info, 0, sizeof(dom_info));
     dom_info.debug = debug;
     dom_info.daemonize = daemonize;
+    dom_info.monitor = monitor;
     dom_info.paused = 1;
     dom_info.restore_file = "incoming migration stream";
     dom_info.migrate_fd = 0; /* stdin */
@@ -2825,10 +2828,11 @@ int main_restore(int argc, char **argv)
     const char *checkpoint_file = NULL;
     const char *config_file = NULL;
     struct domain_create dom_info;
-    int paused = 0, debug = 0, daemonize = 1, console_autoconnect = 0;
+    int paused = 0, debug = 0, daemonize = 1, monitor = 1,
+        console_autoconnect = 0;
     int opt, rc;
 
-    while ((opt = getopt(argc, argv, "chpde")) != -1) {
+    while ((opt = getopt(argc, argv, "Fchpde")) != -1) {
         switch (opt) {
         case 'c':
             console_autoconnect = 1;
@@ -2839,8 +2843,12 @@ int main_restore(int argc, char **argv)
         case 'd':
             debug = 1;
             break;
+        case 'F':
+            daemonize = 0;
+            break;
         case 'e':
             daemonize = 0;
+            monitor = 0;
             break;
         case 'h':
             help("restore");
@@ -2864,6 +2872,7 @@ int main_restore(int argc, char **argv)
     memset(&dom_info, 0, sizeof(dom_info));
     dom_info.debug = debug;
     dom_info.daemonize = daemonize;
+    dom_info.monitor = monitor;
     dom_info.paused = paused;
     dom_info.config_file = config_file;
     dom_info.restore_file = checkpoint_file;
@@ -2879,17 +2888,21 @@ int main_restore(int argc, char **argv)
 
 int main_migrate_receive(int argc, char **argv)
 {
-    int debug = 0, daemonize = 1;
+    int debug = 0, daemonize = 1, monitor = 1;
     int opt;
 
-    while ((opt = getopt(argc, argv, "hed")) != -1) {
+    while ((opt = getopt(argc, argv, "Fhed")) != -1) {
         switch (opt) {
         case 'h':
             help("migrate-receive");
             return 2;
             break;
+        case 'F':
+            daemonize = 0;
+            break;
         case 'e':
             daemonize = 0;
+            monitor = 0;
             break;
         case 'd':
             debug = 1;
@@ -2904,7 +2917,7 @@ int main_migrate_receive(int argc, char 
         help("migrate-receive");
         return 2;
     }
-    migrate_receive(debug, daemonize);
+    migrate_receive(debug, daemonize, monitor);
     return 0;
 }
 
@@ -2948,9 +2961,9 @@ int main_migrate(int argc, char **argv)
     const char *ssh_command = "ssh";
     char *rune = NULL;
     char *host;
-    int opt, daemonize = 1, debug = 0;
-
-    while ((opt = getopt(argc, argv, "hC:s:ed")) != -1) {
+    int opt, daemonize = 1, monitor = 1, debug = 0;
+
+    while ((opt = getopt(argc, argv, "FhC:s:ed")) != -1) {
         switch (opt) {
         case 'h':
             help("migrate");
@@ -2961,8 +2974,12 @@ int main_migrate(int argc, char **argv)
         case 's':
             ssh_command = optarg;
             break;
+        case 'F':
+            daemonize = 0;
+            break;
         case 'e':
             daemonize = 0;
+            monitor = 0;
             break;
         case 'd':
             debug = 1;
@@ -3250,7 +3267,7 @@ int main_create(int argc, char **argv)
     char extra_config[1024];
     struct domain_create dom_info;
     int paused = 0, debug = 0, daemonize = 1, console_autoconnect = 0,
-        dryrun = 0, quiet = 0;
+        dryrun = 0, quiet = 0, monitor = 1;
     int opt, rc;
     int option_index = 0;
     static struct option long_options[] = {
@@ -3267,7 +3284,7 @@ int main_create(int argc, char **argv)
     }
 
     while (1) {
-        opt = getopt_long(argc, argv, "hnqf:pcde", long_options, 
&option_index);
+        opt = getopt_long(argc, argv, "Fhnqf:pcde", long_options, 
&option_index);
         if (opt == -1)
             break;
 
@@ -3284,8 +3301,12 @@ int main_create(int argc, char **argv)
         case 'd':
             debug = 1;
             break;
+        case 'F':
+            daemonize = 0;
+            break;
         case 'e':
             daemonize = 0;
+            monitor = 0;
             break;
         case 'h':
             help("create");
@@ -3318,6 +3339,7 @@ int main_create(int argc, char **argv)
     memset(&dom_info, 0, sizeof(dom_info));
     dom_info.debug = debug;
     dom_info.daemonize = daemonize;
+    dom_info.monitor = monitor;
     dom_info.paused = paused;
     dom_info.dryrun = dryrun;
     dom_info.quiet = quiet;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel