Skip to contentSkip to conversation

tools: xl: on create, if debug && !daemonize, wait for domain destroy in the foreground

PATCH In review Ian Campbell 4 participants 8 messages Apr 18, 2011 – Jan 28, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: xl: on create, if debug && !daemonize, wait for domain destroy in the foreground

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1303143831 -3600
# Node ID 31b98feb0eb6a50fe9e664a31feaa32ad3dac7cc
# Parent 05abea47f4dc670974cd513a0e74db54d22eacc9
tools: xl: on create, if debug && !daemonize, wait for domain destroy in the foreground

Perhaps this should be a separate option but I find that when I'm debugging xl in the foreground this is the behaviour I would like.

tools/libxl/xl_cmdimpl.c +2 -2
diff -r 05abea47f4dc -r 31b98feb0eb6 tools/libxl/xl_cmdimpl.c
@@ -1354,7 +1354,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 +1537,7 @@ start:
         libxl_domain_unpause(ctx, domid);
 
     ret = domid; /* caller gets success in parent */
-    if (!daemonize)
+    if (!daemonize && !debug)
         goto out;
 
     if (need_daemon) {
#1 lore raw

Ian Campbell writes ("[Xen-devel] [PATCH] tools: xl: on create, if debug && !daemonize, wait for domain destroy in the foreground"):

Quoted 4 lines

tools: xl: on create, if debug && !daemonize, wait for domain destroy in the foreground

Perhaps this should be a separate option but I find that when I'm debugging xl in the foreground this is the behaviour I would like.

Normally the "-e" option prevents xl from restarting domains when they ask to reboot, etc.

With your patch, "-d" suppresses this property of "-e". Perhaps it would be better to have a new "run in foreground" option ?

Ian.

#2 lore raw
Quoted 8 lines · Ian Jackson

Ian Campbell writes ("[Xen-devel] [PATCH] tools: xl: on create, if debug && !daemonize, wait for domain destroy in the foreground"):

Quoted 4 lines

tools: xl: on create, if debug && !daemonize, wait for domain destroy in the foreground

Perhaps this should be a separate option but I find that when I'm debugging xl in the foreground this is the behaviour I would like.

Normally the "-e" option prevents xl from restarting domains when they ask to reboot, etc.

Oh, is that what it means...

Quoted 2 lines

With your patch, "-d" suppresses this property of "-e". Perhaps it would be better to have a new "run in foreground" option ?

Sure.

Ian.

#3 lore raw

PATCH 1/1 tools: xl: add option to run in foreground but still monitor for reboot etc

# HG changeset patch
# User Ian Campbell <[email protected]>
# 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.

tools/libxl/xl_cmdimpl.c +35 -13
diff -r f033c8649263 -r 6f20fdf37a97 tools/libxl/xl_cmdimpl.c
@@ -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;
#4 lore raw

Re: [PATCH] tools: xl: add option to run in foreground but still monitor for reboot etc

Quoted 6 lines · Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1304523348 -3600
# Node ID 6f20fdf37a97db6ff6ce4690057b8fd6662582f5
# Parent f033c864926375fd545af71a2f0229c00c4354a7
tools: xl: add option to run in foreground but still monitor for reboot etc

v3 updated for 23299:39f2942fe56b "xl: refactor common parts of command line parsing"

8<----------------------

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1304685600 -3600
# Node ID c0d309593d78b3e7340b805f95330249e7142169
# Parent 94ddef3d9f45fa36aa076a164dfbfa04c09eeb85
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.

tools/libxl/xl_cmdimpl.c +35 -13
diff -r 94ddef3d9f45 -r c0d309593d78 tools/libxl/xl_cmdimpl.c
@@ -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) {
@@ -2651,7 +2653,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;
@@ -2672,6 +2674,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 */
@@ -2754,10 +2757,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 = def_getopt(argc, argv, "cpde", "restore", 1)) != -1) {
+    while ((opt = def_getopt(argc, argv, "Fcpde", "restore", 1)) != -1) {
         switch (opt) {
         case 0: case 2:
             return opt;
@@ -2770,8 +2774,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;
         }
     }
@@ -2789,6 +2797,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;
@@ -2804,15 +2813,19 @@ 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 = def_getopt(argc, argv, "ed", "migrate-receive", 0)) != -1) {
+    while ((opt = def_getopt(argc, argv, "Fed", "migrate-receive", 0)) != -1) {
         switch (opt) {
         case 0: case 2:
             return opt;
+        case 'F':
+            daemonize = 0;
+            break;
         case 'e':
             daemonize = 0;
+            monitor = 0;
             break;
         case 'd':
             debug = 1;
@@ -2824,7 +2837,7 @@ int main_migrate_receive(int argc, char 
         help("migrate-receive");
         return 2;
     }
-    migrate_receive(debug, daemonize);
+    migrate_receive(debug, daemonize, monitor);
     return 0;
 }
 
@@ -2864,9 +2877,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 = def_getopt(argc, argv, "C:s:ed", "migrate", 2)) != -1) {
+    int opt, daemonize = 1, monitor = 1, debug = 0;
+
+    while ((opt = def_getopt(argc, argv, "FC:s:ed", "migrate", 2)) != -1) {
         switch (opt) {
         case 0: case 2:
             return opt;
@@ -2876,8 +2889,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;
@@ -3069,7 +3086,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[] = {
@@ -3086,7 +3103,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;
 
@@ -3103,8 +3120,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");
@@ -3137,6 +3158,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;
Applied
#5 lore raw

Re: [PATCH] tools: xl: add option to run in foreground but still monitor for reboot etc

Ian Campbell writes ("Re: [Xen-devel] [PATCH] tools: xl: add option to run in foreground but still monitor for reboot etc"):

Quoted 2 lines

v3 updated for 23299:39f2942fe56b "xl: refactor common parts of command line parsing"

Great, thanks.

Quoted 8 lines

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.

Applied.

Ian.

#6 lore raw

Re: [PATCH] tools: xl: add option to run in foreground but still monitor for reboot etc

In reply to Ian Campbell

Ian,

the xl migrate command gets a new option -F with this change. Is it intentional? The "monitor" variable is not used in this part of the patch.
It got applied in changeset 23350:f531ed84b066

Olaf

Quoted 54 lines · Ian Campbell
Quoted 6 lines · Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1304523348 -3600
# Node ID 6f20fdf37a97db6ff6ce4690057b8fd6662582f5
# Parent f033c864926375fd545af71a2f0229c00c4354a7
tools: xl: add option to run in foreground but still monitor for reboot etc

v3 updated for 23299:39f2942fe56b "xl: refactor common parts of command line parsing"

8<----------------------

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1304685600 -3600
# Node ID c0d309593d78b3e7340b805f95330249e7142169
# Parent 94ddef3d9f45fa36aa076a164dfbfa04c09eeb85
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.

tools/libxl/xl_cmdimpl.c +7 -3
@@ -2864,9 +2877,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 = def_getopt(argc, argv, "C:s:ed", "migrate", 2)) != -1) {
+    int opt, daemonize = 1, monitor = 1, debug = 0;
+
+    while ((opt = def_getopt(argc, argv, "FC:s:ed", "migrate", 2)) != -1) {
         switch (opt) {
         case 0: case 2:
             return opt;
@@ -2876,8 +2889,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;
#7 lore raw

Re: [PATCH] tools: xl: add option to run in foreground but still monitor for reboot etc

Quoted 6 lines · Olaf Hering

Ian,

the xl migrate command gets a new option -F with this change. Is it intentional? The "monitor" variable is not used in this part of the patch.

Looks like I intended to plumb it through to the invocation of migrate-receive?

Quoted 61 lines

It got applied in changeset 23350:f531ed84b066

Olaf

Quoted 54 lines · Ian Campbell
Quoted 6 lines · Ian Campbell

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1304523348 -3600
# Node ID 6f20fdf37a97db6ff6ce4690057b8fd6662582f5
# Parent f033c864926375fd545af71a2f0229c00c4354a7
tools: xl: add option to run in foreground but still monitor for reboot etc

v3 updated for 23299:39f2942fe56b "xl: refactor common parts of command line parsing"

8<----------------------

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1304685600 -3600
# Node ID c0d309593d78b3e7340b805f95330249e7142169
# Parent 94ddef3d9f45fa36aa076a164dfbfa04c09eeb85
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.

tools/libxl/xl_cmdimpl.c +7 -3
@@ -2864,9 +2877,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 = def_getopt(argc, argv, "C:s:ed", "migrate", 2)) != -1) {
+    int opt, daemonize = 1, monitor = 1, debug = 0;
+
+    while ((opt = def_getopt(argc, argv, "FC:s:ed", "migrate", 2)) != -1) {
         switch (opt) {
         case 0: case 2:
             return opt;
@@ -2876,8 +2889,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;