summaryrefslogtreecommitdiff
path: root/qemu-error.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2010-02-18 19:48:33 +0100
committerMarkus Armbruster <armbru@redhat.com>2010-03-16 16:58:32 +0100
commitcf5a65aaaf3e9382e50df550ba049a1c8691a5dd (patch)
treecefb10d2cab499ba0d7c76682503a309c187dc4a /qemu-error.c
parent65abca0a3441fb47024553e7676f6f3eef685a32 (diff)
downloadqemu-cf5a65aaaf3e9382e50df550ba049a1c8691a5dd.tar.gz
qemu-cf5a65aaaf3e9382e50df550ba049a1c8691a5dd.tar.bz2
qemu-cf5a65aaaf3e9382e50df550ba049a1c8691a5dd.zip
error: Track locations in configuration files
New LOC_FILE. Use it for tracking file name and line number in qemu_config_parse(). We now report errors like qemu:foo.conf:42: Did not find I2C bus for smbus-eeprom In particular, gems like this message: -device: no driver specified become almost nice now: qemu:foo.conf:44: -device: no driver specified (A later commit will get rid of the bogus -device:)
Diffstat (limited to 'qemu-error.c')
-rw-r--r--qemu-error.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/qemu-error.c b/qemu-error.c
index 214e4481e2..23176e16a8 100644
--- a/qemu-error.c
+++ b/qemu-error.c
@@ -113,6 +113,19 @@ void loc_set_none(void)
cur_loc->kind = LOC_NONE;
}
+/*
+ * Change the current location to file FNAME, line LNO.
+ */
+void loc_set_file(const char *fname, int lno)
+{
+ assert (fname || cur_loc->kind == LOC_FILE);
+ cur_loc->kind = LOC_FILE;
+ cur_loc->num = lno;
+ if (fname) {
+ cur_loc->ptr = fname;
+ }
+}
+
static const char *progname;
/*
@@ -136,6 +149,13 @@ void error_print_loc(void)
sep = " ";
}
switch (cur_loc->kind) {
+ case LOC_FILE:
+ error_printf("%s:", (const char *)cur_loc->ptr);
+ if (cur_loc->num) {
+ error_printf("%d:", cur_loc->num);
+ }
+ error_printf(" ");
+ break;
default:
error_printf(sep);
}