vhost: fix leak of fds and mmaps
authorRich Lane <rich.lane@bigswitch.com>
Wed, 10 Feb 2016 18:40:55 +0000 (10:40 -0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 19 Feb 2016 15:13:32 +0000 (16:13 +0100)
commitca67ed289a76f38d6c4a4021985a36eaf1d77e28
tree4553ad01e611b18e9eaef1becba9fe1bfac6896a
parentd22929db97b4fc7297a57e016578eca1acd33aad
vhost: fix leak of fds and mmaps

The common vhost code only supported a single mmap per device. vhost-user
worked around this by saving the address/length/fd of each mmap after the end
of the rte_virtio_memory struct. This only works if the vhost-user code frees
dev->mem, since the common code is unaware of the extra info. The
VHOST_USER_RESET_OWNER message is one situation where the common code frees
dev->mem and leaks the fds and mappings. This happens every time I shut down a
VM.

The new code calls back into the implementation (vhost-user or vhost-cuse) to
clean up these resources.

The vhost-cuse changes are only compile tested.

Signed-off-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
lib/librte_vhost/vhost-net.h
lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
lib/librte_vhost/vhost_user/vhost-net-user.c
lib/librte_vhost/vhost_user/virtio-net-user.c
lib/librte_vhost/vhost_user/virtio-net-user.h
lib/librte_vhost/virtio-net.c