summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMartin Ejdestig <martin.ejdestig@volvocars.com>2020-12-14 01:43:52 +0100
committerGitHub <noreply@github.com>2020-12-14 09:43:52 +0900
commit8f5e3dc0f3134ea2fdaffd13a16464b1a2f2ecd4 (patch)
treecd371956f6098d4d7e9e0937a929e87e5e5f0f71 /doc
parent329ba78deb40558df30aa8731928c9887197d30b (diff)
downloadDLT-daemon-8f5e3dc0f3134ea2fdaffd13a16464b1a2f2ecd4.tar.gz
Add support for logging with VSOCK (#255)
For more information about VSOCK, see "man vsock" ( https://man7.org/linux/man-pages/man7/vsock.7.html ). Makes it possible for processes in a virtual machine to log directly in DLT running on host without setting up a network connection between guest and host. It is also probably more efficient. Have not done any performance measurements (not main reason for patch), but no forwarding is required as when running DLT in a multi-node setup. When building dlt-daemon for host, WITH_DLT_DAEMON_VSOCK_IPC should be enabled for daemon to listen on incoming VSOCK requests. Local communication method between applications and daemon is still determined with DLT_IPC. When building for guest, WITH_DLT_LIB_VSOCK_IPC should be enabled and DLT_IPC will be ignored, which will make libdlt open a VSOCK socket to the deamon for logging messages. VSOCK can be tested without a virtual machine. Since VMADDR_CID_HOST is used by libdlt when connecting, see vsock man page, clients can be run on host to test VSOCK communication. Some modifications has been done to be able to handle logging through FIFO pipe and socket in the same build of dlt-daemon: - dlt_receiver_init/free_unix_socket() is renamed to dlt_receiver_init/free_global_buffer() and used for FIFO as well. Also fixes memory leak since dlt_receiver_free_unix_socket() was used regardless of whether DLT_USE_UNIX_SOCKET was defined or not. - Pass type to dlt_receiver_init() instead of dlt_receiver_receive(). And remove preprocessor conditionals for handling DLT_CONNECTION_APP_MSG in dlt_daemon_process_user_messages(). Also fixes wrong enum type being passed to dlt_receiver_receive() in dlt_client.c (DltClient::mode was used as a DltReceiverType enum but it is a DltClientMode enum). - Add a flag to DltDaemonApplication to indicate whether file descriptor is "owned" by the DltDaemonApplication or not. When dlt_daemon_application_add() is called due to message received on a socket, fd is passed as an argument (app does not own fd). For FIFO, a per application FIFO is opened (app owns the fd). Also fixes so that user handle is reset for both application and all its contexts when resetting any. Prevents fd from being used by accident after it has been closed. dlt_mkdir_recursive() is moved to src/daemon since it is only used in the daemon. Minimizes use of DLT_USE_UNIX_SOCKET_IPC. Other bugfixes: - Call DLT_SEM_FREE() if setting socket to O_NONBLOCK fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). - Close socket if dlt_receiver_init() fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/dlt_design_specification.md29
1 files changed, 21 insertions, 8 deletions
diff --git a/doc/dlt_design_specification.md b/doc/dlt_design_specification.md
index 4642e31..5731cec 100644
--- a/doc/dlt_design_specification.md
+++ b/doc/dlt_design_specification.md
@@ -61,8 +61,8 @@ applications using the DLT user library.
The DLT daemon is a standalone application which is running as the center of
management and this is implemented as a single-thread process. The DLT daemon
communicates with the DLT clients over TCP/IP connections or over a serial line
-with the applications using the DLT user library over named pipes (FIFOs) or
-UNIX_SOCKET based on compile time configuration.
+with the applications using the DLT user library over named pipes (FIFOs),
+UNIX sockets or VSOCK sockets based on compile time configuration.
The message format is specified in the DLT AUTOSAR Standard. More details
concerning the exchanged user messages and their content can be found in
@@ -94,6 +94,8 @@ mode, it uses the syslog daemon for log messages of the DLT daemon application.
- Open DLT output file, if specified
- After phase 1, the daemon initializes the connection handling:
- Delete, create and open its own named FIFO /tmp/dlt or UNIX_SOCKET
+ - If VSOCK support is enabled in the daemon, open, bind and listen to VSOCK
+ socket for incoming application connections.
- Open, bind and listen to TCP socket for incoming connections
- Setup and open serial device, if specified
- Then the daemon enters initialization phase 2:
@@ -126,8 +128,8 @@ and possibly on the serial device, via poll() call.
- Create a new TCP connection
- If the newly created connection is the first TCP connection, send all log
messages already stored in ring buffer to DLT client.
- - Event from incoming named pipe (FIFO) or Unix socket (from DLT user library
- to DLT daemon):
+ - Event from incoming named pipe (FIFO) or UNIX socket and, if enabled, VSOCK
+ socket (from DLT user library to DLT daemon):
- Use dlt receiver to read data
- As long as there are DLT messages available in received data, the handle
user messages type can be found at src/shared/dlt_user_shared_cfg.h
@@ -213,8 +215,8 @@ contains one entry for each context:
- Setup signal handler and atexit handler
- Ignore all pipe signals
- Create and open own named pipe (with the name /tmp/dlt<PID>, where <PID> is the
-process id of the application using the DLT user library) or Unix socket IPC to
-the DLT daemon
+process id of the application using the DLT user library) or UNIX/VSOCK socket IPC
+to the DLT daemon
- Open local file for storage, if specified
- Initialize receiver object
- Start housekeeper thread for receiving messages
@@ -345,7 +347,8 @@ steps are executed:
### Communication between DLT daemon and DLT user library
The communication mechanism (IPC) used between DLT daemon and DLT user library
-are named pipes (FIFOs or UNIX_SOCKETS, based on compile time configuration).
+are named pipes (FIFOs), UNIX sockets or VSOCK sockets, based on compile time
+configuration).
During the startup of the DLT daemon, the DLT daemon creates and opens the IPC
(FIFOs or UNIX_SOCKET) on the configured path called /tmp/dlt. If a DLT user
@@ -379,6 +382,16 @@ itself with the same PID, which is impossible. To solve this problem, the
UNIX_SOCKETS based communication is used. The UNIX_SOCKETS IPC is also supported
in the Non-linux platforms (eg: QNX).
+If the daemon is built with VSOCK socket support, it can also receive log
+messages from processes running in virtual machines. The communication mechanism
+between the daemon and the DLT user library on the host is still FIFOs or UNIX
+sockets. But the DLT user library for the system running in the virtual machine
+can be built to use VSOCK sockets for sending log messages to the daemon. See
+"man vsock" for more information about VSOCK sockets. This is an alternative to
+using a [multinode](dlt_multinode.md) setup for receiving DLT log messages from
+processes in a virtualized environment. No passive daemon(s) are required and it
+works without having a network configured between the guest and the host.
+
### Place of message creation
The following table shows, where the certain types of DLT messages are created.
@@ -746,7 +759,7 @@ The shared directory contains the following files:
| --------- | ----------- |
| dlt_common.c | Common helper functions, such as: Print functions for DLT messages, Functions for handling DLT Ids, Filter functions, DLT message handling functions, Functions for handling DLT files, DLT receiver functions, Log handling, Ringbuffer functions, Setting and checking of storage header |
| dlt_common_cfg.h | Compile time configuration for dlt_common.c |
-| dlt_user_shared.c | Shared functions, required by the DLT daemon and the DLT user library, such as: Setting and checking the user header, Sending DLT messages over named pipes (FIFOs) or UNIX_SOCKET |
+| dlt_user_shared.c | Shared functions, required by the DLT daemon and the DLT user library, such as: Setting and checking the user header, Sending DLT messages over named pipes (FIFOs) or UNIX/VSOCK sockets |
| dlt_user_shared.h | Header file for dlt_user_shared.c |
| dlt_user_shared_cfg.h | Compile time configuration for dlt_user_shared.c |