Add the VMCI transport.

VMCI transport allows fast communication between the Host
and a virtual machine, between virtual machines on the same host,
and within a virtual machine (like IPC).

It requires VMware to be installed on the host and Guest Additions
to be installed on a guest.
This commit is contained in:
Ilya Kulakov
2015-12-07 18:19:45 +06:00
parent 61f74e2dfc
commit 68b13fbddb
40 changed files with 1757 additions and 13 deletions

View File

@@ -52,6 +52,7 @@
#include "ipc_listener.hpp"
#include "tipc_listener.hpp"
#include "tcp_connecter.hpp"
#include "vmci_listener.hpp"
#include "io_thread.hpp"
#include "session_base.hpp"
#include "config.hpp"
@@ -67,6 +68,12 @@
#include "tipc_address.hpp"
#include "mailbox.hpp"
#include "mailbox_safe.hpp"
#if defined ZMQ_HAVE_VMCI
#include "vmci_address.hpp"
#include "vmci_listener.hpp"
#endif
#ifdef ZMQ_HAVE_OPENPGM
#include "pgm_socket.hpp"
#endif
@@ -244,7 +251,8 @@ int zmq::socket_base_t::check_protocol (const std::string &protocol_)
&& protocol_ != "pgm"
&& protocol_ != "epgm"
&& protocol_ != "tipc"
&& protocol_ != "norm") {
&& protocol_ != "norm"
&& protocol_ != "vmci") {
errno = EPROTONOSUPPORT;
return -1;
}
@@ -281,6 +289,13 @@ int zmq::socket_base_t::check_protocol (const std::string &protocol_)
}
#endif
#if !defined ZMQ_HAVE_VMCI
if (protocol_ == "vmci") {
errno = EPROTONOSUPPORT;
return -1;
}
#endif
// Check whether socket type and transport protocol match.
// Specifically, multicast protocols can't be combined with
// bi-directional messaging patterns (socket types).
@@ -595,6 +610,27 @@ int zmq::socket_base_t::bind (const char *addr_)
return 0;
}
#endif
#if defined ZMQ_HAVE_VMCI
if (protocol == "vmci") {
vmci_listener_t *listener = new (std::nothrow) vmci_listener_t (
io_thread, this, options);
alloc_assert (listener);
int rc = listener->set_address (address.c_str ());
if (rc != 0) {
LIBZMQ_DELETE(listener);
event_bind_failed (address, zmq_errno ());
EXIT_MUTEX();
return -1;
}
listener->get_address (last_endpoint);
add_endpoint (last_endpoint.c_str(), (own_t *) listener, NULL);
options.connected = true;
EXIT_MUTEX();
return 0;
}
#endif
EXIT_MUTEX();
zmq_assert (false);
@@ -753,7 +789,7 @@ int zmq::socket_base_t::connect (const char *addr_)
return -1;
}
address_t *paddr = new (std::nothrow) address_t (protocol, address);
address_t *paddr = new (std::nothrow) address_t (protocol, address, this->get_ctx ());
alloc_assert (paddr);
// Resolve address (if needed by the protocol)
@@ -838,6 +874,19 @@ int zmq::socket_base_t::connect (const char *addr_)
}
}
#endif
#if defined ZMQ_HAVE_VMCI
else
if (protocol == "vmci") {
paddr->resolved.vmci_addr = new (std::nothrow) vmci_address_t (this->get_ctx ());
alloc_assert (paddr->resolved.vmci_addr);
int rc = paddr->resolved.vmci_addr->resolve (address.c_str ());
if (rc != 0) {
LIBZMQ_DELETE(paddr);
EXIT_MUTEX();
return -1;
}
}
#endif
// Create session.
session_base_t *session = session_base_t::create (io_thread, true, this,