tools/foreignmem: Support querying the size of a resource
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 23 Jul 2020 14:58:48 +0000 (15:58 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 28 Jan 2021 13:08:11 +0000 (13:08 +0000)
commit75fc85998546878ca5417071a6ca60c34065c2c3
treee08f9a5452c960719626b26b4066e3ec7da5de44
parent2b4b33ffe7d67dc677350a3e1fa7a11d7ab49fb4
tools/foreignmem: Support querying the size of a resource

With the Xen side of this interface (soon to be) fixed to return real sizes,
userspace needs to be able to make the query.

Introduce xenforeignmemory_resource_size() for the purpose, bumping the
library minor version.

Update both all osdep_xenforeignmemory_map_resource() implementations to
understand size requests, skip the mmap() operation, and copy back the
nr_frames field.

For NetBSD, also fix up the ioctl() error path to issue an unmap(), which was
overlooked by c/s 4a64e2bb39 "libs/foreignmemory: Implement on NetBSD".

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Acked-by: Wei Liu <wl@xen.org>
tools/include/xenforeignmemory.h
tools/libs/foreignmemory/Makefile
tools/libs/foreignmemory/core.c
tools/libs/foreignmemory/freebsd.c
tools/libs/foreignmemory/libxenforeignmemory.map
tools/libs/foreignmemory/linux.c
tools/libs/foreignmemory/netbsd.c