block: Set BDRV_O_ALLOW_RDWR and snapshot_options before storing the flags
If an image is opened with snapshot=on, its flags are modified by bdrv_backing_options() and then bs->open_flags is updated accordingly. This last step is unnecessary if we calculate the new flags before setting bs->open_flags. Soon we'll introduce the "read-only" option, and then we'll need to be able to modify its value in the QDict when snapshot=on. This is more cumbersome if bs->options is already set. This patch simplifies that. Other than that, there are no semantic changes. Although it might seem that bs->options can have a different value now because it is stored after calling bdrv_backing_options(), this call doesn't actually modify them in this scenario. The code that sets BDRV_O_ALLOW_RDWR is also moved for the same reason. Signed-off-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
38b5e4c3dc
commit
14499ea541
23
block.c
23
block.c
@ -1675,6 +1675,17 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & BDRV_O_RDWR) {
|
||||||
|
flags |= BDRV_O_ALLOW_RDWR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & BDRV_O_SNAPSHOT) {
|
||||||
|
snapshot_options = qdict_new();
|
||||||
|
bdrv_temp_snapshot_options(&snapshot_flags, snapshot_options,
|
||||||
|
flags, options);
|
||||||
|
bdrv_backing_options(&flags, options, flags, options);
|
||||||
|
}
|
||||||
|
|
||||||
bs->open_flags = flags;
|
bs->open_flags = flags;
|
||||||
bs->options = options;
|
bs->options = options;
|
||||||
options = qdict_clone_shallow(options);
|
options = qdict_clone_shallow(options);
|
||||||
@ -1699,18 +1710,6 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
|||||||
|
|
||||||
/* Open image file without format layer */
|
/* Open image file without format layer */
|
||||||
if ((flags & BDRV_O_PROTOCOL) == 0) {
|
if ((flags & BDRV_O_PROTOCOL) == 0) {
|
||||||
if (flags & BDRV_O_RDWR) {
|
|
||||||
flags |= BDRV_O_ALLOW_RDWR;
|
|
||||||
}
|
|
||||||
if (flags & BDRV_O_SNAPSHOT) {
|
|
||||||
snapshot_options = qdict_new();
|
|
||||||
bdrv_temp_snapshot_options(&snapshot_flags, snapshot_options,
|
|
||||||
flags, options);
|
|
||||||
bdrv_backing_options(&flags, options, flags, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
bs->open_flags = flags;
|
|
||||||
|
|
||||||
file = bdrv_open_child(filename, options, "file", bs,
|
file = bdrv_open_child(filename, options, "file", bs,
|
||||||
&child_file, true, &local_err);
|
&child_file, true, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user