|
|
9ae3a8 |
From d654202a62b8bf07cba4044e4eb912958c7392bb Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 28 Aug 2013 15:50:44 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 27/28] add timestamp to error_report()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1377705045-1054-2-git-send-email-lersek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 53886
|
|
|
9ae3a8 |
O-Subject: [RHEL-7 qemu-kvm PATCH v3 1/2] add timestamp to error_report()
|
|
|
9ae3a8 |
Bugzilla: 906937
|
|
|
9ae3a8 |
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Seiji Aguchi <seiji.aguchi@hds.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
[Issue]
|
|
|
9ae3a8 |
When we offer a customer support service and a problem happens
|
|
|
9ae3a8 |
in a customer's system, we try to understand the problem by
|
|
|
9ae3a8 |
comparing what the customer reports with message logs of the
|
|
|
9ae3a8 |
customer's system.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
In this case, we often need to know when the problem happens.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
But, currently, there is no timestamp in qemu's error messages.
|
|
|
9ae3a8 |
Therefore, we may not be able to understand the problem based on
|
|
|
9ae3a8 |
error messages.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
[Solution]
|
|
|
9ae3a8 |
Add a timestamp to qemu's error message logged by
|
|
|
9ae3a8 |
error_report() with g_time_val_to_iso8601().
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
|
|
|
9ae3a8 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 5e2ac5191772dea782ff78e95edd395985273019)
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
include/qemu/error-report.h | 2 ++
|
|
|
9ae3a8 |
util/qemu-error.c | 10 ++++++++++
|
|
|
9ae3a8 |
vl.c | 26 ++++++++++++++++++++++++++
|
|
|
9ae3a8 |
qemu-options.hx | 11 +++++++++++
|
|
|
9ae3a8 |
4 files changed, 49 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
include/qemu/error-report.h | 2 ++
|
|
|
9ae3a8 |
qemu-options.hx | 11 +++++++++++
|
|
|
9ae3a8 |
util/qemu-error.c | 10 ++++++++++
|
|
|
9ae3a8 |
vl.c | 26 ++++++++++++++++++++++++++
|
|
|
9ae3a8 |
4 files changed, 49 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
|
|
|
9ae3a8 |
index 14c1719..3b098a9 100644
|
|
|
9ae3a8 |
--- a/include/qemu/error-report.h
|
|
|
9ae3a8 |
+++ b/include/qemu/error-report.h
|
|
|
9ae3a8 |
@@ -14,6 +14,7 @@
|
|
|
9ae3a8 |
#define QEMU_ERROR_H
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#include <stdarg.h>
|
|
|
9ae3a8 |
+#include <stdbool.h>
|
|
|
9ae3a8 |
#include "qemu/compiler.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
typedef struct Location {
|
|
|
9ae3a8 |
@@ -40,5 +41,6 @@ void error_print_loc(void);
|
|
|
9ae3a8 |
void error_set_progname(const char *argv0);
|
|
|
9ae3a8 |
void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
|
|
|
9ae3a8 |
const char *error_get_progname(void);
|
|
|
9ae3a8 |
+extern bool enable_timestamp_msg;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
diff --git a/qemu-options.hx b/qemu-options.hx
|
|
|
9ae3a8 |
index fb62b75..2ad0ed2 100644
|
|
|
9ae3a8 |
--- a/qemu-options.hx
|
|
|
9ae3a8 |
+++ b/qemu-options.hx
|
|
|
9ae3a8 |
@@ -3095,6 +3095,17 @@ property must be set. These objects are placed in the
|
|
|
9ae3a8 |
'/objects' path.
|
|
|
9ae3a8 |
ETEXI
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+DEF("msg", HAS_ARG, QEMU_OPTION_msg,
|
|
|
9ae3a8 |
+ "-msg timestamp[=on|off]\n"
|
|
|
9ae3a8 |
+ " change the format of messages\n"
|
|
|
9ae3a8 |
+ " on|off controls leading timestamps (default:on)\n",
|
|
|
9ae3a8 |
+ QEMU_ARCH_ALL)
|
|
|
9ae3a8 |
+STEXI
|
|
|
9ae3a8 |
+@item -msg timestamp[=on|off]
|
|
|
9ae3a8 |
+@findex -msg
|
|
|
9ae3a8 |
+prepend a timestamp to each log message.(default:on)
|
|
|
9ae3a8 |
+ETEXI
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
HXCOMM This is the last statement. Insert new options before this line!
|
|
|
9ae3a8 |
STEXI
|
|
|
9ae3a8 |
@end table
|
|
|
9ae3a8 |
diff --git a/util/qemu-error.c b/util/qemu-error.c
|
|
|
9ae3a8 |
index 08a36f4..fec02c6 100644
|
|
|
9ae3a8 |
--- a/util/qemu-error.c
|
|
|
9ae3a8 |
+++ b/util/qemu-error.c
|
|
|
9ae3a8 |
@@ -196,6 +196,7 @@ void error_print_loc(void)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+bool enable_timestamp_msg;
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* Print an error message to current monitor if we have one, else to stderr.
|
|
|
9ae3a8 |
* Format arguments like sprintf(). The result should not contain
|
|
|
9ae3a8 |
@@ -206,6 +207,15 @@ void error_print_loc(void)
|
|
|
9ae3a8 |
void error_report(const char *fmt, ...)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
va_list ap;
|
|
|
9ae3a8 |
+ GTimeVal tv;
|
|
|
9ae3a8 |
+ gchar *timestr;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (enable_timestamp_msg) {
|
|
|
9ae3a8 |
+ g_get_current_time(&tv;;
|
|
|
9ae3a8 |
+ timestr = g_time_val_to_iso8601(&tv;;
|
|
|
9ae3a8 |
+ error_printf("%s ", timestr);
|
|
|
9ae3a8 |
+ g_free(timestr);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
error_print_loc();
|
|
|
9ae3a8 |
va_start(ap, fmt);
|
|
|
9ae3a8 |
diff --git a/vl.c b/vl.c
|
|
|
9ae3a8 |
index d424af7..0ce554d 100644
|
|
|
9ae3a8 |
--- a/vl.c
|
|
|
9ae3a8 |
+++ b/vl.c
|
|
|
9ae3a8 |
@@ -518,6 +518,18 @@ static QemuOptsList qemu_realtime_opts = {
|
|
|
9ae3a8 |
},
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static QemuOptsList qemu_msg_opts = {
|
|
|
9ae3a8 |
+ .name = "msg",
|
|
|
9ae3a8 |
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_msg_opts.head),
|
|
|
9ae3a8 |
+ .desc = {
|
|
|
9ae3a8 |
+ {
|
|
|
9ae3a8 |
+ .name = "timestamp",
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_BOOL,
|
|
|
9ae3a8 |
+ },
|
|
|
9ae3a8 |
+ { /* end of list */ }
|
|
|
9ae3a8 |
+ },
|
|
|
9ae3a8 |
+};
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/**
|
|
|
9ae3a8 |
* Get machine options
|
|
|
9ae3a8 |
*
|
|
|
9ae3a8 |
@@ -1473,6 +1485,12 @@ static void configure_realtime(QemuOpts *opts)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+static void configure_msg(QemuOpts *opts)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ enable_timestamp_msg = qemu_opt_get_bool(opts, "timestamp", true);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/***********************************************************/
|
|
|
9ae3a8 |
/* USB devices */
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -2911,6 +2929,7 @@ int main(int argc, char **argv, char **envp)
|
|
|
9ae3a8 |
qemu_add_opts(&qemu_object_opts);
|
|
|
9ae3a8 |
qemu_add_opts(&qemu_tpmdev_opts);
|
|
|
9ae3a8 |
qemu_add_opts(&qemu_realtime_opts);
|
|
|
9ae3a8 |
+ qemu_add_opts(&qemu_msg_opts);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
runstate_init();
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -3883,6 +3902,13 @@ int main(int argc, char **argv, char **envp)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
configure_realtime(opts);
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
+ case QEMU_OPTION_msg:
|
|
|
9ae3a8 |
+ opts = qemu_opts_parse(qemu_find_opts("msg"), optarg, 0);
|
|
|
9ae3a8 |
+ if (!opts) {
|
|
|
9ae3a8 |
+ exit(1);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ configure_msg(opts);
|
|
|
9ae3a8 |
+ break;
|
|
|
9ae3a8 |
default:
|
|
|
9ae3a8 |
os_parse_cmd_args(popt->index, optarg);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|