aboutsummaryrefslogtreecommitdiff
path: root/block/blkdebug.c
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2012-10-11 05:19:58 -0300
committerMarcelo Tosatti <mtosatti@redhat.com>2012-10-11 05:19:58 -0300
commitcaaef9b163a4696f686d91f9f2767e9c6ab446d6 (patch)
tree33acd5bd1bc8c34ffe36af2a7ab160018d80250f /block/blkdebug.c
parent487a26af87644923656e98a40f7801ec2f459b14 (diff)
parentc9159fe9aa9abe24115ea4d16127179e9cb07e22 (diff)
Merge commit 'c9159fe9aa9abe24115ea4d16127179e9cb07e22' into upstream-merge
* commit 'c9159fe9aa9abe24115ea4d16127179e9cb07e22': (83 commits) Remove libhw rtc: implement century byte rtc: map CMOS index 0x37 to 0x32 on read and writes rtc: fix overflow in mktimegm qtest: implement QTEST_STOP qemu-barrier: Fix compiler version check for future gcc versions doc: update HACKING wrt strncpy/pstrcpy hw/r2d: add comment: this strncpy use is ok qcow2: mark this file's sole strncpy use as justified acpi: remove strzcpy (strncpy-identical) function; just use strncpy libcacard/vcard_emul_nss: use pstrcpy in place of strncpy qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name vscsi: avoid unwarranted strncpy virtio-9p: avoid unwarranted uses of strncpy bt: replace fragile snprintf use and unwarranted strncpy ui/vnc: simplify and avoid strncpy linux-user: remove two unchecked uses of strdup ppc: avoid buffer overrun: use pstrcpy, not strncpy os-posix: avoid buffer overrun lm32: avoid buffer overrun ... Conflicts: hw/Makefile.objs Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'block/blkdebug.c')
-rw-r--r--block/blkdebug.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 59dcea065..1206d5256 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)