diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-02-18 19:46:49 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2010-03-16 16:58:32 +0100 |
commit | 827b08139c8ba97c18bda19e4893fdf26878b531 (patch) | |
tree | 1c02d74e56c7ee47b6542712a00872e02b794e9b /qemu-option.c | |
parent | ab5b027ee645f26320379d1d80cd96fdc944ecb5 (diff) | |
download | hqemu-827b08139c8ba97c18bda19e4893fdf26878b531.zip hqemu-827b08139c8ba97c18bda19e4893fdf26878b531.tar.gz |
error: Infrastructure to track locations for error reporting
New struct Location holds a location. So far, the only location is
LOC_NONE, so this doesn't do anything useful yet.
Passing the current location all over the place would be too
cumbersome. Hide it away in static cur_loc instead, and provide
accessors. Print it in error_report().
Store it in QError, and print it in qerror_print().
Store it in QemuOpt, for use by qemu_opts_foreach(). This makes
error_report() do the right thing when it runs within
qemu_opts_foreach().
We may still have to store it in other data structures holding user
input for better error messages. Left for another day.
Diffstat (limited to 'qemu-option.c')
-rw-r--r-- | qemu-option.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/qemu-option.c b/qemu-option.c index de40bff..ab488e4 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -27,6 +27,7 @@ #include <string.h> #include "qemu-common.h" +#include "qemu-error.h" #include "qemu-option.h" /* @@ -483,6 +484,7 @@ struct QemuOpt { struct QemuOpts { char *id; QemuOptsList *list; + Location loc; QTAILQ_HEAD(QemuOptHead, QemuOpt) head; QTAILQ_ENTRY(QemuOpts) next; }; @@ -653,6 +655,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exist opts->id = qemu_strdup(id); } opts->list = list; + loc_save(&opts->loc); QTAILQ_INIT(&opts->head); QTAILQ_INSERT_TAIL(&list->head, opts, next); return opts; @@ -810,13 +813,17 @@ int qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc) int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, int abort_on_failure) { + Location loc; QemuOpts *opts; int rc = 0; + loc_push_none(&loc); QTAILQ_FOREACH(opts, &list->head, next) { + loc_restore(&opts->loc); rc |= func(opts, opaque); if (abort_on_failure && rc != 0) break; } + loc_pop(&loc); return rc; } |