[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/19] blkdebug: process all set_state rules in the
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 17/19] blkdebug: process all set_state rules in the old state |
Date: |
Fri, 28 Sep 2012 17:23:00 +0200 |
Currently it is impossible to write a blkdebug script that ping-pongs
between two states, because the second set-state rule will use the
state that is set in the first. If you have
[set-state]
event = "..."
state = "1"
new_state = "2"
[set-state]
event = "..."
state = "2"
new_state = "1"
for example the state will remain locked at 1. This can be fixed
by first processing all rules, and then setting the state.
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/blkdebug.c | 12 +++++++-----
1 file modificato, 7 inserzioni(+), 5 rimozioni(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 59dcea0..1206d52 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -28,6 +28,7 @@
typedef struct BDRVBlkdebugState {
int state;
+ int new_state;
QLIST_HEAD(, BlkdebugRule) rules[BLKDBG_EVENT_MAX];
QSIMPLEQ_HEAD(, BlkdebugRule) active_rules;
} BDRVBlkdebugState;
@@ -403,12 +404,12 @@ static void blkdebug_close(BlockDriverState *bs)
}
static bool process_rule(BlockDriverState *bs, struct BlkdebugRule *rule,
- int old_state, bool injected)
+ bool injected)
{
BDRVBlkdebugState *s = bs->opaque;
/* Only process rules for the current state */
- if (rule->state && rule->state != old_state) {
+ if (rule->state && rule->state != s->state) {
return injected;
}
@@ -423,7 +424,7 @@ static bool process_rule(BlockDriverState *bs, struct
BlkdebugRule *rule,
break;
case ACTION_SET_STATE:
- s->state = rule->options.set_state.new_state;
+ s->new_state = rule->options.set_state.new_state;
break;
}
return injected;
@@ -433,15 +434,16 @@ static void blkdebug_debug_event(BlockDriverState *bs,
BlkDebugEvent event)
{
BDRVBlkdebugState *s = bs->opaque;
struct BlkdebugRule *rule;
- int old_state = s->state;
bool injected;
assert((int)event >= 0 && event < BLKDBG_EVENT_MAX);
injected = false;
+ s->new_state = s->state;
QLIST_FOREACH(rule, &s->rules[event], next) {
- injected = process_rule(bs, rule, old_state, injected);
+ injected = process_rule(bs, rule, injected);
}
+ s->state = s->new_state;
}
static int64_t blkdebug_getlength(BlockDriverState *bs)
--
1.7.12
- [Qemu-devel] [PATCH 04/19] block: move job APIs to separate files, (continued)
- [Qemu-devel] [PATCH 04/19] block: move job APIs to separate files, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 06/19] qmp: add 'busy' member to BlockJobInfo, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 05/19] block: add block_job_query, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 09/19] qemu-iotests: add test for pausing a streaming operation, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 08/19] qmp: add block-job-pause and block-job-resume, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 07/19] block: add support for job pause/resume, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 10/19] block: rename block_job_complete to block_job_completed, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 11/19] iostatus: rename BlockErrorAction, BlockQMPEventAction, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 15/19] block: introduce block job error, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 19/19] qemu-iotests: add tests for streaming error handling, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 17/19] blkdebug: process all set_state rules in the old state,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 18/19] qemu-iotests: map underscore to dash in QMP argument names, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 14/19] iostatus: reorganize io error code, Paolo Bonzini, 2012/09/28
- Re: [Qemu-devel] [PULL for Kevin 00/19] Block job improvements part 1, Eric Blake, 2012/09/28
- [Qemu-devel] [PATCH 13/19] iostatus: change is_read to a bool, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 16/19] stream: add on-error argument, Paolo Bonzini, 2012/09/28
- [Qemu-devel] [PATCH 12/19] iostatus: move BlockdevOnError declaration to QAPI, Paolo Bonzini, 2012/09/28
- Re: [Qemu-devel] [PULL for Kevin 00/19] Block job improvements part 1, Kevin Wolf, 2012/09/28