Skip to contentSkip to conversation

libxl: pass debug flag down to libxl_domain_suspend

PATCH Superseded Olaf Hering 2 participants 8 messages Jan 31, 2013 – Feb 5, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: pass debug flag down to libxl_domain_suspend

# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1359648298 -3600
# Node ID 256d59b2bc8a413876559dc8daf4c52ba46677de # Parent 12455da211d4e841692b2374086356a87eb74ff7
libxl: pass debug flag down to libxl_domain_suspend

libxl_domain_suspend is already prepared to handle LIBXL_SUSPEND_DEBUG, and xl migrate handles the -d switch as well. Pass this flag down to libxl_domain_suspend, so that finally xc_domain_save can dump huge amount of debug data to stdout.
Update xl.5 and help text output.

docs/man/xl.pod.1 +4 -0
diff -r 12455da211d4 -r 256d59b2bc8a docs/man/xl.pod.1
@@ -387,6 +387,10 @@ domain. See the corresponding option of 
 
 Send <config> instead of config file from creation.
 
+=item B<-e>
+
+Print huge (!) amount of debug during the migration process.
+
 =back
 
 =item B<remus> [I<OPTIONS>] I<domain-id> I<host>
tools/libxl/xl_cmdimpl.c +6 -4
diff -r 12455da211d4 -r 256d59b2bc8a tools/libxl/xl_cmdimpl.c
@@ -3331,7 +3331,7 @@ static void migrate_do_preamble(int send
 
 }
 
