2f4adfad0a
Since VFIO cannot be used to map the same device twice, secondary processes receive the device/group fd's by means of communicating over a local socket. Only group and container fd's should be sent, as device fd's can be obtained via ioctl() calls' on the group fd. For multiprocess, VFIO distinguishes between existing but unused groups (e.g. grups that aren't bound to VFIO driver) and non-existing groups in order to know if the secondary process requests a valid group, or if secondary process requests something that doesn't exist. VFIO multiprocess sync communicates over a simple protocol. It defines two requests - request for group fd, and request for container fd. Possible replies are: SOCKET_OK (an OK signal), SOCKET_ERR (error signal) and SOCKET_NO_FD (a signal that indicates that the requested VFIO group is valid, but no fd is present for that group - indicating that the respective group is simply not bound to VFIO driver). Here is the logic in a nutshell: 1. secondary process sends SOCKET_REQ_CONTAINER or SOCKET_REQ_GROUP 1a. in case of SOCKET_REQ_GROUP, client also then sends group number 2. primary process receives message 2a. in case of invalid group, SOCKET_ERR is sent back to secondary 2b. in case of unbound group, SOCKET_NO_FD is sent back to secondary 2c. in case of valid group, SOCKET_OK is sent and followed by fd 3. socket is closed in case of any error, socket is closed and SOCKET_ERR is sent. Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com> Tested-by: Waterman Cao <waterman.cao@intel.com> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>