[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 18/19] vvfat: Use opened node as backing file
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 18/19] vvfat: Use opened node as backing file |
Date: |
Fri, 24 Feb 2017 19:17:09 +0100 |
We should not try to assign a not yet opened node as the backing file,
because as soon as the permission system is added it will fail. The
just added bdrv_new_open_driver() function is the right tool to open a
file with an internal driver, use it.
In case anyone wonders whether that magic fake backing file to trigger a
special action on 'commit' actually works today: No, not for me. One
reason is that we've been adding a raw format driver on top for several
years now and raw doesn't support commit. Other reasons include that the
backing file isn't writable and the driver doesn't support reopen, and
it's also size 0 and the driver doesn't support bdrv_truncate. All of
these are easily fixable, but then 'commit' ended up in an infinite loop
deep in the vvfat code for me, so I thought I'd best leave it alone. I'm
not really sure what it was supposed to do anyway.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block/vvfat.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/block/vvfat.c b/block/vvfat.c
index c6bf67e..7f230be 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -2968,6 +2968,7 @@ static void write_target_close(BlockDriverState *bs) {
static BlockDriver vvfat_write_target = {
.format_name = "vvfat_write_target",
+ .instance_size = sizeof(void*),
.bdrv_co_pwritev = write_target_commit,
.bdrv_close = write_target_close,
};
@@ -3036,14 +3037,13 @@ static int enable_write_target(BlockDriverState *bs,
Error **errp)
unlink(s->qcow_filename);
#endif
- backing = bdrv_new();
+ backing = bdrv_new_open_driver(&vvfat_write_target, NULL,
BDRV_O_ALLOW_RDWR,
+ &error_abort);
+ *(void**) backing->opaque = s;
+
bdrv_set_backing_hd(s->bs, backing);
bdrv_unref(backing);
- s->bs->backing->bs->drv = &vvfat_write_target;
- s->bs->backing->bs->opaque = g_new(void *, 1);
- *(void**)s->bs->backing->bs->opaque = s;
-
return 0;
err:
--
1.8.3.1
- [Qemu-devel] [PULL 06/19] qemu-img: Truncate before full preallocation, (continued)
- [Qemu-devel] [PULL 06/19] qemu-img: Truncate before full preallocation, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 08/19] iotests: Fix another race in 030, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 09/19] blockdev: Use BlockBackend to resize in qmp_block_resize(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 11/19] mirror: Resize active commit base in mirror_run(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 12/19] block: Pass BdrvChild to bdrv_truncate(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 15/19] block: Use BlockBackend for image probing, Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 10/19] qcow2: Use BB for resizing in qcow2_amend_options(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 14/19] block: Factor out bdrv_open_child_bs(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 16/19] block: Factor out bdrv_open_driver(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 17/19] block: Add bdrv_new_open_driver(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 18/19] vvfat: Use opened node as backing file,
Kevin Wolf <=
- [Qemu-devel] [PULL 13/19] block: Attach bs->file only during .bdrv_open(), Kevin Wolf, 2017/02/24
- [Qemu-devel] [PULL 19/19] tests: Use opened block node for block job tests, Kevin Wolf, 2017/02/24
- Re: [Qemu-devel] [PULL 00/19] Block layer patches, no-reply, 2017/02/24
- Re: [Qemu-devel] [PULL 00/19] Block layer patches, Peter Maydell, 2017/02/26