block: Move bdrv_fill_options() call to bdrv_open()
bs->options now contains the modified version of the options. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
f54120ff1a
commit
462f5bcf69
25
block.c
25
block.c
@ -1009,14 +1009,19 @@ free_and_fail:
|
|||||||
* Fills in default options for opening images and converts the legacy
|
* Fills in default options for opening images and converts the legacy
|
||||||
* filename/flags pair to option QDict entries.
|
* filename/flags pair to option QDict entries.
|
||||||
*/
|
*/
|
||||||
static int bdrv_fill_options(QDict **options, const char *filename,
|
static int bdrv_fill_options(QDict **options, const char *filename, int flags,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
const char *drvname;
|
const char *drvname;
|
||||||
|
bool protocol = flags & BDRV_O_PROTOCOL;
|
||||||
bool parse_filename = false;
|
bool parse_filename = false;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
BlockDriver *drv;
|
BlockDriver *drv;
|
||||||
|
|
||||||
|
if (!protocol) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Fetch the file name from the options QDict if necessary */
|
/* Fetch the file name from the options QDict if necessary */
|
||||||
if (filename) {
|
if (filename) {
|
||||||
if (!qdict_haskey(*options, "filename")) {
|
if (!qdict_haskey(*options, "filename")) {
|
||||||
@ -1081,20 +1086,15 @@ static int bdrv_fill_options(QDict **options, const char *filename,
|
|||||||
* returns. Then, the caller is responsible for freeing it. If it intends to
|
* returns. Then, the caller is responsible for freeing it. If it intends to
|
||||||
* reuse the QDict, QINCREF() should be called beforehand.
|
* reuse the QDict, QINCREF() should be called beforehand.
|
||||||
*/
|
*/
|
||||||
static int bdrv_file_open(BlockDriverState *bs, const char *filename,
|
static int bdrv_file_open(BlockDriverState *bs, QDict **options, int flags,
|
||||||
QDict **options, int flags, Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
BlockDriver *drv;
|
BlockDriver *drv;
|
||||||
|
const char *filename;
|
||||||
const char *drvname;
|
const char *drvname;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = bdrv_fill_options(options, filename, &local_err);
|
|
||||||
if (local_err) {
|
|
||||||
error_propagate(errp, local_err);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
filename = qdict_get_try_str(*options, "filename");
|
filename = qdict_get_try_str(*options, "filename");
|
||||||
drvname = qdict_get_str(*options, "driver");
|
drvname = qdict_get_str(*options, "driver");
|
||||||
|
|
||||||
@ -1436,12 +1436,17 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
|
|||||||
filename = NULL;
|
filename = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = bdrv_fill_options(&options, filename, flags, &local_err);
|
||||||
|
if (local_err) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
bs->options = options;
|
bs->options = options;
|
||||||
options = qdict_clone_shallow(options);
|
options = qdict_clone_shallow(options);
|
||||||
|
|
||||||
if (flags & BDRV_O_PROTOCOL) {
|
if (flags & BDRV_O_PROTOCOL) {
|
||||||
assert(!drv);
|
assert(!drv);
|
||||||
ret = bdrv_file_open(bs, filename, &options, flags & ~BDRV_O_PROTOCOL,
|
ret = bdrv_file_open(bs, &options, flags & ~BDRV_O_PROTOCOL,
|
||||||
&local_err);
|
&local_err);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
drv = bs->drv;
|
drv = bs->drv;
|
||||||
|
Loading…
Reference in New Issue
Block a user