diff options
author | Kevin Wolf <kwolf@redhat.com> | 2013-03-15 18:47:22 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-03-22 17:51:32 +0100 |
commit | 6963a30d82413bea36c7545137b090b284cc2b18 (patch) | |
tree | f4258be2af81298342b01f359790ea10ba5f856c /block.c | |
parent | f53a1febcd9d887149ac1429880a3f2fdb2c117f (diff) | |
download | qemu-6963a30d82413bea36c7545137b090b284cc2b18.tar.gz qemu-6963a30d82413bea36c7545137b090b284cc2b18.tar.bz2 qemu-6963a30d82413bea36c7545137b090b284cc2b18.zip |
block: Introduce .bdrv_parse_filename callback
If a driver needs structured data and not just a string, it can provide
a .bdrv_parse_filename callback now that parses the command line string
into separate options. Keeping this separate from .bdrv_open_filename
ensures that the preferred way of directly specifying the options always
works as well if parsing the string works.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -770,6 +770,17 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename, bs->options = options; options = qdict_clone_shallow(options); + if (drv->bdrv_parse_filename) { + Error *local_err = NULL; + drv->bdrv_parse_filename(filename, options, &local_err); + if (error_is_set(&local_err)) { + qerror_report_err(local_err); + error_free(local_err); + ret = -EINVAL; + goto fail; + } + } + ret = bdrv_open_common(bs, NULL, filename, options, flags, drv); if (ret < 0) { goto fail; |