From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PULL 01/11] blkdebug: show an error for invalid event names
Date: Fri, 26 Sep 2014 20:58:47 +0200 [thread overview]
Message-ID: <1411757937-9087-2-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1411757937-9087-1-git-send-email-kwolf@redhat.com>
From: Stefan Hajnoczi <stefanha@redhat.com>
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 <stefanha@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
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
next prev parent reply other threads:[~2014-09-26 18:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 18:58 [Qemu-devel] [PULL 00/11] Block patches Kevin Wolf
2014-09-26 18:58 ` Kevin Wolf [this message]
2014-09-26 18:58 ` [Qemu-devel] [PULL 02/11] blockdev: Disentangle BlockDriverState and DriveInfo creation Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 03/11] block: Keep DriveInfo alive until BlockDriverState dies Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 04/11] qemu-nbd: Destroy the BlockDriverState properly Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 05/11] block: Improve message for device name clashing with node name Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 06/11] block: Specify -drive legacy option aliases in array Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 07/11] block: Catch simultaneous usage of options and their aliases Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 08/11] docs: add blkdebug block driver documentation Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 09/11] vpc: fix beX_to_cpu() and cpu_to_beX() confusion Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 10/11] block: Validate node-name Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 11/11] qemu-iotests: Fail test if explicit test case number is unknown Kevin Wolf
2014-09-29 13:03 ` [Qemu-devel] [PULL 00/11] Block patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411757937-9087-2-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).