From: Paolo Bonzini <pbonzini@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC] virtio: add virtqueue_fill_partial
Date: Mon, 27 Apr 2015 16:24:31 +0200 [thread overview]
Message-ID: <553E469F.1000605@redhat.com> (raw)
In-Reply-To: <1430144304-13514-1-git-send-email-mst@redhat.com>
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. If the guest is not relying on iov boundaries, it should never
be necessary to use this function."
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);
> +}
> +
next prev parent reply other threads:[~2015-04-27 14:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-27 14:18 [Qemu-devel] [PATCH RFC] virtio: add virtqueue_fill_partial Michael S. Tsirkin
2015-04-27 14:24 ` Paolo Bonzini [this message]
2015-04-27 14:38 ` Michael S. Tsirkin
2015-04-27 14:58 ` Paolo Bonzini
2015-04-27 16:13 ` Michael S. Tsirkin
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=553E469F.1000605@redhat.com \
--to=pbonzini@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.