summaryrefslogtreecommitdiff
path: root/lib/librte_vhost
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@samsung.com>2016-06-16 12:16:36 +0300
committerYuanhan Liu <yuanhan.liu@linux.intel.com>2016-06-22 09:47:12 +0200
commit53af5b1e0acec5080b4928e33a127289e0a73a1e (patch)
tree974351b655db067c1b4dc6e525429bfe66d8ffe1 /lib/librte_vhost
parent1b69528e5fc1bfb78c7b7cc93307b5661ae03f68 (diff)
downloaddpdk-53af5b1e0acec5080b4928e33a127289e0a73a1e.zip
dpdk-53af5b1e0acec5080b4928e33a127289e0a73a1e.tar.gz
dpdk-53af5b1e0acec5080b4928e33a127289e0a73a1e.tar.xz
vhost: fix leak of file descriptors
While migration of vhost-user device QEMU allocates memfd to store information about dirty pages and sends fd to vhost-user process. File descriptor for this memory should be closed to prevent "Too many open files" error for vhost-user process after some amount of migrations. Ex.: # ls /proc/<ovs-vswitchd pid>/fd/ -alh total 0 root qemu . root qemu .. root qemu 0 -> /dev/pts/0 root qemu 1 -> pipe:[1804353] root qemu 10 -> socket:[1782240] root qemu 100 -> /memfd:vhost-log (deleted) root qemu 1000 -> /memfd:vhost-log (deleted) root qemu 1001 -> /memfd:vhost-log (deleted) root qemu 1004 -> /memfd:vhost-log (deleted) [...] root qemu 996 -> /memfd:vhost-log (deleted) root qemu 997 -> /memfd:vhost-log (deleted) ovs-vswitchd.log: |WARN|punix:ovs-vswitchd.ctl: accept failed: Too many open files Fixes: 54f9e32305d4 ("vhost: handle dirty pages logging request") Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Diffstat (limited to 'lib/librte_vhost')
-rw-r--r--lib/librte_vhost/vhost_user/virtio-net-user.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
index 64a6ec4..e6a2aed 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -401,6 +401,7 @@ user_set_log_base(int vid, struct VhostUserMsg *msg)
* fail when offset is not page size aligned.
*/
addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ close(fd);
if (addr == MAP_FAILED) {
RTE_LOG(ERR, VHOST_CONFIG, "mmap log base failed!\n");
return -1;