[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 5/5] xl: new loglvl command



Introduce a new command to dynamically change log level thresholds.
Provide adequate documentation.

Based on a patch by Jan Beulich.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
Cc: Jan Beulich <JBeulich@xxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 docs/man/xl.pod.1.in      | 22 +++++++++++++++++++++
 tools/libxl/xl.h          |  1 +
 tools/libxl/xl_cmdimpl.c  | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/xl_cmdtable.c |  6 ++++++
 4 files changed, 78 insertions(+)

diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index c1e6b7f..9abd06a 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -810,6 +810,28 @@ Pass VNC password to vncviewer via stdin.
 Send debug I<keys> to Xen. It is the same as pressing the Xen
 "conswitch" (Ctrl-A by default) three times and then pressing "keys".
 
+=item B<loglvl> [B<-g>] [B<-s [lower_threshold][/upper_threshold]>]
+
+Get and set the log level thresholds.
+
+B<OPTIONS>
+
+=over 4
+
+=item B<-g>, B<--guest>
+
+Select guest log levels instead of host wide log levels.
+
+=item B<-s [lower_threshold][/upper_threshold]> 
B<--set=[lower_threshold][/upper_threshold]>
+
+Set the lower threshold to B<lower_threshold> and optionally set upper
+threshold to B<upper_threshold>.
+
+If this option is not specified, the command prints the current lower
+threshold and upper threshold.
+
+=back
+
 =item B<dmesg> [B<-c>]
 
 Reads the Xen message buffer, similar to dmesg on a Linux system.  The
diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h
index e601ca1..4bf16ee 100644
--- a/tools/libxl/xl.h
+++ b/tools/libxl/xl.h
@@ -80,6 +80,7 @@ int main_rename(int argc, char **argv);
 int main_trigger(int argc, char **argv);
 int main_sysrq(int argc, char **argv);
 int main_debug_keys(int argc, char **argv);
+int main_loglvl(int argc, char **argv);
 int main_dmesg(int argc, char **argv);
 int main_top(int argc, char **argv);
 int main_networkattach(int argc, char **argv);
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 6459eec..b01bdaa 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -7160,6 +7160,55 @@ int main_debug_keys(int argc, char **argv)
     return EXIT_SUCCESS;
 }
 
+int main_loglvl(int argc, char **argv)
+{
+    int opt;
+    bool guest = false, set = false;
+    char *lower_thresh = NULL, *upper_thresh = NULL, *delim = NULL;
+    char lower_thresh_out[16], upper_thresh_out[16];
+    unsigned int llen, ulen;
+    int rc;
+    static const struct option opts[] = {
+        {"guest", 0, 0, 'g'},
+        {"set", 0, 0, 's'},
+        COMMON_LONG_OPTS
+    };
+
+    SWITCH_FOREACH_OPT(opt, "gs:", opts, "loglvl", 0) {
+    case 'g':
+        guest = true;
+        break;
+    case 's':
+        delim = strstr(optarg, "/");
+
+        if (delim) {
+            if (delim != optarg)
+                lower_thresh = optarg;
+            *delim = 0;
+            upper_thresh = ++delim;
+        } else {
+            lower_thresh = optarg;
+        }
+
+        set = true;
+        break;
+    }
+
+    if (set)
+        rc = libxl_set_log_level(ctx, guest, lower_thresh, upper_thresh);
+    else {
+        llen = sizeof(lower_thresh_out);
+        ulen = sizeof(upper_thresh_out);
+        rc = libxl_get_log_level(ctx, guest, lower_thresh_out, &llen,
+                                 upper_thresh_out, &ulen);
+        if (!rc)
+            printf("%s log levels: %s/%s\n", guest ? "guest" : "host",
+                   lower_thresh_out, upper_thresh_out);
+    }
+
+    return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
 int main_dmesg(int argc, char **argv)
 {
     unsigned int clear = 0;
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index bf69ffb..3f3e996 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -583,6 +583,12 @@ struct cmd_spec cmd_table[] = {
       "List information about all USB controllers and devices for a domain",
       "<Domain>",
     },
+    { "loglvl",
+      &main_loglvl, 0, 1,
+      "[-g] [-s=[LOWER]/[UPPER]]",
+      "-g,                 --guest                 act on guest log level\n"
+      "-s [LOWER][/UPPER], --set=[LOWER][/UPPER]   set new log level\n"
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.