[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v1 4/7] io: pass a struct iovec into qio_channel
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-devel] [PATCH v1 4/7] io: pass a struct iovec into qio_channel_websock_encode |
Date: |
Tue, 10 Oct 2017 18:36:07 +0100 |
User-agent: |
Mutt/1.9.0 (2017-09-02) |
On Tue, Oct 10, 2017 at 12:18:26PM -0500, Eric Blake wrote:
> On 10/10/2017 10:43 AM, Daniel P. Berrange wrote:
> > Instead of requiring use of another Buffer, pass a struct iovec
> > into qio_channel_websock_encode, which gives callers more
> > flexibility in how they process data.
> >
> > Signed-off-by: Daniel P. Berrange <address@hidden>
> > ---
> > io/channel-websock.c | 69
> > ++++++++++++++++++++++++++++++++--------------------
> > 1 file changed, 42 insertions(+), 27 deletions(-)
> >
>
> > +static void qio_channel_websock_encode(QIOChannelWebsock *ioc,
> > + uint8_t opcode,
> > + const struct iovec *iov,
> > + size_t niov,
> > + size_t size)
> > {
>
> Is size redundant with iov_size(iov, niov)? Or is a caller allowed to
> pass a smaller size (tail end of iov is not encoded) or larger size
> (encoding stops at end of iov, even if size is not exhausted)? I'd lean
> towards the former (one less parameter), especially since all callers in
> this patch could have passed iov_size(&iov, 1) for the same effect.
You've already noticed the code in later patch which passes a smaller
size. This lets me avoid having to duplicate the iovec array and
set smaller iov_len
>
> > - trace_qio_channel_websock_encode(ioc, opcode, header_size,
> > buffer->offset);
> > - buffer_reserve(output, header_size + buffer->offset);
> > - buffer_append(output, header.buf, header_size);
> > - buffer_append(output, buffer->buffer, buffer->offset);
> > + trace_qio_channel_websock_encode(ioc, opcode, header_size, size);
> > + buffer_reserve(&ioc->encoutput, header_size + size);
> > + buffer_append(&ioc->encoutput, header.buf, header_size);
> > + for (i = 0; i < niov && size != 0; i++) {
> > + size_t want = iov->iov_len;
> > + if (want > size) {
> > + want = size;
> > + }
> > + buffer_append(&ioc->encoutput, iov->iov_base, want);
> > + size -= want;
> > + }
>
> Umm, where are you incrementing iov? It appears you only tested with
> niov == 1.
Opps. Yeah, we need to cope with niov > 0 to satisfy qio_channel_writev
API contract, but the VNC server only ever sends a single iov element
so I didn't hit the bug.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- Re: [Qemu-devel] [PATCH v1 2/7] io: simplify websocket ping reply handling, (continued)
- [Qemu-devel] [PATCH v1 3/7] io: get rid of qio_channel_websock_encode helper method, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 1/7] io: monitor encoutput buffer size from websocket GSource, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 5/7] io: get rid of bounce buffering in websock write path, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 4/7] io: pass a struct iovec into qio_channel_websock_encode, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 7/7] io: add trace points for websocket HTTP protocol headers, Daniel P. Berrange, 2017/10/10
- [Qemu-devel] [PATCH v1 6/7] io: cope with websock 'Connection' header having multiple values, Daniel P. Berrange, 2017/10/10