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>