[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/33] block: Don't queue the same BDS twice in bdrv_
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 08/33] block: Don't queue the same BDS twice in bdrv_reopen_queue_child() |
Date: |
Thu, 22 Sep 2016 18:29:09 +0200 |
From: Alberto Garcia <address@hidden>
bdrv_reopen_queue_child() assumes that a BlockDriverState is never
added twice to BlockReopenQueue.
That's however not the case: commit_start() adds 'base' (and its
children) to a new reopen queue, and then 'overlay_bs' (and its
children, which include 'base') to the same queue. The effect of this
is that the first set of options is ignored and overriden by the
second.
We fixed this by swapping the order in which both BDSs were added to
the queue in 3db2bd5508c86a1605258bc77c9672d93b5c350e. This patch
checks if a BDS is already in the reopen queue and keeps its options.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index b724ada..493ecf3 100644
--- a/block.c
+++ b/block.c
@@ -1925,6 +1925,13 @@ static BlockReopenQueue
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
options = qdict_new();
}
+ /* Check if this BlockDriverState is already in the queue */
+ QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) {
+ if (bs == bs_entry->state.bs) {
+ break;
+ }
+ }
+
/*
* Precedence of options:
* 1. Explicitly passed in options (highest)
@@ -1945,7 +1952,11 @@ static BlockReopenQueue
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
}
/* Old explicitly set values (don't overwrite by inherited value) */
- old_options = qdict_clone_shallow(bs->explicit_options);
+ if (bs_entry) {
+ old_options = qdict_clone_shallow(bs_entry->state.explicit_options);
+ } else {
+ old_options = qdict_clone_shallow(bs->explicit_options);
+ }
bdrv_join_options(bs, options, old_options);
QDECREF(old_options);
@@ -1984,8 +1995,13 @@ static BlockReopenQueue
*bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
child->role, options, flags);
}
- bs_entry = g_new0(BlockReopenQueueEntry, 1);
- QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry);
+ if (!bs_entry) {
+ bs_entry = g_new0(BlockReopenQueueEntry, 1);
+ QSIMPLEQ_INSERT_TAIL(bs_queue, bs_entry, entry);
+ } else {
+ QDECREF(bs_entry->state.options);
+ QDECREF(bs_entry->state.explicit_options);
+ }
bs_entry->state.bs = bs;
bs_entry->state.options = options;
--
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, 2016/09/22
- [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 <=
- [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
- [Qemu-devel] [PULL 16/33] block: Accept device model name for x-blockdev-insert-medium, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 15/33] block: Accept device model name for blockdev-open/close-tray, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 17/33] block: Accept device model name for x-blockdev-remove-medium, Kevin Wolf, 2016/09/22