diff options
author | Kevin Wolf <kwolf@redhat.com> | 2015-06-10 13:33:17 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-06-12 17:04:59 +0200 |
commit | 6ee4ce1ee75a651c246d926c2302281b51981f6d (patch) | |
tree | d0949db11848e03524342ccc7f56db08dd11739f /linux-user/uname.h | |
parent | f3930ed0bb1945b59da8e591072b5c79606d0760 (diff) | |
download | hqemu-6ee4ce1ee75a651c246d926c2302281b51981f6d.zip hqemu-6ee4ce1ee75a651c246d926c2302281b51981f6d.tar.gz |
block: Drain requests before swapping nodes in bdrv_swap()
bdrv_swap() requires that there are no requests in flight on either of
the two devices. The request coroutine would work on the wrong
BlockDriverState object (with bs->opaque even being interpreted as a
different type potentially) and all sorts of bad things would result
from this.
The currently existing callers mostly ensure that there is no I/O
pending on nodes that are swapped. In detail, this is:
1. Live snapshots. This goes through qmp_transaction(), which calls
bdrv_drain_all() before doing anything. The command is executed
synchronously, so no new I/O can be issued concurrently.
2. snapshot=on in bdrv_open(). We're in the middle of opening the image
(both the original image and its temporary overlay), so there can't
be any I/O in flight yet.
3. Mirroring. bdrv_drain() is already used on the source device so that
the mirror doesn't miss anything. However, the main loop runs between
that and the bdrv_swap() (which is actually a bug, being addressed in
another series), so there is a small window in which new I/O might be
issued that would be in flight during bdrv_swap().
It is safer to just drain the request queue of both devices in
bdrv_swap() instead of relying on callers to do the right thing.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'linux-user/uname.h')
0 files changed, 0 insertions, 0 deletions