* [Qemu-devel] [PATCH v2] win32-aio: use iov utility functions instead of open-coding them
@ 2013-01-17 10:44 Michael Tokarev
2013-01-17 13:06 ` Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2013-01-17 10:44 UTC (permalink / raw)
To: Kevin Wolf; +Cc: pbonzini, Michael Tokarev, qemu-devel, stefanha
We have iov_from_buf() and iov_to_buf(), use them instead of
open-coding these in block/win32-aio.c
---
block/win32-aio.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/block/win32-aio.c b/block/win32-aio.c
index b9236ea..b10a0c0 100644
--- a/block/win32-aio.c
+++ b/block/win32-aio.c
@@ -80,13 +80,7 @@ static void win32_aio_process_completion(QEMUWin32AIOState *s,
if (!waiocb->is_linear) {
if (ret == 0 && waiocb->is_read) {
QEMUIOVector *qiov = waiocb->qiov;
- char *p = waiocb->buf;
- int i;
-
- for (i = 0; i < qiov->niov; ++i) {
- memcpy(qiov->iov[i].iov_base, p, qiov->iov[i].iov_len);
- p += qiov->iov[i].iov_len;
- }
+ iov_from_buf(qiov->iov, qiov->niov, 0, waiocb->buf, qiov->size);
}
qemu_vfree(waiocb->buf);
}
@@ -153,13 +147,7 @@ BlockDriverAIOCB *win32_aio_submit(BlockDriverState *bs,
if (qiov->niov > 1) {
waiocb->buf = qemu_blockalign(bs, qiov->size);
if (type & QEMU_AIO_WRITE) {
- char *p = waiocb->buf;
- int i;
-
- for (i = 0; i < qiov->niov; ++i) {
- memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len);
- p += qiov->iov[i].iov_len;
- }
+ iov_to_buf(qiov->iov, qiov->niov, 0, waiocb->buf, qiov->size);
}
waiocb->is_linear = false;
} else {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32-aio: use iov utility functions instead of open-coding them
2013-01-17 10:44 [Qemu-devel] [PATCH v2] win32-aio: use iov utility functions instead of open-coding them Michael Tokarev
@ 2013-01-17 13:06 ` Stefan Hajnoczi
2013-01-17 13:51 ` Michael Tokarev
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-01-17 13:06 UTC (permalink / raw)
To: Michael Tokarev; +Cc: Kevin Wolf, pbonzini, qemu-devel
On Thu, Jan 17, 2013 at 02:44:41PM +0400, Michael Tokarev wrote:
> We have iov_from_buf() and iov_to_buf(), use them instead of
> open-coding these in block/win32-aio.c
Please use qemu_iovec_from_buf() and qemu_iovec_to_buf() since we're
operating on a QEMUIOVector.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32-aio: use iov utility functions instead of open-coding them
2013-01-17 13:06 ` Stefan Hajnoczi
@ 2013-01-17 13:51 ` Michael Tokarev
2013-01-18 8:46 ` Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2013-01-17 13:51 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, pbonzini, qemu-devel
17.01.2013 17:06, Stefan Hajnoczi wrote:
> On Thu, Jan 17, 2013 at 02:44:41PM +0400, Michael Tokarev wrote:
>> We have iov_from_buf() and iov_to_buf(), use them instead of
>> open-coding these in block/win32-aio.c
>
> Please use qemu_iovec_from_buf() and qemu_iovec_to_buf() since we're
> operating on a QEMUIOVector.
I'd remove qemu_iovec_{from,to}_buf() completely at this point
due to their trivialness and almost no gain in usage as polluting
the namespace (having too many trivial utility functions isn't
good). Right now these are only used in one place - in
hw/dataplane/virtio-blk.c .
If not, we can at least inline them.
Thanks,
/mjt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32-aio: use iov utility functions instead of open-coding them
2013-01-17 13:51 ` Michael Tokarev
@ 2013-01-18 8:46 ` Stefan Hajnoczi
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-01-18 8:46 UTC (permalink / raw)
To: Michael Tokarev; +Cc: Kevin Wolf, pbonzini, qemu-devel
On Thu, Jan 17, 2013 at 05:51:05PM +0400, Michael Tokarev wrote:
> 17.01.2013 17:06, Stefan Hajnoczi wrote:
> >On Thu, Jan 17, 2013 at 02:44:41PM +0400, Michael Tokarev wrote:
> >>We have iov_from_buf() and iov_to_buf(), use them instead of
> >>open-coding these in block/win32-aio.c
> >
> >Please use qemu_iovec_from_buf() and qemu_iovec_to_buf() since we're
> >operating on a QEMUIOVector.
>
> I'd remove qemu_iovec_{from,to}_buf() completely at this point
> due to their trivialness and almost no gain in usage as polluting
> the namespace (having too many trivial utility functions isn't
> good). Right now these are only used in one place - in
> hw/dataplane/virtio-blk.c .
I like them because it makes the calling code nicer to read. It saves
us from pulling apart the QEMUIOVector struct.
But it's not a big deal to me. I can merge this version of the patch.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-18 10:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-17 10:44 [Qemu-devel] [PATCH v2] win32-aio: use iov utility functions instead of open-coding them Michael Tokarev
2013-01-17 13:06 ` Stefan Hajnoczi
2013-01-17 13:51 ` Michael Tokarev
2013-01-18 8:46 ` Stefan Hajnoczi
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).