提交 f7d9fd8c 编写于 作者: M Max Reitz 提交者: Kevin Wolf

block: Remove bdrv_open_image()'s force_raw option

This option is now unnecessary since specifying BDRV_O_PROTOCOL as flag
will do exactly the same.
Signed-off-by: NMax Reitz <mreitz@redhat.com>
Reviewed-by: NBenoit Canet <benoit@irqsave.net>
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 5acd9d81
...@@ -1109,10 +1109,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) ...@@ -1109,10 +1109,6 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
* Opens a disk image whose options are given as BlockdevRef in another block * Opens a disk image whose options are given as BlockdevRef in another block
* device's options. * device's options.
* *
* If force_raw is true, bdrv_file_open() will be used, thereby preventing any
* image format auto-detection. If it is false and a filename is given,
* bdrv_open() will be used for auto-detection.
*
* If allow_none is true, no image will be opened if filename is false and no * If allow_none is true, no image will be opened if filename is false and no
* BlockdevRef is given. *pbs will remain unchanged and 0 will be returned. * BlockdevRef is given. *pbs will remain unchanged and 0 will be returned.
* *
...@@ -1127,7 +1123,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp) ...@@ -1127,7 +1123,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
*/ */
int bdrv_open_image(BlockDriverState **pbs, const char *filename, int bdrv_open_image(BlockDriverState **pbs, const char *filename,
QDict *options, const char *bdref_key, int flags, QDict *options, const char *bdref_key, int flags,
bool force_raw, bool allow_none, Error **errp) bool allow_none, Error **errp)
{ {
QDict *image_options; QDict *image_options;
int ret; int ret;
...@@ -1153,22 +1149,7 @@ int bdrv_open_image(BlockDriverState **pbs, const char *filename, ...@@ -1153,22 +1149,7 @@ int bdrv_open_image(BlockDriverState **pbs, const char *filename,
goto done; goto done;
} }
if (filename && !force_raw) { ret = bdrv_open(pbs, filename, reference, image_options, flags, NULL, errp);
/* If a filename is given and the block driver should be detected
automatically (instead of using none), use bdrv_open() in order to do
that auto-detection. */
if (reference) {
error_setg(errp, "Cannot reference an existing block device while "
"giving a filename");
ret = -EINVAL;
goto done;
}
ret = bdrv_open(pbs, filename, NULL, image_options, flags, NULL, errp);
} else {
ret = bdrv_open(pbs, filename, reference, image_options,
flags | BDRV_O_PROTOCOL, NULL, errp);
}
done: done:
qdict_del(options, bdref_key); qdict_del(options, bdref_key);
...@@ -1330,8 +1311,8 @@ int bdrv_open(BlockDriverState **pbs, const char *filename, ...@@ -1330,8 +1311,8 @@ int bdrv_open(BlockDriverState **pbs, const char *filename,
assert(file == NULL); assert(file == NULL);
ret = bdrv_open_image(&file, filename, options, "file", ret = bdrv_open_image(&file, filename, options, "file",
bdrv_open_flags(bs, flags | BDRV_O_UNMAP), true, true, bdrv_open_flags(bs, flags | BDRV_O_UNMAP) |
&local_err); BDRV_O_PROTOCOL, true, &local_err);
if (ret < 0) { if (ret < 0) {
goto fail; goto fail;
} }
......
...@@ -412,7 +412,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -412,7 +412,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
/* Open the backing file */ /* Open the backing file */
assert(bs->file == NULL); assert(bs->file == NULL);
ret = bdrv_open_image(&bs->file, qemu_opt_get(opts, "x-image"), options, "image", ret = bdrv_open_image(&bs->file, qemu_opt_get(opts, "x-image"), options, "image",
flags, true, false, &local_err); flags | BDRV_O_PROTOCOL, false, &local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
goto out; goto out;
......
...@@ -137,7 +137,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -137,7 +137,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
/* Open the raw file */ /* Open the raw file */
assert(bs->file == NULL); assert(bs->file == NULL);
ret = bdrv_open_image(&bs->file, qemu_opt_get(opts, "x-raw"), options, ret = bdrv_open_image(&bs->file, qemu_opt_get(opts, "x-raw"), options,
"raw", flags, true, false, &local_err); "raw", flags | BDRV_O_PROTOCOL, false, &local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
goto fail; goto fail;
...@@ -146,7 +146,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -146,7 +146,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
/* Open the test file */ /* Open the test file */
assert(s->test_file == NULL); assert(s->test_file == NULL);
ret = bdrv_open_image(&s->test_file, qemu_opt_get(opts, "x-image"), options, ret = bdrv_open_image(&s->test_file, qemu_opt_get(opts, "x-image"), options,
"test", flags, false, false, &local_err); "test", flags, false, &local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
s->test_file = NULL; s->test_file = NULL;
......
...@@ -188,7 +188,7 @@ int bdrv_parse_cache_flags(const char *mode, int *flags); ...@@ -188,7 +188,7 @@ int bdrv_parse_cache_flags(const char *mode, int *flags);
int bdrv_parse_discard_flags(const char *mode, int *flags); int bdrv_parse_discard_flags(const char *mode, int *flags);
int bdrv_open_image(BlockDriverState **pbs, const char *filename, int bdrv_open_image(BlockDriverState **pbs, const char *filename,
QDict *options, const char *bdref_key, int flags, QDict *options, const char *bdref_key, int flags,
bool force_raw, bool allow_none, Error **errp); bool allow_none, Error **errp);
int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp); int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp);
int bdrv_open(BlockDriverState **pbs, const char *filename, int bdrv_open(BlockDriverState **pbs, const char *filename,
const char *reference, QDict *options, int flags, const char *reference, QDict *options, int flags,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册