OSDN Git Service

block: Implement bdrv_append() without bdrv_swap()
authorKevin Wolf <kwolf@redhat.com>
Thu, 18 Jun 2015 12:09:57 +0000 (14:09 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 16 Oct 2015 13:34:30 +0000 (15:34 +0200)
commitdd62f1ca433ea60b06590884642ad2c8f8e539f2
treea1e53e2369d7b92f71e951d8c9bb23237642e39f
parentd42a8a935b8b2d567331fffa13a70918352668bb
block: Implement bdrv_append() without bdrv_swap()

Remember all parent nodes and just change the pointers there instead of
swapping the contents of the BlockDriverState.

Handling of snapshot=on must be moved further down in bdrv_open()
because *pbs (which is the bs pointer in the BlockBackend) must already
be set before bdrv_append() is called. Otherwise bdrv_append() changes
the BB's pointer to the temporary snapshot, but bdrv_open() overwrites
it with the read-only original image.

We also need to be careful to update callers as the interface changes
(becomes less insane): Previously, the meaning of the two parameters was
inverted when bdrv_append() returns. Now any BDS pointers keep pointing
to the same node.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
block.c
blockdev.c