[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/11] blkdebug: show an error for invalid event name
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 01/11] blkdebug: show an error for invalid event names |
Date: |
Fri, 26 Sep 2014 20:58:47 +0200 |
From: Stefan Hajnoczi <address@hidden>
It is easy to typo a blkdebug configuration and waste a lot of time
figuring out why no rules are matching.
Push the Error** down into add_rule() so we can report an error when the
event name is invalid.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Gonglei <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/blkdebug.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index ced0b60..f8fbb0f 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -214,6 +214,7 @@ static int get_event_by_name(const char *name,
BlkDebugEvent *event)
struct add_rule_data {
BDRVBlkdebugState *s;
int action;
+ Error **errp;
};
static int add_rule(QemuOpts *opts, void *opaque)
@@ -226,7 +227,11 @@ static int add_rule(QemuOpts *opts, void *opaque)
/* Find the right event for the rule */
event_name = qemu_opt_get(opts, "event");
- if (!event_name || get_event_by_name(event_name, &event) < 0) {
+ if (!event_name) {
+ error_setg(d->errp, "Missing event name for rule");
+ return -1;
+ } else if (get_event_by_name(event_name, &event) < 0) {
+ error_setg(d->errp, "Invalid event name \"%s\"", event_name);
return -1;
}
@@ -312,10 +317,21 @@ static int read_config(BDRVBlkdebugState *s, const char
*filename,
d.s = s;
d.action = ACTION_INJECT_ERROR;
- qemu_opts_foreach(&inject_error_opts, add_rule, &d, 0);
+ d.errp = &local_err;
+ qemu_opts_foreach(&inject_error_opts, add_rule, &d, 1);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ ret = -EINVAL;
+ goto fail;
+ }
d.action = ACTION_SET_STATE;
- qemu_opts_foreach(&set_state_opts, add_rule, &d, 0);
+ qemu_opts_foreach(&set_state_opts, add_rule, &d, 1);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ ret = -EINVAL;
+ goto fail;
+ }
ret = 0;
fail:
--
1.8.3.1
- [Qemu-devel] [PULL 00/11] Block patches, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 01/11] blkdebug: show an error for invalid event names,
Kevin Wolf <=
- [Qemu-devel] [PULL 02/11] blockdev: Disentangle BlockDriverState and DriveInfo creation, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 05/11] block: Improve message for device name clashing with node name, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 06/11] block: Specify -drive legacy option aliases in array, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 04/11] qemu-nbd: Destroy the BlockDriverState properly, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 03/11] block: Keep DriveInfo alive until BlockDriverState dies, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 07/11] block: Catch simultaneous usage of options and their aliases, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 09/11] vpc: fix beX_to_cpu() and cpu_to_beX() confusion, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 10/11] block: Validate node-name, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 11/11] qemu-iotests: Fail test if explicit test case number is unknown, Kevin Wolf, 2014/09/26
- [Qemu-devel] [PULL 08/11] docs: add blkdebug block driver documentation, Kevin Wolf, 2014/09/26