From: Stefan Hajnoczi <stefanha@gmail.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, kwolf@redhat.com,
fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [RFC PATCH] block: local qiov helper
Date: Tue, 29 Jan 2019 11:31:55 +0800 [thread overview]
Message-ID: <20190129033155.GD3264@stefanha-x1.localdomain> (raw)
In-Reply-To: <20190125164601.130556-1-vsementsov@virtuozzo.com>
[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]
On Fri, Jan 25, 2019 at 07:46:01PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Hi all.
>
> What about such a simple helper for a very often patter around
> qemu_iovec_init_external ?
Sounds good, qemu_iovec_init() has 55 references vs
qemu_iovec_init_external() with 51. It's worth making
qemu_iovec_init_external() nicer to use.
> If we like it, I'll update other callers of qemu_iovec_init_external.
>
> Possible interface change would be
> LOCAL_QIOV(lc, buf, len);
> instead of
> LocalQiov lc = LOCAL_QIOV(lc, buf, len);
>
> or, may be, someone has a better idea?
Bike-shedding territory, but I prefer LocalQiov lc = LOCAL_QIOV(lc, buf,
len) because it reveals the type. This makes the code easier to read
than just LOCAL_QIOV(lc, buf, len) by itself - the reader is forced to
look up the macro definition to figure out what magic happens.
> diff --git a/block/io.c b/block/io.c
> index bd9d688f8b..c7d7b199c1 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -949,18 +949,13 @@ int bdrv_preadv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov)
>
> int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int bytes)
> {
> - QEMUIOVector qiov;
> - struct iovec iov = {
> - .iov_base = (void *)buf,
> - .iov_len = bytes,
> - };
> + LocalQiov lq = LOCAL_QIOV(lq, buf, bytes);
>
> if (bytes < 0) {
> return -EINVAL;
> }
>
> - qemu_iovec_init_external(&qiov, &iov, 1);
> - return bdrv_preadv(child, offset, &qiov);
> + return bdrv_preadv(child, offset, &lq.qiov);
I think it's unfortunate that LocalQiov is necessary since the caller
only needs the qiov. Can we afford to embed the struct iovec into
QEMUIOVector?
That way callers don't need a separate LocalQiov type:
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
...
return bdrv_preadv(child, offset, &qiov);
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2019-01-29 3:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-25 16:46 [Qemu-devel] [RFC PATCH] block: local qiov helper Vladimir Sementsov-Ogievskiy
2019-01-29 3:31 ` Stefan Hajnoczi [this message]
2019-01-29 10:24 ` [Qemu-devel] [Qemu-block] " Vladimir Sementsov-Ogievskiy
2019-01-29 10:32 ` Stefan Hajnoczi
2019-01-29 11:18 ` Vladimir Sementsov-Ogievskiy
2019-01-29 12:34 ` Kevin Wolf
2019-01-30 3:10 ` Stefan Hajnoczi
2019-02-03 5:54 ` [Qemu-devel] " no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190129033155.GD3264@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).