summaryrefslogtreecommitdiffstats
path: root/block.c
diff options
context:
space:
mode:
authorPeter Maydell2016-06-16 16:22:56 +0200
committerPeter Maydell2016-06-16 16:22:56 +0200
commitdc278c58fa02e5fb796dbacf02c8dde32f697015 (patch)
tree0f9d28aba34318ee06c89a7ee1f4d54a8cc9f1ed /block.c
parentMerge remote-tracking branch 'remotes/amit-migration/tags/migration-for-2.7-4... (diff)
parentMerge remote-tracking branch 'mreitz/tags/pull-block-for-kevin-2016-06-16' in... (diff)
downloadqemu-dc278c58fa02e5fb796dbacf02c8dde32f697015.tar.gz
qemu-dc278c58fa02e5fb796dbacf02c8dde32f697015.tar.xz
qemu-dc278c58fa02e5fb796dbacf02c8dde32f697015.zip
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches # gpg: Signature made Thu 16 Jun 2016 15:01:27 BST # gpg: using RSA key 0x7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (39 commits) hbitmap: add 'pos < size' asserts iotests: Add test for oVirt-like storage migration iotests: Add test for post-mirror backing chains block/null: Implement bdrv_refresh_filename() block/mirror: Fix target backing BDS block: Allow replacement of a BDS by its overlay rbd:change error_setg() to error_setg_errno() iotests: 095: Clean up QEMU before showing image info block: Create the commit block job before reopening any image block: Prevent sleeping jobs from resuming if they have been paused block: use the block job list in qmp_query_block_jobs() block: use the block job list in bdrv_drain_all() block: Fix snapshot=on with aio=native block: Remove bs->zero_beyond_eof qcow2: Let vmstate call qcow2_co_preadv/pwrite directly block: Make bdrv_load/save_vmstate coroutine_fns block: Allow .bdrv_load/save_vmstate() to return 0/-errno block: Make .bdrv_load_vmstate() vectored block: Introduce bdrv_preadv() doc: Fix mailing list address in tests/qemu-iotests/README ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block.c')
-rw-r--r--block.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/block.c b/block.c
index f54bc25e8a..b331eb9d38 100644
--- a/block.c
+++ b/block.c
@@ -684,6 +684,10 @@ static void bdrv_temp_snapshot_options(int *child_flags, QDict *child_options,
/* For temporary files, unconditional cache=unsafe is fine */
qdict_set_default_str(child_options, BDRV_OPT_CACHE_DIRECT, "off");
qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on");
+
+ /* aio=native doesn't work for cache.direct=off, so disable it for the
+ * temporary snapshot */
+ *child_flags &= ~BDRV_O_NATIVE_AIO;
}
/*
@@ -937,8 +941,7 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
goto fail_opts;
}
- bs->request_alignment = 512;
- bs->zero_beyond_eof = true;
+ bs->request_alignment = drv->bdrv_co_preadv ? 1 : 512;
bs->read_only = !(bs->open_flags & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
@@ -2192,7 +2195,6 @@ static void bdrv_close(BlockDriverState *bs)
bs->encrypted = 0;
bs->valid_key = 0;
bs->sg = 0;
- bs->zero_beyond_eof = false;
QDECREF(bs->options);
QDECREF(bs->explicit_options);
bs->options = NULL;
@@ -2224,9 +2226,23 @@ void bdrv_close_all(void)
static void change_parent_backing_link(BlockDriverState *from,
BlockDriverState *to)
{
- BdrvChild *c, *next;
+ BdrvChild *c, *next, *to_c;
QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
+ if (c->role == &child_backing) {
+ /* @from is generally not allowed to be a backing file, except for
+ * when @to is the overlay. In that case, @from may not be replaced
+ * by @to as @to's backing node. */
+ QLIST_FOREACH(to_c, &to->children, next) {
+ if (to_c == c) {
+ break;
+ }
+ }
+ if (to_c) {
+ continue;
+ }
+ }
+
assert(c->role != &child_backing);
bdrv_ref(to);
bdrv_replace_child(c, to);
@@ -2275,14 +2291,6 @@ void bdrv_replace_in_backing_chain(BlockDriverState *old, BlockDriverState *new)
change_parent_backing_link(old, new);
- /* Change backing files if a previously independent node is added to the
- * chain. For active commit, we replace top by its own (indirect) backing
- * file and don't do anything here so we don't build a loop. */
- if (new->backing == NULL && !bdrv_chain_contains(backing_bs(old), new)) {
- bdrv_set_backing_hd(new, backing_bs(old));
- bdrv_set_backing_hd(old, NULL);
- }
-
bdrv_unref(old);
}