aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2013-03-15 18:47:22 +0100
committerKevin Wolf <kwolf@redhat.com>2013-03-22 17:51:32 +0100
commit6963a30d82413bea36c7545137b090b284cc2b18 (patch)
treef4258be2af81298342b01f359790ea10ba5f856c /block.c
parentf53a1febcd9d887149ac1429880a3f2fdb2c117f (diff)
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.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/block.c b/block.c
index ef1ae940c9..8a95a28c05 100644
--- a/block.c
+++ b/block.c
@@ -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;