[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC] virtio: add virtqueue_fill_partial
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH RFC] virtio: add virtqueue_fill_partial |
Date: |
Mon, 27 Apr 2015 16:38:52 +0200 |
On Mon, Apr 27, 2015 at 04:24:31PM +0200, Paolo Bonzini wrote:
>
>
> On 27/04/2015 16:18, Michael S. Tsirkin wrote:
> > +/*
> > + * Some devices dirty guest memory but don't want to tell guest about it.
> > In
> > + * that case, use virtqueue_fill_partial: host_len is >= the amount of
> > guest
> > + * memory actually written, guest_len is how much we guarantee to guest.
> > + * If you know exactly how much was written, use virtqueue_fill instead.
>
> "If you never leave holes unwritten in the iov, use virtqueue_fill
> instead.
Is it just holes? Never data you are unsure about?
> If the guest is not relying on iov boundaries, it should never
> be necessary to use this function."
You never know what guest does though, do you?
> The API looks okay though.
>
> Paolo
>
> > + */
> > +void virtqueue_fill_partial(VirtQueue *vq, const VirtQueueElement *elem,
> > + unsigned int host_len, unsigned int guest_len,
> > + unsigned int idx)
> > {
> > unsigned int offset;
> > int i;
> >
> > - trace_virtqueue_fill(vq, elem, len, idx);
> > + assert(host_len >= guest_len);
> > +
> > + trace_virtqueue_fill(vq, elem, guest_len, idx);
> >
> > offset = 0;
> > for (i = 0; i < elem->in_num; i++) {
> > - size_t size = MIN(len - offset, elem->in_sg[i].iov_len);
> > + size_t size = MIN(host_len - offset, elem->in_sg[i].iov_len);
> >
> > cpu_physical_memory_unmap(elem->in_sg[i].iov_base,
> > elem->in_sg[i].iov_len,
> > @@ -269,7 +278,13 @@ void virtqueue_fill(VirtQueue *vq, const
> > VirtQueueElement *elem,
> >
> > /* Get a pointer to the next entry in the used ring. */
> > vring_used_ring_id(vq, idx, elem->index);
> > - vring_used_ring_len(vq, idx, len);
> > + vring_used_ring_len(vq, idx, guest_len);
> > +}
> > +