block/blkdebug: Store config filename
Store the configuration file's filename so it can later be used in bdrv_refresh_filename() without having to directly access the options QDict which may contain a value of a non-string type. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
7ccc44fd7d
commit
036990d72b
@ -39,6 +39,9 @@ typedef struct BDRVBlkdebugState {
|
|||||||
int new_state;
|
int new_state;
|
||||||
int align;
|
int align;
|
||||||
|
|
||||||
|
/* For blkdebug_refresh_filename() */
|
||||||
|
char *config_file;
|
||||||
|
|
||||||
QLIST_HEAD(, BlkdebugRule) rules[BLKDBG__MAX];
|
QLIST_HEAD(, BlkdebugRule) rules[BLKDBG__MAX];
|
||||||
QSIMPLEQ_HEAD(, BlkdebugRule) active_rules;
|
QSIMPLEQ_HEAD(, BlkdebugRule) active_rules;
|
||||||
QLIST_HEAD(, BlkdebugSuspendedReq) suspended_reqs;
|
QLIST_HEAD(, BlkdebugSuspendedReq) suspended_reqs;
|
||||||
@ -351,7 +354,6 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
|
|||||||
BDRVBlkdebugState *s = bs->opaque;
|
BDRVBlkdebugState *s = bs->opaque;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
const char *config;
|
|
||||||
uint64_t align;
|
uint64_t align;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -364,8 +366,8 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read rules from config file or command line options */
|
/* Read rules from config file or command line options */
|
||||||
config = qemu_opt_get(opts, "config");
|
s->config_file = g_strdup(qemu_opt_get(opts, "config"));
|
||||||
ret = read_config(s, config, options, errp);
|
ret = read_config(s, s->config_file, options, errp);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -398,6 +400,9 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
|
|||||||
fail_unref:
|
fail_unref:
|
||||||
bdrv_unref_child(bs, bs->file);
|
bdrv_unref_child(bs, bs->file);
|
||||||
out:
|
out:
|
||||||
|
if (ret < 0) {
|
||||||
|
g_free(s->config_file);
|
||||||
|
}
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -515,6 +520,8 @@ static void blkdebug_close(BlockDriverState *bs)
|
|||||||
remove_rule(rule);
|
remove_rule(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(s->config_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void suspend_request(BlockDriverState *bs, BlkdebugRule *rule)
|
static void suspend_request(BlockDriverState *bs, BlkdebugRule *rule)
|
||||||
@ -679,6 +686,7 @@ static int blkdebug_truncate(BlockDriverState *bs, int64_t offset)
|
|||||||
|
|
||||||
static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
|
static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
{
|
{
|
||||||
|
BDRVBlkdebugState *s = bs->opaque;
|
||||||
QDict *opts;
|
QDict *opts;
|
||||||
const QDictEntry *e;
|
const QDictEntry *e;
|
||||||
bool force_json = false;
|
bool force_json = false;
|
||||||
@ -700,8 +708,7 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
|
|||||||
|
|
||||||
if (!force_json && bs->file->bs->exact_filename[0]) {
|
if (!force_json && bs->file->bs->exact_filename[0]) {
|
||||||
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||||
"blkdebug:%s:%s",
|
"blkdebug:%s:%s", s->config_file ?: "",
|
||||||
qdict_get_try_str(options, "config") ?: "",
|
|
||||||
bs->file->bs->exact_filename);
|
bs->file->bs->exact_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user