include/qemu/error-report.h | 2 ++ qemu-options.hx | 12 +++++++++--- softmmu/vl.c | 9 +++++++++ util/qemu-error.c | 7 +++++++ 4 files changed, 27 insertions(+), 3 deletions(-)
This is followup patch to the one submitted back in Oct, 19
https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg02102.html
My mistake here, I took my eyes of the mailing list after I got the
initial thumbs up. This patch follows up on Markus comments in the
above link.
Purpose of this patch:
We want to print guest name for errors, warnings and info messages. This
was the first of two patches the second being MCE errors targeting a VM
with guest name prepended. But in a large fleet we see many other
errors that disable a VM or crash it. In a large fleet and centralized
logging having the guest name enables identify of owner and customer.
Signed-off-by: Mario Smarduch <msmarduch@digitalocean.com>
---
Test verification summary:
a) qemu-system-x86_64 -msg help
guest-name=<bool (on/off)> - Prepends guest name for error messages but only if -name <guestname> is set otherwise option is ignored
timestamp=<bool (on/off)>
b) qemu-system-x86_64 -help
-msg [timestamp[=on|off]][,guest-name=[on|off]]
control error message format
timestamp=on enables timestamps (default: off)
guest-name=on enables guest name prefix but only if
-name guest option is set (default: off)
c) man qemu
-msg [timestamp[=on|off]][,guest-name[=on|off]]
Control error message format.
timestamp=on|off
Prefix messages with a timestamp. Default is off.
guest-name=on|off
Prefix messages with guest name but only if -name guest
option is set otherwise the option is ignored. Default is
off.
d) command options
./x86_64-softmmu/qemu-system-x86_64 -msg timestamp
2020-06-26T01:01:23.140294Z qemu-system-x86_64: Testing ERROR...
./x86_64-softmmu/qemu-system-x86_64 -msg timestamp,guest-name
2020-06-26T01:02:30.301431Z qemu-system-x86_64: Testing ERROR...
./x86_64-softmmu/qemu-system-x86_64 -msg timestamp,guest-name \
-name guest=DROPLET-123
2020-06-26T01:04:37.720380Z DROPLET-1234 qemu-system-x86_64: Testing ERROR...
./x86_64-softmmu/qemu-system-x86_64 -msg timestamp=off,guest-name=off \
-name guest=DROPLET-123
qemu-system-x86_64: Testing ERROR...
./x86_64-softmmu/qemu-system-x86_64 -msg timestamp=on,guest-name=off \
-name guest=DROPLET-123
2020-06-26T01:06:33.888859Z qemu-system-x86_64: Testing ERROR...
./x86_64-softmmu/qemu-system-x86_64 -msg timestamp=off,guest-name=on \
-name guest=DROPLET-123
DROPLET-1234 qemu-system-x86_64: Testing ERROR...
./x86_64-softmmu/qemu-system-x86_64 -msg timestamp=on,guest-name=on \
-name guest=DROPLET-123
2020-06-26T01:09:31.116283Z DROPLET-1234 qemu-system-x86_64: Testing ERROR...
include/qemu/error-report.h | 2 ++
qemu-options.hx | 12 +++++++++---
softmmu/vl.c | 9 +++++++++
util/qemu-error.c | 7 +++++++
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index 87532d8596..a5ad95ff1b 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -75,5 +75,7 @@ void error_init(const char *argv0);
const char *error_get_progname(void);
extern bool error_with_timestamp;
+extern bool error_with_guestname;
+extern const char *error_guest_name;
#endif
diff --git a/qemu-options.hx b/qemu-options.hx
index 93bde2bbc8..ff75510b7c 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4290,16 +4290,22 @@ HXCOMM Deprecated by -accel tcg
DEF("no-kvm", 0, QEMU_OPTION_no_kvm, "", QEMU_ARCH_I386)
DEF("msg", HAS_ARG, QEMU_OPTION_msg,
- "-msg timestamp[=on|off]\n"
+ "-msg [timestamp[=on|off]][,guest-name=[on|off]]\n"
" control error message format\n"
- " timestamp=on enables timestamps (default: off)\n",
+ " timestamp=on enables timestamps (default: off)\n"
+ " guest-name=on enables guest name prefix but only if\n"
+ " -name guest option is set (default: off)\n",
QEMU_ARCH_ALL)
SRST
-``-msg timestamp[=on|off]``
+``-msg [timestamp[=on|off]][,guest-name[=on|off]]``
Control error message format.
``timestamp=on|off``
Prefix messages with a timestamp. Default is off.
+
+ ``guest-name=on|off``
+ Prefix messages with guest name but only if -name guest option is set
+ otherwise the option is ignored. Default is off.
ERST
DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
diff --git a/softmmu/vl.c b/softmmu/vl.c
index f669c06ede..3f7aad89c3 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -389,6 +389,12 @@ static QemuOptsList qemu_msg_opts = {
.name = "timestamp",
.type = QEMU_OPT_BOOL,
},
+ {
+ .name = "guest-name",
+ .type = QEMU_OPT_BOOL,
+ .help = "Prepends guest name for error messages but only if "
+ "-name guest is set otherwise option is ignored\n",
+ },
{ /* end of list */ }
},
};
@@ -1109,6 +1115,7 @@ static void realtime_init(void)
static void configure_msg(QemuOpts *opts)
{
error_with_timestamp = qemu_opt_get_bool(opts, "timestamp", false);
+ error_with_guestname = qemu_opt_get_bool(opts, "guest-name", false);
}
@@ -3578,6 +3585,8 @@ void qemu_init(int argc, char **argv, char **envp)
if (!opts) {
exit(1);
}
+ /* Capture guest name if -msg guest-name is used later */
+ error_guest_name = qemu_opt_get(opts, "guest");
break;
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {
diff --git a/util/qemu-error.c b/util/qemu-error.c
index dac7c7dc50..017288b6c9 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -26,6 +26,8 @@ typedef enum {
/* Prepend timestamp to messages */
bool error_with_timestamp;
+bool error_with_guestname;
+const char *error_guest_name;
int error_printf(const char *fmt, ...)
{
@@ -213,6 +215,11 @@ static void vreport(report_type type, const char *fmt, va_list ap)
g_free(timestr);
}
+ /* Only prepend guest name if -msg guest-name and -name guest=... are set */
+ if (error_with_guestname && error_guest_name && !cur_mon) {
+ error_printf("%s ", error_guest_name);
+ }
+
print_loc();
switch (type) {
--
2.17.1
Patchew URL: https://patchew.org/QEMU/20200626201900.8876-1-msmarduch@digitalocean.com/ Hi, This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally. === TEST SCRIPT BEGIN === #! /bin/bash export ARCH=x86_64 make docker-image-fedora V=1 NETWORK=1 time make docker-test-mingw@fedora J=14 NETWORK=1 === TEST SCRIPT END === raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=020e7e5d29b64032a2c4dc8298c72e78', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-zwjiwlea/src/docker-src.2020-06-26-16.24.46.11501:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=020e7e5d29b64032a2c4dc8298c72e78 make[1]: *** [docker-run] Error 1 make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-zwjiwlea/src' make: *** [docker-run-test-mingw@fedora] Error 2 real 7m4.382s user 0m8.330s The full log is available at http://patchew.org/logs/20200626201900.8876-1-msmarduch@digitalocean.com/testing.docker-mingw@fedora/?type=message. --- Email generated automatically by Patchew [https://patchew.org/]. Please send your feedback to patchew-devel@redhat.com
On 26/06/20 22:19, Mario Smarduch wrote: > This is followup patch to the one submitted back in Oct, 19 > > https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg02102.html > > My mistake here, I took my eyes of the mailing list after I got the > initial thumbs up. This patch follows up on Markus comments in the > above link. > > Purpose of this patch: > > We want to print guest name for errors, warnings and info messages. This > was the first of two patches the second being MCE errors targeting a VM > with guest name prepended. But in a large fleet we see many other > errors that disable a VM or crash it. In a large fleet and centralized > logging having the guest name enables identify of owner and customer. > > Signed-off-by: Mario Smarduch <msmarduch@digitalocean.com> > --- > Test verification summary: > > a) qemu-system-x86_64 -msg help > guest-name=<bool (on/off)> - Prepends guest name for error messages but only if -name <guestname> is set otherwise option is ignored > > timestamp=<bool (on/off)> > > b) qemu-system-x86_64 -help > -msg [timestamp[=on|off]][,guest-name=[on|off]] > control error message format > timestamp=on enables timestamps (default: off) > guest-name=on enables guest name prefix but only if > -name guest option is set (default: off) > > c) man qemu > -msg [timestamp[=on|off]][,guest-name[=on|off]] > Control error message format. > > timestamp=on|off > Prefix messages with a timestamp. Default is off. > > guest-name=on|off > Prefix messages with guest name but only if -name guest > option is set otherwise the option is ignored. Default is > off. > d) command options > ./x86_64-softmmu/qemu-system-x86_64 -msg timestamp > 2020-06-26T01:01:23.140294Z qemu-system-x86_64: Testing ERROR... > > ./x86_64-softmmu/qemu-system-x86_64 -msg timestamp,guest-name > 2020-06-26T01:02:30.301431Z qemu-system-x86_64: Testing ERROR... > > ./x86_64-softmmu/qemu-system-x86_64 -msg timestamp,guest-name \ > -name guest=DROPLET-123 > 2020-06-26T01:04:37.720380Z DROPLET-1234 qemu-system-x86_64: Testing ERROR... > > ./x86_64-softmmu/qemu-system-x86_64 -msg timestamp=off,guest-name=off \ > -name guest=DROPLET-123 > qemu-system-x86_64: Testing ERROR... > > ./x86_64-softmmu/qemu-system-x86_64 -msg timestamp=on,guest-name=off \ > -name guest=DROPLET-123 > 2020-06-26T01:06:33.888859Z qemu-system-x86_64: Testing ERROR... > > ./x86_64-softmmu/qemu-system-x86_64 -msg timestamp=off,guest-name=on \ > -name guest=DROPLET-123 > DROPLET-1234 qemu-system-x86_64: Testing ERROR... > > ./x86_64-softmmu/qemu-system-x86_64 -msg timestamp=on,guest-name=on \ > -name guest=DROPLET-123 > 2020-06-26T01:09:31.116283Z DROPLET-1234 qemu-system-x86_64: Testing ERROR... > > > include/qemu/error-report.h | 2 ++ > qemu-options.hx | 12 +++++++++--- > softmmu/vl.c | 9 +++++++++ > util/qemu-error.c | 7 +++++++ > 4 files changed, 27 insertions(+), 3 deletions(-) > > diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h > index 87532d8596..a5ad95ff1b 100644 > --- a/include/qemu/error-report.h > +++ b/include/qemu/error-report.h > @@ -75,5 +75,7 @@ void error_init(const char *argv0); > const char *error_get_progname(void); > > extern bool error_with_timestamp; > +extern bool error_with_guestname; > +extern const char *error_guest_name; > > #endif > diff --git a/qemu-options.hx b/qemu-options.hx > index 93bde2bbc8..ff75510b7c 100644 > --- a/qemu-options.hx > +++ b/qemu-options.hx > @@ -4290,16 +4290,22 @@ HXCOMM Deprecated by -accel tcg > DEF("no-kvm", 0, QEMU_OPTION_no_kvm, "", QEMU_ARCH_I386) > > DEF("msg", HAS_ARG, QEMU_OPTION_msg, > - "-msg timestamp[=on|off]\n" > + "-msg [timestamp[=on|off]][,guest-name=[on|off]]\n" > " control error message format\n" > - " timestamp=on enables timestamps (default: off)\n", > + " timestamp=on enables timestamps (default: off)\n" > + " guest-name=on enables guest name prefix but only if\n" > + " -name guest option is set (default: off)\n", > QEMU_ARCH_ALL) > SRST > -``-msg timestamp[=on|off]`` > +``-msg [timestamp[=on|off]][,guest-name[=on|off]]`` > Control error message format. > > ``timestamp=on|off`` > Prefix messages with a timestamp. Default is off. > + > + ``guest-name=on|off`` > + Prefix messages with guest name but only if -name guest option is set > + otherwise the option is ignored. Default is off. > ERST > > DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate, > diff --git a/softmmu/vl.c b/softmmu/vl.c > index f669c06ede..3f7aad89c3 100644 > --- a/softmmu/vl.c > +++ b/softmmu/vl.c > @@ -389,6 +389,12 @@ static QemuOptsList qemu_msg_opts = { > .name = "timestamp", > .type = QEMU_OPT_BOOL, > }, > + { > + .name = "guest-name", > + .type = QEMU_OPT_BOOL, > + .help = "Prepends guest name for error messages but only if " > + "-name guest is set otherwise option is ignored\n", > + }, > { /* end of list */ } > }, > }; > @@ -1109,6 +1115,7 @@ static void realtime_init(void) > static void configure_msg(QemuOpts *opts) > { > error_with_timestamp = qemu_opt_get_bool(opts, "timestamp", false); > + error_with_guestname = qemu_opt_get_bool(opts, "guest-name", false); > } > > > @@ -3578,6 +3585,8 @@ void qemu_init(int argc, char **argv, char **envp) > if (!opts) { > exit(1); > } > + /* Capture guest name if -msg guest-name is used later */ > + error_guest_name = qemu_opt_get(opts, "guest"); > break; > case QEMU_OPTION_prom_env: > if (nb_prom_envs >= MAX_PROM_ENVS) { > diff --git a/util/qemu-error.c b/util/qemu-error.c > index dac7c7dc50..017288b6c9 100644 > --- a/util/qemu-error.c > +++ b/util/qemu-error.c > @@ -26,6 +26,8 @@ typedef enum { > > /* Prepend timestamp to messages */ > bool error_with_timestamp; > +bool error_with_guestname; > +const char *error_guest_name; > > int error_printf(const char *fmt, ...) > { > @@ -213,6 +215,11 @@ static void vreport(report_type type, const char *fmt, va_list ap) > g_free(timestr); > } > > + /* Only prepend guest name if -msg guest-name and -name guest=... are set */ > + if (error_with_guestname && error_guest_name && !cur_mon) { > + error_printf("%s ", error_guest_name); > + } > + > print_loc(); > > switch (type) { > Queued, thanks. Paolo
© 2016 - 2024 Red Hat, Inc.