From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: [PATCH v2 5/5] xl: new loglvl command
Date: Mon, 4 Jul 2016 16:13:26 +0100 [thread overview]
Message-ID: <1467645206-28142-6-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1467645206-28142-1-git-send-email-wei.liu2@citrix.com>
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@suse.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
---
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@lists.xen.org
https://lists.xen.org/xen-devel
prev parent reply other threads:[~2016-07-04 15:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-04 15:13 [PATCH v2 0/5] Allow runtime adjustment to log level thresholds Wei Liu
2016-07-04 15:13 ` [PATCH v2 1/5] xen/console: consolidate log levels to an array Wei Liu
2016-07-04 15:28 ` Wei Liu
2016-07-07 10:39 ` Jan Beulich
2016-07-04 15:13 ` [PATCH v2 2/5] xen/console: allow log level threshold adjustments Wei Liu
2016-07-05 17:52 ` Daniel De Graaf
2016-07-06 11:14 ` Ian Jackson
2016-07-07 11:51 ` Jan Beulich
2016-07-04 15:13 ` [PATCH v2 3/5] libxc: wrapper for log level sysctl Wei Liu
2016-07-06 11:11 ` Ian Jackson
2016-07-04 15:13 ` [PATCH v2 4/5] libxl: introduce APIs to get and set log level Wei Liu
2016-07-06 11:15 ` Ian Jackson
2016-07-04 15:13 ` Wei Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467645206-28142-6-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=JBeulich@suse.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).