Skip to content

Commit 2eda1f5

Browse files
committed
Add the Linux VSOCK transport.
VSOCK transport allows communication between the Host and guests. It requires linux on the host and Guest. Fixes #4491
1 parent 7a7bfa1 commit 2eda1f5

33 files changed

+1031
-7
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Philip Kovacs
102102
Pieter Hintjens
103103
Piotr Trojanek
104104
Reza Ebrahimi
105+
Remi Jouannet
105106
Richard Newton
106107
Rik van der Heijden
107108
Robert G. Jakabosky

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,9 @@ set(cxx-sources
11601160
vmci_address.hpp
11611161
vmci_connecter.hpp
11621162
vmci_listener.hpp
1163+
vsock_address.hpp
1164+
vsock_connecter.hpp
1165+
vsock_listener.hpp
11631166
windows.hpp
11641167
wire.hpp
11651168
xpub.hpp
@@ -1233,6 +1236,10 @@ message(STATUS "Building with VMCI")
12331236
list(APPEND cxx-sources vmci_address.cpp vmci_connecter.cpp vmci_listener.cpp vmci.cpp)
12341237
endif()
12351238

1239+
if(ZMQ_HAVE_VSOCK)
1240+
list(APPEND cxx-sources vsock_address.cpp vsock_connecter.cpp vsock_listener.cpp)
1241+
endif()
1242+
12361243
if(ZMQ_HAVE_TIPC)
12371244
list(APPEND cxx-sources tipc_address.cpp tipc_connecter.cpp tipc_listener.cpp)
12381245
endif()

Makefile.am

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ src_libzmq_la_SOURCES = \
255255
src/vmci_connecter.hpp \
256256
src/vmci_listener.cpp \
257257
src/vmci_listener.hpp \
258+
src/vsock_address.cpp \
259+
src/vsock_address.hpp \
260+
src/vsock_connecter.cpp \
261+
src/vsock_connecter.hpp \
262+
src/vsock_listener.cpp \
263+
src/vsock_listener.hpp \
258264
src/windows.hpp \
259265
src/wire.hpp \
260266
src/xpub.cpp \
@@ -1047,6 +1053,19 @@ tests_test_reqrep_vmci_CXXFLAGS = @LIBZMQ_VMCI_CXXFLAGS@
10471053

10481054
endif
10491055

1056+
if BUILD_VSOCK
1057+
test_apps += tests/test_pair_vsock tests/test_reqrep_vsock
1058+
1059+
tests_test_pair_vsock_SOURCES = tests/test_pair_vsock.cpp
1060+
tests_test_pair_vsock_LDADD = ${TESTUTIL_LIBS} src/libzmq.la
1061+
tests_test_pair_vsock_CPPFLAGS = ${TESTUTIL_CPPFLAGS}
1062+
1063+
tests_test_reqrep_vsock_SOURCES = tests/test_reqrep_vsock.cpp
1064+
tests_test_reqrep_vsock_LDADD = ${TESTUTIL_LIBS} src/libzmq.la
1065+
tests_test_reqrep_vsock_CPPFLAGS = ${TESTUTIL_CPPFLAGS}
1066+
1067+
endif
1068+
10501069
if ENABLE_DRAFTS
10511070
test_apps += tests/test_poller \
10521071
tests/test_client_server \

builds/cmake/platform.hpp.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#cmakedefine ZMQ_HAVE_OPENPGM
7272
#cmakedefine ZMQ_HAVE_NORM
7373
#cmakedefine ZMQ_HAVE_VMCI
74+
#cmakedefine ZMQ_HAVE_VSOCK
7475

7576
#cmakedefine ZMQ_MAKE_VALGRIND_HAPPY
7677

configure.ac

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,22 @@ AC_RUN_IFELSE(
128128

129129
AC_MSG_RESULT([$libzmq_tipc_support])
130130

131+
132+
# check vsock support
133+
AC_MSG_CHECKING([if vsock is available ])
134+
135+
AC_CHECK_HEADERS([linux/vm_sockets.h],
136+
[libzmq_vsock_support=yes],
137+
[libzmq_vsock_support=no],
138+
[
139+
#include <sys/socket.h>
140+
#include <linux/vm_sockets.h>
141+
]
142+
)
143+
AC_MSG_RESULT([$libzmq_vsock_support])
144+
145+
146+
131147
AC_ARG_ENABLE([pedantic],
132148
[AS_HELP_STRING([--disable-pedantic], [disable pedantic compiler checks [default=enabled]])],
133149
[libzmq_pedantic=$enableval], [libzmq_pedantic=yes])
@@ -235,6 +251,10 @@ case "${host_os}" in
235251
if test "x$libzmq_tipc_support" = "xyes"; then
236252
AC_DEFINE(ZMQ_HAVE_TIPC, 1, [Have TIPC support])
237253
fi
254+
255+
if test "x$libzmq_vsock_support" = "xyes"; then
256+
AC_DEFINE(ZMQ_HAVE_VSOCK, 1, [Have vsock support])
257+
fi
238258
case "${host_os}" in
239259
*android*)
240260
AC_DEFINE(ZMQ_HAVE_ANDROID, 1, [Have Android OS])
@@ -774,6 +794,7 @@ fi
774794

775795
AM_CONDITIONAL(HAVE_VMCI, test "x$have_vmci_ext" != "xno")
776796

797+
777798
# Set -Wall, -Werror and -pedantic
778799
AC_LANG_PUSH([C++])
779800

@@ -789,6 +810,7 @@ if test "x$libzmq_pedantic" = "xyes"; then
789810
fi
790811
AC_LANG_POP([C++])
791812

813+
AM_CONDITIONAL(BUILD_VSOCK, test "x$libzmq_vsock_support" = "xyes")
792814
AM_CONDITIONAL(BUILD_TIPC, test "x$libzmq_tipc_support" = "xyes")
793815
AM_CONDITIONAL(ON_MINGW, test "x$libzmq_on_mingw" = "xyes")
794816
AM_CONDITIONAL(ON_CYGWIN, test "x$libzmq_on_cygwin" = "xyes")

doc/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MAN3 = \
2626
MAN7 = \
2727
zmq.7 zmq_tcp.7 zmq_pgm.7 zmq_inproc.7 zmq_ipc.7 \
2828
zmq_null.7 zmq_plain.7 zmq_curve.7 zmq_tipc.7 zmq_vmci.7 zmq_udp.7 \
29-
zmq_gssapi.7
29+
zmq_gssapi.7 zmq_vsock.7
3030

3131
# ASCIIDOC_DOC_WITHOUT_INDEX contains all the Asciidoc files checked into the git repo, except for index.adoc
3232
ASCIIDOC_DOC_WITHOUT_INDEX = $(MAN3:%.3=%.adoc) $(MAN7:%.7=%.adoc)

doc/zmq.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,14 @@ Local inter-process communication transport::
165165
Local in-process (inter-thread) communication transport::
166166
* xref:zmq_inproc.adoc[zmq_inproc]
167167

168-
Virtual Machine Communications Interface (VMC) transport::
168+
Virtual Machine Communications Interface (VMCI) transport::
169169
* xref:zmq_vmci.adoc[zmq_vmci]
170170

171171
Unreliable unicast and multicast using UDP::
172172
* xref:zmq_udp.adoc[zmq_udp]
173173

174+
Linux VSOCK (AF_VSCOK) transport::
175+
* xref:zmq_vsock.adoc[zmq_vsock]
174176

175177
Proxies
176178
~~~~~~~

doc/zmq_bind.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ The 'endpoint' is a string consisting of a 'transport'`://` followed by an
2525
'pgm', 'epgm':: reliable multicast transport using PGM, see xref:zmq_pgm.adoc[zmq_pgm]
2626
'vmci':: virtual machine communications interface (VMCI), see xref:zmq_vmci.adoc[zmq_vmci]
2727
'udp':: unreliable unicast and multicast using UDP, see xref:zmq_udp.adoc[zmq_udp]
28+
'vsock':: Linux VSOCK, see xref:zmq_vsock.adoc[zmq_vsock]
2829

2930
Every 0MQ socket type except 'ZMQ_PAIR' and 'ZMQ_CHANNEL' supports one-to-many and many-to-one
3031
semantics. The precise semantics depend on the socket type and are defined in
3132
xref:zmq_socket.adoc[zmq_socket]
3233

33-
The 'ipc', 'tcp', 'vmci' and 'udp' transports accept wildcard addresses: see
34-
xref:zmq_ipc.adoc[zmq_ipc], xref:zmq_tcp.adoc[zmq_tcp], xref:zmq_vmci.adoc[zmq_vmci] and
35-
xref:zmq_udp.adoc[zmq_udp] for details.
34+
The 'ipc', 'tcp', 'vmci', 'udp' and 'vsock' transports accept wildcard addresses: see
35+
xref:zmq_ipc.adoc[zmq_ipc], xref:zmq_tcp.adoc[zmq_tcp], xref:zmq_vmci.adoc[zmq_vmci],
36+
xref:zmq_udp.adoc[zmq_udp] and xref:zmq_vsock.adoc[zmq_vsock] for details.
3637

3738
NOTE: the address syntax may be different for _zmq_bind()_ and _zmq_connect()_
3839
especially for the 'tcp', 'pgm' and 'epgm' transports.

doc/zmq_connect.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The 'endpoint' is a string consisting of a 'transport'`://` followed by an
2525
'pgm', 'epgm':: reliable multicast transport using PGM, see xref:zmq_pgm.adoc[zmq_pgm]
2626
'vmci':: virtual machine communications interface (VMCI), see xref:zmq_vmci.adoc[zmq_vmci]
2727
'udp':: unreliable unicast and multicast using UDP, see xref:zmq_udp.adoc[zmq_udp]
28+
'vsock':: Linux VSOCK, see xref:zmq_vsock.adoc[zmq_vsock]
2829

2930
Every 0MQ socket type except 'ZMQ_PAIR' and 'ZMQ_CHANNEL' supports one-to-many and many-to-one
3031
semantics. The precise semantics depend on the socket type and are defined in

doc/zmq_inproc.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ assert (rc == 0);
7373
* xref:zmq_tcp.adoc[zmq_tcp]
7474
* xref:zmq_pgm.adoc[zmq_pgm]
7575
* xref:zmq_vmci.adoc[zmq_vmci]
76+
* xref:zmq_vsock.adoc[zmq_vsock]
7677
* xref:zmq.adoc[zmq]
7778

7879

0 commit comments

Comments
 (0)