[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 32/46] block: bdrv_append() fixes
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 32/46] block: bdrv_append() fixes |
Date: |
Thu, 5 Apr 2012 17:52:10 +0200 |
From: Jeff Cody <address@hidden>
A few fixups for bdrv_append():
The new bs (bs_new) passed into bdrv_append() should be anonymous. Rather
than call bdrv_make_anon() to enforce this, use an assert to catch when a caller
is passing in a bs_new that is not anonymous.
Also, the new top layer should have its backing_format reflect the original
top's format.
And last, after the swap of bs contents, the device_name will have been copied
down. This needs to be cleared to reflect the anonymity of the bs that was
pushed down.
Signed-off-by: Jeff Cody <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index 33630eb..b3117ef 100644
--- a/block.c
+++ b/block.c
@@ -892,14 +892,16 @@ void bdrv_make_anon(BlockDriverState *bs)
* This will modify the BlockDriverState fields, and swap contents
* between bs_new and bs_top. Both bs_new and bs_top are modified.
*
+ * bs_new is required to be anonymous.
+ *
* This function does not create any image files.
*/
void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
{
BlockDriverState tmp;
- /* the new bs must not be in bdrv_states */
- bdrv_make_anon(bs_new);
+ /* bs_new must be anonymous */
+ assert(bs_new->device_name[0] == '\0');
tmp = *bs_new;
@@ -944,11 +946,18 @@ void bdrv_append(BlockDriverState *bs_new,
BlockDriverState *bs_top)
* swapping bs_new and bs_top contents. */
tmp.backing_hd = bs_new;
pstrcpy(tmp.backing_file, sizeof(tmp.backing_file), bs_top->filename);
+ bdrv_get_format(bs_top, tmp.backing_format, sizeof(tmp.backing_format));
/* swap contents of the fixed new bs and the current top */
*bs_new = *bs_top;
*bs_top = tmp;
+ /* device_name[] was carried over from the old bs_top. bs_new
+ * shouldn't be in bdrv_states, so we need to make device_name[]
+ * reflect the anonymity of bs_new
+ */
+ bs_new->device_name[0] = '\0';
+
/* clear the copied fields in the new backing file */
bdrv_detach_dev(bs_new, bs_new->dev);
--
1.7.6.5
- [Qemu-devel] [PATCH 17/46] vdi: merge aio_read_cb and aio_write_cb into callers, (continued)
- [Qemu-devel] [PATCH 17/46] vdi: merge aio_read_cb and aio_write_cb into callers, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 18/46] vdi: move aiocb fields to locals, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 23/46] block: disable I/O throttling on sync api, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 24/46] block: cancel jobs when a device is ready to go away, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 22/46] Use DMADirection type for dma_bdrv_io, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 43/46] qed: add bdrv_invalidate_cache to be called after incoming live migration, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 37/46] qemu-iotests: Fix call syntax for qemu-img, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 38/46] qemu-iotests: Fix call syntax for qemu-io, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 28/46] qemu-img: add image fragmentation statistics, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 21/46] vdi: change goto to loop, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 32/46] block: bdrv_append() fixes,
Kevin Wolf <=
- [Qemu-devel] [PATCH 13/46] qdev: add blocksize property type, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 20/46] vdi: do not create useless iovecs, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 42/46] blockdev: open images with BDRV_O_INCOMING on incoming live migration, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 25/46] block: fix streaming/closing race, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 36/46] qemu-iotests: Test unknown qcow2 header extensions, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 33/46] sheepdog: implement SD_OP_FLUSH_VDI operation, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 11/46] block/vpc: write checksum back to footer after check, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 15/46] vdi: basic conversion to coroutines, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 09/46] ide: Change serial number strncpy() to pstrcpy(), Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 27/46] block: document job API, Kevin Wolf, 2012/04/05