[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/33] block: Set BDRV_O_ALLOW_RDWR and snapshot_opti
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 05/33] block: Set BDRV_O_ALLOW_RDWR and snapshot_options before storing the flags |
Date: |
Thu, 22 Sep 2016 18:29:06 +0200 |
From: Alberto Garcia <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/block.c b/block.c
index d448520..324dbe7 100644
--- a/block.c
+++ b/block.c
@@ -1675,6 +1675,17 @@ static BlockDriverState *bdrv_open_inherit(const char
*filename,
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->options = options;
options = qdict_clone_shallow(options);
@@ -1699,18 +1710,6 @@ static BlockDriverState *bdrv_open_inherit(const char
*filename,
/* Open image file without format layer */
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,
&child_file, true, &local_err);
if (local_err) {
--
1.8.3.1
- [Qemu-devel] [PULL 00/33] Block layer patches, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 01/33] qcow2: fix encryption during cow of sectors, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 02/33] hmp: Remove dead code in hmp_qemu_io(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 04/33] block: Remove bdrv_is_snapshot, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 05/33] block: Set BDRV_O_ALLOW_RDWR and snapshot_options before storing the flags,
Kevin Wolf <=
- [Qemu-devel] [PULL 03/33] tests: allow to specify list of formats to test for check-block.sh, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 06/33] block: Update bs->open_flags earlier in bdrv_open_common(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 08/33] block: Don't queue the same BDS twice in bdrv_reopen_queue_child(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 10/33] block: rename "read-only" to BDRV_OPT_READ_ONLY, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 07/33] block: Add "read-only" to the options QDict, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 09/33] commit: Add 'base' to the reopen queue before 'overlay_bs', Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 11/33] block: Fix 'since' for compressed Drive/BlockdevBackup, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 13/33] qdev-monitor: Factor out find_device_state(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 12/33] block: Add blk_by_dev(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 14/33] qdev-monitor: Add blk_by_qdev_id(), Kevin Wolf, 2016/09/22