From: Olaf Hering <olaf@aepfle.de>
To: xen-devel@lists.xenproject.org
Cc: Olaf Hering <olaf@aepfle.de>, Ian Jackson <iwj@xenproject.org>,
Wei Liu <wl@xen.org>, Anthony PERARD <anthony.perard@citrix.com>
Subject: [PATCH v20210209 3/4] xl: optionally print timestamps when running xl commands
Date: Tue, 9 Feb 2021 16:45:35 +0100 [thread overview]
Message-ID: <20210209154536.10851-4-olaf@aepfle.de> (raw)
In-Reply-To: <20210209154536.10851-1-olaf@aepfle.de>
Add a global option "-T" to xl to enable timestamps in the output from
libxl and libxc. This is most useful with long running commands such
as "migrate".
During 'xl -v.. migrate domU host' a large amount of debug is generated.
It is difficult to map each line to the sending and receiving side.
Also the time spent for migration is not reported.
With 'xl -T migrate domU host' both sides will print timestamps and
also the pid of the invoked xl process to make it more obvious which
side produced a given log line.
Note: depending on the command, xl itself also produces other output
which does not go through libxentoollog. As a result such output will
not have timestamps prepended.
This change adds also the missing "-t" flag to "xl help" output.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
docs/man/xl.1.pod.in | 4 ++++
tools/xl/xl.c | 18 +++++++++++++-----
tools/xl/xl.h | 1 +
tools/xl/xl_migrate.c | 3 ++-
4 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in
index 618c195148..e2176bd696 100644
--- a/docs/man/xl.1.pod.in
+++ b/docs/man/xl.1.pod.in
@@ -86,6 +86,10 @@ Always use carriage-return-based overwriting for displaying progress
messages without scrolling the screen. Without -t, this is done only
if stderr is a tty.
+=item B<-T>
+
+Include timestamps and pid of the xl process in output.
+
=back
=head1 DOMAIN SUBCOMMANDS
diff --git a/tools/xl/xl.c b/tools/xl/xl.c
index 2a5ddd4390..3a89295802 100644
--- a/tools/xl/xl.c
+++ b/tools/xl/xl.c
@@ -52,6 +52,7 @@ libxl_bitmap global_pv_affinity_mask;
enum output_format default_output_format = OUTPUT_FORMAT_JSON;
int claim_mode = 1;
bool progress_use_cr = 0;
+bool timestamps = 0;
int max_grant_frames = -1;
int max_maptrack_frames = -1;
libxl_domid domid_policy = INVALID_DOMID;
@@ -365,8 +366,9 @@ int main(int argc, char **argv)
int ret;
void *config_data = 0;
int config_len = 0;
+ unsigned int xtl_flags = 0;
- while ((opt = getopt(argc, argv, "+vftN")) >= 0) {
+ while ((opt = getopt(argc, argv, "+vftTN")) >= 0) {
switch (opt) {
case 'v':
if (minmsglevel > 0) minmsglevel--;
@@ -380,6 +382,9 @@ int main(int argc, char **argv)
case 't':
progress_use_cr = 1;
break;
+ case 'T':
+ timestamps = 1;
+ break;
default:
fprintf(stderr, "unknown global option\n");
exit(EXIT_FAILURE);
@@ -394,8 +399,11 @@ int main(int argc, char **argv)
}
opterr = 0;
- logger = xtl_createlogger_stdiostream(stderr, minmsglevel,
- (progress_use_cr ? XTL_STDIOSTREAM_PROGRESS_USE_CR : 0));
+ if (progress_use_cr)
+ xtl_flags |= XTL_STDIOSTREAM_PROGRESS_USE_CR;
+ if (timestamps)
+ xtl_flags |= XTL_STDIOSTREAM_SHOW_DATE | XTL_STDIOSTREAM_SHOW_PID;
+ logger = xtl_createlogger_stdiostream(stderr, minmsglevel, xtl_flags);
if (!logger) exit(EXIT_FAILURE);
xl_ctx_alloc();
@@ -457,7 +465,7 @@ void help(const char *command)
struct cmd_spec *cmd;
if (!command || !strcmp(command, "help")) {
- printf("Usage xl [-vfN] <subcommand> [args]\n\n");
+ printf("Usage xl [-vfNtT] <subcommand> [args]\n\n");
printf("xl full list of subcommands:\n\n");
for (i = 0; i < cmdtable_len; i++) {
printf(" %-19s ", cmd_table[i].cmd_name);
@@ -468,7 +476,7 @@ void help(const char *command)
} else {
cmd = cmdtable_lookup(command);
if (cmd) {
- printf("Usage: xl [-v%s%s] %s %s\n\n%s.\n\n",
+ printf("Usage: xl [-vtT%s%s] %s %s\n\n%s.\n\n",
cmd->modifies ? "f" : "",
cmd->can_dryrun ? "N" : "",
cmd->cmd_name,
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index 06569c6c4a..137a29077c 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -269,6 +269,7 @@ extern int run_hotplug_scripts;
extern int dryrun_only;
extern int claim_mode;
extern bool progress_use_cr;
+extern bool timestamps;
extern xentoollog_level minmsglevel;
#define minmsglevel_default XTL_PROGRESS
extern char *lockfile;
diff --git a/tools/xl/xl_migrate.c b/tools/xl/xl_migrate.c
index 0813beb801..b8594f44a5 100644
--- a/tools/xl/xl_migrate.c
+++ b/tools/xl/xl_migrate.c
@@ -592,9 +592,10 @@ int main_migrate(int argc, char **argv)
} else {
verbose_len = (minmsglevel_default - minmsglevel) + 2;
}
- xasprintf(&rune, "exec %s %s xl%s%.*s migrate-receive%s%s%s",
+ xasprintf(&rune, "exec %s %s xl%s%s%.*s migrate-receive%s%s%s",
ssh_command, host,
pass_tty_arg ? " -t" : "",
+ timestamps ? " -T" : "",
verbose_len, verbose_buf,
daemonize ? "" : " -e",
debug ? " -d" : "",
next prev parent reply other threads:[~2021-02-09 15:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 15:45 [PATCH v20210209 0/4] tools changes Olaf Hering
2021-02-09 15:45 ` [PATCH v20210209 1/4] tools: move CONFIG_DIR and XEN_CONFIG_DIR in paths.m4 Olaf Hering
2021-02-09 16:48 ` Ian Jackson
2021-02-09 15:45 ` [PATCH v20210209 2/4] tools: add with-xen-scriptdir configure option Olaf Hering
2021-02-09 16:49 ` Ian Jackson
2021-02-09 15:45 ` Olaf Hering [this message]
2021-02-09 16:53 ` [PATCH v20210209 3/4] xl: optionally print timestamps when running xl commands Ian Jackson
2021-02-09 17:06 ` Olaf Hering
2021-02-09 17:16 ` Ian Jackson
2021-02-09 15:45 ` [PATCH v20210209 4/4] xl: disable --debug option for xl migrate Olaf Hering
2021-02-09 17:12 ` Ian Jackson
2021-02-09 17:16 ` Olaf Hering
2021-02-10 9:06 ` Olaf Hering
2021-02-10 9:44 ` Olaf Hering
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=20210209154536.10851-4-olaf@aepfle.de \
--to=olaf@aepfle.de \
--cc=anthony.perard@citrix.com \
--cc=iwj@xenproject.org \
--cc=wl@xen.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.