On 25 November 2014 at 14:43, Stefano Stabellini <stefano.stabell...@eu.citrix.com> wrote: > Introduce a function to unmap an sg previously mapped with > virtqueue_map_sg. > > Signed-off-by: Stefano Stabellini <stefano.stabell...@eu.citrix.com> > CC: jasow...@redhat.com > CC: we...@cn.fujitsu.com > CC: m...@redhat.com > CC: pbonz...@redhat.com > --- > hw/virtio/virtio.c | 22 ++++++++++++++++++++++ > include/hw/virtio/virtio.h | 2 ++ > 2 files changed, 24 insertions(+) > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index 3e4b70c..2621ae6 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -446,6 +446,28 @@ void virtqueue_map_sg(struct iovec *sg, hwaddr *addr, > } > } > > +void virtqueue_unmap_sg(const struct iovec *sg, size_t num_sg, > + int is_write, unsigned int len) > +{ > + unsigned int i; > + unsigned int offset; > + > + if (num_sg > VIRTQUEUE_MAX_SIZE) { > + error_report("virtio: unmap attempt out of bounds: %zd > %d", > + num_sg, VIRTQUEUE_MAX_SIZE); > + exit(1); > + } > + > + offset = 0; > + for (i = 0; i < num_sg; i++) { > + size_t size = MIN(len - offset, sg[i].iov_len); > + > + cpu_physical_memory_unmap(sg[i].iov_base, sg[i].iov_len, is_write, > size); > + > + offset += size; > + } > +}
It seems rather odd that "size" and the iov_len fields in the iovec are size_t but 'len' and 'offset' are only unsigned int... thanks -- PMM _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel