aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2012-12-06 14:32:56 +0100
committerKevin Wolf <kwolf@redhat.com>2012-12-12 12:33:48 +0100
commit9e35542b0fc3871caac15ccd57548b99df2c94b7 (patch)
tree5a49d2084f33488f48a1b4970b07647163f8adb3 /block
parent312a2ba0eb8ab19646517aeaa785475d3fbcfd51 (diff)
blkdebug: Factor out remove_rule()
The cleanup work to remove a rule depends on the type of the rule. It's easy for the existing rules as there is no data that must be cleaned up and is specific to a type yet, but the next patch will change this. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/blkdebug.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c
index c9041ec3d2..859792b647 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -234,6 +234,18 @@ static int add_rule(QemuOpts *opts, void *opaque)
return 0;
}
+static void remove_rule(BlkdebugRule *rule)
+{
+ switch (rule->action) {
+ case ACTION_INJECT_ERROR:
+ case ACTION_SET_STATE:
+ break;
+ }
+
+ QLIST_REMOVE(rule, next);
+ g_free(rule);
+}
+
static int read_config(BDRVBlkdebugState *s, const char *filename)
{
FILE *f;
@@ -402,8 +414,7 @@ static void blkdebug_close(BlockDriverState *bs)
for (i = 0; i < BLKDBG_EVENT_MAX; i++) {
QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) {
- QLIST_REMOVE(rule, next);
- g_free(rule);
+ remove_rule(rule);
}
}
}