static QemuOptsList set_state_opts = {
.name = "set-state",
- .head = QTAILQ_HEAD_INITIALIZER(inject_error_opts.head),
+ .head = QTAILQ_HEAD_INITIALIZER(set_state_opts.head),
.desc = {
{
.name = "event",
}
/* Set attributes common for all actions */
- rule = qemu_mallocz(sizeof(*rule));
+ rule = g_malloc0(sizeof(*rule));
*rule = (struct BlkdebugRule) {
.event = event,
.action = d->action,
ret = 0;
fail:
+ qemu_opts_reset(&inject_error_opts);
+ qemu_opts_reset(&set_state_opts);
fclose(f);
return ret;
}
return -EINVAL;
}
- config = strdup(filename);
+ config = g_strdup(filename);
config[c - filename] = '\0';
ret = read_config(s, config);
- free(config);
+ g_free(config);
if (ret < 0) {
return ret;
}
filename = c + 1;
+ /* Set initial state */
+ s->vars.state = 1;
+
/* Open the backing file */
ret = bdrv_file_open(&bs->file, filename, flags);
if (ret < 0) {
for (i = 0; i < BLKDBG_EVENT_MAX; i++) {
QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) {
QLIST_REMOVE(rule, next);
- qemu_free(rule);
+ g_free(rule);
}
}
}
-static void blkdebug_flush(BlockDriverState *bs)
-{
- bdrv_flush(bs->file);
-}
-
-static BlockDriverAIOCB *blkdebug_aio_flush(BlockDriverState *bs,
- BlockDriverCompletionFunc *cb, void *opaque)
-{
- return bdrv_aio_flush(bs->file, cb, opaque);
-}
-
static void process_rule(BlockDriverState *bs, struct BlkdebugRule *rule,
BlkdebugVars *old_vars)
{
struct BlkdebugRule *rule;
BlkdebugVars old_vars = s->vars;
- if (event < 0 || event >= BLKDBG_EVENT_MAX) {
- return;
- }
+ assert((int)event >= 0 && event < BLKDBG_EVENT_MAX);
QLIST_FOREACH(rule, &s->rules[event], next) {
process_rule(bs, rule, &old_vars);
.bdrv_file_open = blkdebug_open,
.bdrv_close = blkdebug_close,
- .bdrv_flush = blkdebug_flush,
.bdrv_aio_readv = blkdebug_aio_readv,
.bdrv_aio_writev = blkdebug_aio_writev,
- .bdrv_aio_flush = blkdebug_aio_flush,
.bdrv_debug_event = blkdebug_debug_event,
};