Skip to content

Commit

Permalink
blkdebug: Factor out remove_rule()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kevmw committed Dec 12, 2012
1 parent 312a2ba commit 9e35542
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions block/blkdebug.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 9e35542

Please sign in to comment.