From 99e98d7c9fc1a1639fad2c638733b02f4b43aebe Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 31 Jan 2019 17:46:13 +0100 Subject: qemu-io: Use error_[gs]et_progname() qemu-io reimplements itself what error_get_progname()/error_set_progname() already does. This commit switches it to use this API from qemu-error.h Signed-off-by: Christophe Fergeau Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20190131164614.19209-2-cfergeau@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- qemu-io.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'qemu-io.c') diff --git a/qemu-io.c b/qemu-io.c index 6df7731..2c52ac0 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -34,8 +34,6 @@ #define CMD_NOFILE_OK 0x01 -static char *progname; - static BlockBackend *qemuio_blk; static bool quit_qemu_io; @@ -312,7 +310,7 @@ static char *get_prompt(void) static char prompt[FILENAME_MAX + 2 /*"> "*/ + 1 /*"\0"*/ ]; if (!prompt[0]) { - snprintf(prompt, sizeof(prompt), "%s> ", progname); + snprintf(prompt, sizeof(prompt), "%s> ", error_get_progname()); } return prompt; @@ -525,7 +523,7 @@ int main(int argc, char **argv) #endif module_call_init(MODULE_INIT_TRACE); - progname = g_path_get_basename(argv[0]); + error_set_progname(argv[0]); qemu_init_exec_dir(argv[0]); qcrypto_init(&error_fatal); @@ -580,10 +578,10 @@ int main(int argc, char **argv) break; case 'V': printf("%s version " QEMU_FULL_VERSION "\n" - QEMU_COPYRIGHT "\n", progname); + QEMU_COPYRIGHT "\n", error_get_progname()); exit(0); case 'h': - usage(progname); + usage(error_get_progname()); exit(0); case 'U': force_share = true; @@ -600,13 +598,13 @@ int main(int argc, char **argv) imageOpts = true; break; default: - usage(progname); + usage(error_get_progname()); exit(1); } } if ((argc - optind) > 1) { - usage(progname); + usage(error_get_progname()); exit(1); } -- cgit v1.1 From f5852efa293e1dc240cdfde30b42cea1f780a1f2 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 31 Jan 2019 17:46:14 +0100 Subject: log: Make glib logging go through QEMU This commit adds a error_init() helper which calls g_log_set_default_handler() so that glib logs (g_log, g_warning, ...) are handled similarly to other QEMU logs. This means they will get a timestamp if timestamps are enabled, and they will go through the HMP monitor if one is configured. This commit also adds a call to error_init() to the binaries installed by QEMU. Since error_init() also calls error_set_progname(), this means that *-linux-user, *-bsd-user and qemu-pr-helper messages output with error_report, info_report, ... will slightly change: they will be prefixed by the binary name. glib debug messages are enabled through G_MESSAGES_DEBUG similarly to the glib default log handler. At the moment, this change will mostly impact SPICE logging if your spice version is >= 0.14.1. With older spice versions, this is not going to work as expected, but will not have any ill effect, so this call is not conditional on the SPICE version. Signed-off-by: Christophe Fergeau Reviewed-by: Stefan Hajnoczi Message-Id: <20190131164614.19209-3-cfergeau@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- qemu-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qemu-io.c') diff --git a/qemu-io.c b/qemu-io.c index 2c52ac0..8d5d591 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -522,8 +522,8 @@ int main(int argc, char **argv) signal(SIGPIPE, SIG_IGN); #endif + error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); - error_set_progname(argv[0]); qemu_init_exec_dir(argv[0]); qcrypto_init(&error_fatal); -- cgit v1.1