Received: from eggs.gnu.org ([2001:4830:134:3::10]:54046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmkBe-00014i-CL for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:39:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmkBZ-0003in-7j for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:39:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46201) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmkBY-0003ib-Vj for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:39:01 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3REcxHh014584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Apr 2015 10:39:00 -0400 Date: Mon, 27 Apr 2015 16:38:52 +0200 From: "Michael S. Tsirkin" Message-ID: <20150427163730-mutt-send-email-mst@redhat.com> References: <1430144304-13514-1-git-send-email-mst@redhat.com> <553E469F.1000605@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <553E469F.1000605@redhat.com> Subject: Re: [Qemu-devel] [PATCH RFC] virtio: add virtqueue_fill_partial List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org 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); > > +} > > +