blkdebug: Simplify passing of Error through qemu_opts_foreach()
Cc: Kevin Wolf <kwolf@redhat.com> Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
28d0de7a4f
commit
8809cfc38e
@ -216,7 +216,6 @@ static int get_event_by_name(const char *name, BlkDebugEvent *event)
|
|||||||
struct add_rule_data {
|
struct add_rule_data {
|
||||||
BDRVBlkdebugState *s;
|
BDRVBlkdebugState *s;
|
||||||
int action;
|
int action;
|
||||||
Error **errp;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
|
static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
|
||||||
@ -230,10 +229,10 @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
|
|||||||
/* Find the right event for the rule */
|
/* Find the right event for the rule */
|
||||||
event_name = qemu_opt_get(opts, "event");
|
event_name = qemu_opt_get(opts, "event");
|
||||||
if (!event_name) {
|
if (!event_name) {
|
||||||
error_setg(d->errp, "Missing event name for rule");
|
error_setg(errp, "Missing event name for rule");
|
||||||
return -1;
|
return -1;
|
||||||
} else if (get_event_by_name(event_name, &event) < 0) {
|
} else if (get_event_by_name(event_name, &event) < 0) {
|
||||||
error_setg(d->errp, "Invalid event name \"%s\"", event_name);
|
error_setg(errp, "Invalid event name \"%s\"", event_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,8 +318,7 @@ static int read_config(BDRVBlkdebugState *s, const char *filename,
|
|||||||
|
|
||||||
d.s = s;
|
d.s = s;
|
||||||
d.action = ACTION_INJECT_ERROR;
|
d.action = ACTION_INJECT_ERROR;
|
||||||
d.errp = &local_err;
|
qemu_opts_foreach(&inject_error_opts, add_rule, &d, &local_err);
|
||||||
qemu_opts_foreach(&inject_error_opts, add_rule, &d, NULL);
|
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@ -328,7 +326,7 @@ static int read_config(BDRVBlkdebugState *s, const char *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
d.action = ACTION_SET_STATE;
|
d.action = ACTION_SET_STATE;
|
||||||
qemu_opts_foreach(&set_state_opts, add_rule, &d, NULL);
|
qemu_opts_foreach(&set_state_opts, add_rule, &d, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user