summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2010-02-24 14:37:14 +0100
committerMarkus Armbruster <armbru@redhat.com>2010-03-16 16:58:32 +0100
commit65abca0a3441fb47024553e7676f6f3eef685a32 (patch)
tree0243c816446758d7fe0c199231513e3fbff3edf7
parent827b08139c8ba97c18bda19e4893fdf26878b531 (diff)
downloadqemu-65abca0a3441fb47024553e7676f6f3eef685a32.tar.gz
qemu-65abca0a3441fb47024553e7676f6f3eef685a32.tar.bz2
qemu-65abca0a3441fb47024553e7676f6f3eef685a32.zip
error: Include the program name in error messages to stderr
-rw-r--r--qemu-error.c20
-rw-r--r--qemu-error.h1
-rw-r--r--vl.c2
3 files changed, 22 insertions, 1 deletions
diff --git a/qemu-error.c b/qemu-error.c
index 0d673c517e..214e4481e2 100644
--- a/qemu-error.c
+++ b/qemu-error.c
@@ -113,13 +113,31 @@ void loc_set_none(void)
cur_loc->kind = LOC_NONE;
}
+static const char *progname;
+
+/*
+ * Set the program name for error_print_loc().
+ */
+void error_set_progname(const char *argv0)
+{
+ const char *p = strrchr(argv0, '/');
+ progname = p ? p + 1 : argv0;
+}
+
/*
* Print current location to current monitor if we have one, else to stderr.
*/
void error_print_loc(void)
{
+ const char *sep = "";
+
+ if (!cur_mon) {
+ fprintf(stderr, "%s:", progname);
+ sep = " ";
+ }
switch (cur_loc->kind) {
- default: ;
+ default:
+ error_printf(sep);
}
}
diff --git a/qemu-error.h b/qemu-error.h
index a1562aaa02..204dfb6a97 100644
--- a/qemu-error.h
+++ b/qemu-error.h
@@ -31,6 +31,7 @@ void loc_set_none(void);
void error_vprintf(const char *fmt, va_list ap);
void error_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
void error_print_loc(void);
+void error_set_progname(const char *argv0);
void error_report(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
void qerror_report_internal(const char *file, int linenr, const char *func,
const char *fmt, ...)
diff --git a/vl.c b/vl.c
index 160f30a320..c3abeeff2e 100644
--- a/vl.c
+++ b/vl.c
@@ -4862,6 +4862,8 @@ int main(int argc, char **argv, char **envp)
int show_vnc_port = 0;
int defconfig = 1;
+ error_set_progname(argv[0]);
+
init_clocks();
qemu_cache_utils_init(envp);