[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 01/17] vvfat: Use BdrvChild for s->qcow
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH 01/17] vvfat: Use BdrvChild for s->qcow |
Date: |
Wed, 22 Jun 2016 18:54:40 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
On 21.06.2016 11:21, Kevin Wolf wrote:
> vvfat uses a temporary qcow file to cache written data in read-write
> mode. In order to do things properly, this should show up in the BDS
> graph and I/O should go through BdrvChild like for every other node.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block/vvfat.c | 66
> ++++++++++++++++++++++++++++++++++++++---------------------
> 1 file changed, 43 insertions(+), 23 deletions(-)
checkpatch.pl has some complaints:
ERROR: "foo* bar" should be "foo *bar"
#43: FILE: block/vvfat.c:348:
+ BdrvChild* qcow;
ERROR: spaces required around that '-' (ctx:VxV)
#81: FILE: block/vvfat.c:1392:
+ if (bdrv_is_allocated(s->qcow->bs, sector_num,
nb_sectors-i, &n)) {
^
ERROR: spaces required around that '*' (ctx:VxV)
#84: FILE: block/vvfat.c:1395:
+ if (bdrv_read(s->qcow->bs, sector_num, buf + i*0x200, n)) {
^
ERROR: code indent should never use tabs
#103: FILE: block/vvfat.c:1677:
+^I cluster2sector(s, cluster_num) + i,$
The fourth is actually something you introduced (more or less, at least
all of the surrounding code uses spaces), so that must be fixed.
The rest is preexisting, but I think some of those are worth fixing
still; namely all but the first. You know how I think about the first
and I know how you think about it, so I won't complain if it's
surrounded by code in the same style.
> diff --git a/block/vvfat.c b/block/vvfat.c
> index 6d2e21c..2eb2536 100644
> --- a/block/vvfat.c
> +++ b/block/vvfat.c
[...]
> @@ -2949,7 +2958,7 @@ write_target_commit(BlockDriverState *bs, uint64_t
> offset, uint64_t bytes,
>
> static void write_target_close(BlockDriverState *bs) {
> BDRVVVFATState* s = *((BDRVVVFATState**) bs->opaque);
> - bdrv_unref(s->qcow);
> + bdrv_unref_child(NULL, s->qcow);
Not that it matters, but why not s->bs instead of NULL?
> g_free(s->qcow_filename);
> }
>
> @@ -2959,8 +2968,19 @@ static BlockDriver vvfat_write_target = {
> .bdrv_close = write_target_close,
> };
>
> -static int enable_write_target(BDRVVVFATState *s, Error **errp)
> +static void vvfat_qcow_options(int *child_flags, QDict *child_options,
> + int parent_flags, QDict *parent_options)
> {
> + *child_flags = BDRV_O_RDWR | BDRV_O_NO_FLUSH;
> +}
> +
> +const BdrvChildRole child_vvfat_qcow = {
Any reason for not making this static?
> + .inherit_options = vvfat_qcow_options,
> +};
> +
> +static int enable_write_target(BlockDriverState *bs, Error **errp)
> +{
> + BDRVVVFATState *s = bs->opaque;
> BlockDriver *bdrv_qcow = NULL;
> BlockDriverState *backing;
> QemuOpts *opts = NULL;
> @@ -2999,8 +3019,8 @@ static int enable_write_target(BDRVVVFATState *s, Error
> **errp)
>
> options = qdict_new();
> qdict_put(options, "driver", qstring_from_str("qcow"));
> - s->qcow = bdrv_open(s->qcow_filename, NULL, options,
> - BDRV_O_RDWR | BDRV_O_NO_FLUSH, errp);
> + s->qcow = bdrv_open_child(s->qcow_filename, options, "qcow", bs,
I'd have called it "write_target", but, well.
Max
> + &child_vvfat_qcow, false, errp);
> if (!s->qcow) {
> ret = -EINVAL;
> goto err;
>
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH 00/17] block: Convert common I/O path to BdrvChild, Kevin Wolf, 2016/06/21
- [Qemu-devel] [PATCH 02/17] blkreplay: Convert to byte-based I/O, Kevin Wolf, 2016/06/21
- [Qemu-devel] [PATCH 04/17] block: Convert bdrv_co_readv() to BdrvChild, Kevin Wolf, 2016/06/21
- [Qemu-devel] [PATCH 01/17] vvfat: Use BdrvChild for s->qcow, Kevin Wolf, 2016/06/21
- Re: [Qemu-devel] [PATCH 01/17] vvfat: Use BdrvChild for s->qcow,
Max Reitz <=
- [Qemu-devel] [PATCH 03/17] vhdx: Some more BlockBackend use in vhdx_create(), Kevin Wolf, 2016/06/21
- [Qemu-devel] [PATCH 08/17] block: Convert bdrv_co_do_readv/writev to BdrvChild, Kevin Wolf, 2016/06/21
- [Qemu-devel] [PATCH 05/17] block: Convert bdrv_co_writev() to BdrvChild, Kevin Wolf, 2016/06/21
- [Qemu-devel] [PATCH 07/17] block: Convert bdrv_aio_writev() to BdrvChild, Kevin Wolf, 2016/06/21
- [Qemu-devel] [PATCH 12/17] block: Convert bdrv_write() to BdrvChild, Kevin Wolf, 2016/06/21