-static void migrate_domain(uint32_t domid, const char *rune,
+static void migrate_domain(uint32_t domid, const char *rune, int debug,
                            const char *override_config_file)
 {
     pid_t child = -1;
@@ -3340,7 +3340,7 @@ static void migrate_domain(uint32_t domi
     char *away_domname;
     char rc_buf;
     uint8_t *config_data;
-    int config_len;
+    int config_len, flags = LIBXL_SUSPEND_LIVE;
 
     save_domain_core_begin(domid, override_config_file,
                            &config_data, &config_len);
@@ -3358,7 +3358,9 @@ static void migrate_domain(uint32_t domi
 
     xtl_stdiostream_adjust_flags(logger, XTL_STDIOSTREAM_HIDE_PROGRESS, 0);
 
-    rc = libxl_domain_suspend(ctx, domid, send_fd, LIBXL_SUSPEND_LIVE, NULL);
+    if (debug)
+        flags |= LIBXL_SUSPEND_DEBUG;
+    rc = libxl_domain_suspend(ctx, domid, send_fd, flags, NULL);
     if (rc) {
         fprintf(stderr, "migration sender: libxl_domain_suspend failed"
                 " (rc=%d)\n", rc);
@@ -3784,7 +3786,7 @@ int main_migrate(int argc, char **argv)
             return 1;
     }
 
-    migrate_domain(domid, rune, config_filename);
+    migrate_domain(domid, rune, debug, config_filename);
     return 0;
 }
 
tools/libxl/xl_cmdtable.c +2 -1
diff -r 12455da211d4 -r 256d59b2bc8a tools/libxl/xl_cmdtable.c
@@ -153,7 +153,8 @@ struct cmd_spec cmd_table[] = {
       "                to sh. If empty, run <host> instead of ssh <host> xl\n"
       "                migrate-receive [-d -e]\n"
       "-e              Do not wait in the background (on <host>) for the death\n"
-      "                of the domain."
+      "                of the domain.\n"
+      "-d              Print huge (!) amount of debug during the migration process."
     },
     { "dump-core",
       &main_dump_core, 0, 1,
#1 lore raw

PATCH v2 1/1 libxl: pass debug flag down to libxl_domain_suspend

# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1359658156 -3600
# Node ID 7265026699c6a72e150d40d2fb45fd4131c83c19 # Parent 12455da211d4e841692b2374086356a87eb74ff7
libxl: pass debug flag down to libxl_domain_suspend

libxl_domain_suspend is already prepared to handle LIBXL_SUSPEND_DEBUG, and xl migrate handles the -d switch as well. Pass this flag down to libxl_domain_suspend, so that finally xc_domain_save can dump huge amount of debug data to stdout.
Update xl.1 and help text output.

v2:
- fix xl.1 option, really use -d instead of -e

docs/man/xl.pod.1 +4 -0
diff -r 12455da211d4 -r 7265026699c6 docs/man/xl.pod.1
@@ -387,6 +387,10 @@ domain. See the corresponding option of 
 
 Send <config> instead of config file from creation.
 
+=item B<-d>
+
+Print huge (!) amount of debug during the migration process.
+
 =back
 
 =item B<remus> [I<OPTIONS>] I<domain-id> I<host>
tools/libxl/xl_cmdimpl.c +6 -4
diff -r 12455da211d4 -r 7265026699c6 tools/libxl/xl_cmdimpl.c
@@ -3331,7 +3331,7 @@ static void migrate_do_preamble(int send
 
 }
 
-static void migrate_domain(uint32_t domid, const char *rune,
+static void migrate_domain(uint32_t domid, const char *rune, int debug,
                            const char *override_config_file)
 {
     pid_t child = -1;
@@ -3340,7 +3340,7 @@ static void migrate_domain(uint32_t domi
     char *away_domname;
     char rc_buf;
     uint8_t *config_data;
-    int config_len;
+    int config_len, flags = LIBXL_SUSPEND_LIVE;
 
     save_domain_core_begin(domid, override_config_file,
                            &config_data, &config_len);
@@ -3358,7 +3358,9 @@ static void migrate_domain(uint32_t domi
 
     xtl_stdiostream_adjust_flags(logger, XTL_STDIOSTREAM_HIDE_PROGRESS, 0);
 
-    rc = libxl_domain_suspend(ctx, domid, send_fd, LIBXL_SUSPEND_LIVE, NULL);
+    if (debug)
+        flags |= LIBXL_SUSPEND_DEBUG;
+    rc = libxl_domain_suspend(ctx, domid, send_fd, flags, NULL);
     if (rc) {
         fprintf(stderr, "migration sender: libxl_domain_suspend failed"
                 " (rc=%d)\n", rc);
@@ -3784,7 +3786,7 @@ int main_migrate(int argc, char **argv)
             return 1;
     }
 
-    migrate_domain(domid, rune, config_filename);
+    migrate_domain(domid, rune, debug, config_filename);
     return 0;
 }
 
tools/libxl/xl_cmdtable.c +2 -1
diff -r 12455da211d4 -r 7265026699c6 tools/libxl/xl_cmdtable.c
@@ -153,7 +153,8 @@ struct cmd_spec cmd_table[] = {
       "                to sh. If empty, run <host> instead of ssh <host> xl\n"
       "                migrate-receive [-d -e]\n"
       "-e              Do not wait in the background (on <host>) for the death\n"
-      "                of the domain."
+      "                of the domain.\n"
+      "-d              Print huge (!) amount of debug during the migration process."
     },
     { "dump-core",
       &main_dump_core, 0, 1,
#2 lore raw
Quoted 7 lines · Olaf Hering

# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1359658156 -3600
# Node ID 7265026699c6a72e150d40d2fb45fd4131c83c19 # Parent 12455da211d4e841692b2374086356a87eb74ff7
libxl: pass debug flag down to libxl_domain_suspend

Quoted 8 lines

libxl_domain_suspend is already prepared to handle LIBXL_SUSPEND_DEBUG, and xl migrate handles the -d switch as well. Pass this flag down to libxl_domain_suspend, so that finally xc_domain_save can dump huge amount of debug data to stdout.
Update xl.1 and help text output.

v2:
- fix xl.1 option, really use -d instead of -e

Oops, you can ignore my first comment on v1 then ;-)

#3 lore raw
In reply to Olaf Hering
Quoted 19 lines · Olaf Hering

# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1359648298 -3600
# Node ID 256d59b2bc8a413876559dc8daf4c52ba46677de # Parent 12455da211d4e841692b2374086356a87eb74ff7
libxl: pass debug flag down to libxl_domain_suspend

libxl_domain_suspend is already prepared to handle LIBXL_SUSPEND_DEBUG, and xl migrate handles the -d switch as well. Pass this flag down to libxl_domain_suspend, so that finally xc_domain_save can dump huge amount of debug data to stdout.
Update xl.5 and help text output.

diff -r 12455da211d4 -r 256d59b2bc8a docs/man/xl.pod.1

docs/man/xl.pod.1 domain. See the corresponding option of · line 390

Quoted 4 lines
docs/man/xl.pod.1 +1 -0
@@ -387,6 +387,10 @@ domain. See the corresponding option of 
 
 Send <config> instead of config file from creation.
 
+=item B<-e>

You mean -d here.

I wonder if we should make this option a bit more obscure (e.g. a long option only) ? Or tie it to verbose > 5 or something?

Ian.

#4 lore raw
Quoted 21 lines · Ian Campbell
Quoted 20 lines · Olaf Hering

# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1359648298 -3600
# Node ID 256d59b2bc8a413876559dc8daf4c52ba46677de # Parent 12455da211d4e841692b2374086356a87eb74ff7
libxl: pass debug flag down to libxl_domain_suspend

libxl_domain_suspend is already prepared to handle LIBXL_SUSPEND_DEBUG, and xl migrate handles the -d switch as well. Pass this flag down to libxl_domain_suspend, so that finally xc_domain_save can dump huge amount of debug data to stdout.
Update xl.5 and help text output.

diff -r 12455da211d4 -r 256d59b2bc8a docs/man/xl.pod.1

docs/man/xl.pod.1 +0 -0
@@ -387,6 +387,10 @@ domain. See the corresponding option of 
 
Quoted 8 lines

docs/man/xl.pod.1 domain. See the corresponding option of · line 390

Quoted 3 lines
docs/man/xl.pod.1 +1 -0
 Send <config> instead of config file from creation.
 
+=item B<-e>

You mean -d here.

I wonder if we should make this option a bit more obscure (e.g. a long option only) ? Or tie it to verbose > 5 or something?

I'm not sure how to create a long only option. But if it has to be specified two or three times to really enable it, that would be ok for me. Will send v3 of this change shortly.

Olaf

#5 lore raw
Quoted 25 lines · Olaf Hering
Quoted 23 lines · Ian Campbell
Quoted 22 lines · Olaf Hering

# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1359648298 -3600
# Node ID 256d59b2bc8a413876559dc8daf4c52ba46677de # Parent 12455da211d4e841692b2374086356a87eb74ff7
libxl: pass debug flag down to libxl_domain_suspend

libxl_domain_suspend is already prepared to handle LIBXL_SUSPEND_DEBUG, and xl migrate handles the -d switch as well. Pass this flag down to libxl_domain_suspend, so that finally xc_domain_save can dump huge amount of debug data to stdout.
Update xl.5 and help text output.

diff -r 12455da211d4 -r 256d59b2bc8a docs/man/xl.pod.1

docs/man/xl.pod.1 +0 -0
@@ -387,6 +387,10 @@ domain. See the corresponding option of 
 
 Send <config> instead of config file from creation.
 
Quoted 8 lines
Quoted 6 lines

docs/man/xl.pod.1 domain. See the corresponding option of · line 390

Quoted 1 line
docs/man/xl.pod.1 +1 -0
+=item B<-e>

You mean -d here.

I wonder if we should make this option a bit more obscure (e.g. a long option only) ? Or tie it to verbose > 5 or something?

I'm not sure how to create a long only option.

I've not tried it but I think where normally for -c/--cpus you would have:

	{"cpus", 0, 0, 'c'},
	...
	case 'c': ...

You can also have non-char keys in the last field (val) e.g.

	{"foo", 0, 0, 0x100},
	...
	case 0x100: ...

(0x100 because that's not an ascii character so no clash).

Quoted 3 lines

But if it has to be
specified two or three times to really enable it, that would be ok for me. Will send v3 of this change shortly.

I was trying to avoid swallowing one of the lower case letters (which are finite) for a rarely used debug option, rather than worrying about people enabling it by mistake, so -d -d -d doesn't really help.

Ian.

#6 lore raw

PATCH v3 1/1 libxl: pass debug flag down to libxl_domain_suspend

In reply to Olaf Hering

# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1360073994 -3600
# Node ID e2b8970eb702b5151a81c9c5fbbf2e2da7836fd6 # Parent 9ce7648327cdbcd7a24052d6f0e85378627988db
libxl: pass debug flag down to libxl_domain_suspend

libxl_domain_suspend is already prepared to handle LIBXL_SUSPEND_DEBUG, and xl migrate handles the -d switch as well. Pass this flag down to libxl_domain_suspend, so that finally xc_domain_save can dump huge amount of debug data to stdout.
Update xl.1 and help text output.

v3:
- require 3 -d options to really enable it

v2:
- fix xl.1 option, really use -d instead of -e

docs/man/xl.pod.1 +5 -0
diff -r 9ce7648327cd -r e2b8970eb702 docs/man/xl.pod.1
@@ -387,6 +387,11 @@ domain. See the corresponding option of 
 
 Send <config> instead of config file from creation.
 
+=item B<-d>
+
+Print huge (!) amount of debug during the migration process.
+This option has to be specfied three times to really enable it.
+
 =back
 
 =item B<remus> [I<OPTIONS>] I<domain-id> I<host>
tools/libxl/xl_cmdimpl.c +7 -5
diff -r 9ce7648327cd -r e2b8970eb702 tools/libxl/xl_cmdimpl.c
@@ -3331,7 +3331,7 @@ static void migrate_do_preamble(int send
 
 }
 
-static void migrate_domain(uint32_t domid, const char *rune,
+static void migrate_domain(uint32_t domid, const char *rune, int debug,
                            const char *override_config_file)
 {
     pid_t child = -1;
@@ -3340,7 +3340,7 @@ static void migrate_domain(uint32_t domi
     char *away_domname;
     char rc_buf;
     uint8_t *config_data;
-    int config_len;
+    int config_len, flags = LIBXL_SUSPEND_LIVE;
 
     save_domain_core_begin(domid, override_config_file,
                            &config_data, &config_len);
@@ -3358,7 +3358,9 @@ static void migrate_domain(uint32_t domi
 
     xtl_stdiostream_adjust_flags(logger, XTL_STDIOSTREAM_HIDE_PROGRESS, 0);
 
-    rc = libxl_domain_suspend(ctx, domid, send_fd, LIBXL_SUSPEND_LIVE, NULL);
+    if (debug)
+        flags |= LIBXL_SUSPEND_DEBUG;
+    rc = libxl_domain_suspend(ctx, domid, send_fd, flags, NULL);
     if (rc) {
         fprintf(stderr, "migration sender: libxl_domain_suspend failed"
                 " (rc=%d)\n", rc);
@@ -3767,7 +3769,7 @@ int main_migrate(int argc, char **argv)
         monitor = 0;
         break;
     case 'd':
-        debug = 1;
+        debug++;
         break;
     }
 
@@ -3784,7 +3786,7 @@ int main_migrate(int argc, char **argv)
             return 1;
     }
 
-    migrate_domain(domid, rune, config_filename);
+    migrate_domain(domid, rune, debug >= 3, config_filename);
     return 0;
 }
 
tools/libxl/xl_cmdtable.c +2 -1
diff -r 9ce7648327cd -r e2b8970eb702 tools/libxl/xl_cmdtable.c
@@ -153,7 +153,8 @@ struct cmd_spec cmd_table[] = {
       "                to sh. If empty, run <host> instead of ssh <host> xl\n"
       "                migrate-receive [-d -e]\n"
       "-e              Do not wait in the background (on <host>) for the death\n"
-      "                of the domain."
+      "                of the domain.\n"
+      "-d -d -d        Print huge (!) amount of debug during the migration process."
     },
     { "dump-core",
       &main_dump_core, 0, 1,
#7 lore raw

PATCH v4 1/1 libxl: pass debug flag down to libxl_domain_suspend

In reply to Olaf Hering

# HG changeset patch
# User Olaf Hering <[email protected]>
# Date 1360076904 -3600
# Node ID d3caef1468f2b538de42d8998d49879f2b132ae1 # Parent 9ce7648327cdbcd7a24052d6f0e85378627988db
libxl: pass debug flag down to libxl_domain_suspend

libxl_domain_suspend is already prepared to handle LIBXL_SUSPEND_DEBUG, and xl migrate handles the -d switch as well. Pass this flag down to libxl_domain_suspend, so that finally xc_domain_save can dump huge amount of debug data to stdout.
Update xl.1 and help text output.

v4:
- change -d to --debug

v3:
- require 3 -d options to really enable it

v2:
- fix xl.1 option, really use -d instead of -e

docs/man/xl.pod.1 +4 -0
diff -r 9ce7648327cd -r d3caef1468f2 docs/man/xl.pod.1
@@ -387,6 +387,10 @@ domain. See the corresponding option of 
 
 Send <config> instead of config file from creation.
 
+=item B<--debug>
+
+Print huge (!) amount of debug during the migration process.
+
 =back
 
 =item B<remus> [I<OPTIONS>] I<domain-id> I<host>
tools/libxl/xl_cmdimpl.c +14 -7
diff -r 9ce7648327cd -r d3caef1468f2 tools/libxl/xl_cmdimpl.c
@@ -3331,7 +3331,7 @@ static void migrate_do_preamble(int send
 
 }
 
-static void migrate_domain(uint32_t domid, const char *rune,
+static void migrate_domain(uint32_t domid, const char *rune, int debug,
                            const char *override_config_file)
 {
     pid_t child = -1;
@@ -3340,7 +3340,7 @@ static void migrate_domain(uint32_t domi
     char *away_domname;
     char rc_buf;
     uint8_t *config_data;
-    int config_len;
+    int config_len, flags = LIBXL_SUSPEND_LIVE;
 
     save_domain_core_begin(domid, override_config_file,
                            &config_data, &config_len);
@@ -3358,7 +3358,9 @@ static void migrate_domain(uint32_t domi
 
     xtl_stdiostream_adjust_flags(logger, XTL_STDIOSTREAM_HIDE_PROGRESS, 0);
 
-    rc = libxl_domain_suspend(ctx, domid, send_fd, LIBXL_SUSPEND_LIVE, NULL);
+    if (debug)
+        flags |= LIBXL_SUSPEND_DEBUG;
+    rc = libxl_domain_suspend(ctx, domid, send_fd, flags, NULL);
     if (rc) {
         fprintf(stderr, "migration sender: libxl_domain_suspend failed"
                 " (rc=%d)\n", rc);
@@ -3751,8 +3753,13 @@ int main_migrate(int argc, char **argv)
     char *rune = NULL;
     char *host;
     int opt, daemonize = 1, monitor = 1, debug = 0;
-
-    SWITCH_FOREACH_OPT(opt, "FC:s:ed", NULL, "migrate", 2) {
+    static struct option opts[] = {
+        {"debug", 0, 0, 0x100},
+        COMMON_LONG_OPTS,
+        {0, 0, 0, 0}
+    };
+
+    SWITCH_FOREACH_OPT(opt, "FC:s:e", opts, "migrate", 2) {
     case 'C':
         config_filename = optarg;
         break;
@@ -3766,7 +3773,7 @@ int main_migrate(int argc, char **argv)
         daemonize = 0;
         monitor = 0;
         break;
-    case 'd':
+    case 0x100:
         debug = 1;
         break;
     }
@@ -3784,7 +3791,7 @@ int main_migrate(int argc, char **argv)
             return 1;
     }
 
-    migrate_domain(domid, rune, config_filename);
+    migrate_domain(domid, rune, debug, config_filename);
     return 0;
 }
 
tools/libxl/xl_cmdtable.c +2 -1
diff -r 9ce7648327cd -r d3caef1468f2 tools/libxl/xl_cmdtable.c
@@ -153,7 +153,8 @@ struct cmd_spec cmd_table[] = {
       "                to sh. If empty, run <host> instead of ssh <host> xl\n"
       "                migrate-receive [-d -e]\n"
       "-e              Do not wait in the background (on <host>) for the death\n"
-      "                of the domain."
+      "                of the domain.\n"
+      "--debug         Print huge (!) amount of debug during the migration process."
     },
     { "dump-core",
       &main_dump_core, 0, 1,