socket_listen and socket_connect do not allow custom socket option. This would be inconvenient if the caller wants a non-blocking socket, or wants to set TCP_NODELAY or other options.
This series of patches add specific config structures, QemuSocketConfig, which contains QemuSocketOption. All the QemuSocketOption are formed as a linked list. The caller is reponsible for setting up the config structure. Passing an NULL pointer would use the original socket_listen/socket_connect, so existing functions are not affected. Note that the caller needs to check errno after socket_connect when using a non-blocking socket. It does not have to in other cases. Zihan Yang (4): qemu-socket: Allow custom socket option in socket_listen qemu-socket: Allow custom socket options in socket_connect net/socket: change net_socket_listen_init to use functions in include/qemu/sockets.h net/socket: change net_socket_connect_init to use functions in sockets.h block/sheepdog.c | 2 +- block/ssh.c | 2 +- include/qemu/sockets.h | 22 ++++++- io/channel-socket.c | 4 +- net/socket.c | 93 ++++++++++++++--------------- qga/channel-posix.c | 2 +- util/qemu-sockets.c | 156 ++++++++++++++++++++++++++++++++++++++++--------- 7 files changed, 197 insertions(+), 84 deletions(-) -- 2.7.4