Framework architecture

Updated: April 19, 2023

The Virtual Socket framework allows the hypervisor host and guests to exchange data using standard socket API calls.

Note:

This chapter assumes you understand the concepts presented in the following documentation:

The framework defines a virtual device (vdev) that implements section 5.10 (“Socket Device”) of the VirtIO 1.1 specification, which is available from oasis-open.org. At the time of this writing, the latest Android and Linux kernel versions have based their own virtual socket drivers on this specification.

Socket sharing

The hypervisor host manages all interactions between guests and USB devices.

There are two main components: a driver, io-vsock, that runs in the host and controls access to the virtual socket, and the virtual socket device, vdev-virtio-vsock, that runs in qvm processes and moves data between guests and the host. The io-vsock driver also runs in QNX Neutrino guests (but not other types of guests).


Architectural diagram showing how io-vsock and vdev-virtio-vsock interact with host and guest applications to provide socket communication
Figure 1. Virtual socket architecture

Communication over the virtual socket is similar to communication over TCP/IP. An application developer can select any valid port number for other applications to communicate with it through the virtual socket, and then issue standard socket API (i.e., libsock) calls to exchange data with other applications in the host or another guest.

To send data, an application must know the port number and Computer ID (CID) of the receiving application. The host uses a fixed CID of 2; guests use the CID assigned to them in the configuration file for the VM in which they run. The CID is specified in the command that loads the device, as described in the vdev virtio-vsock reference.

The libsock library (which is not shown in the diagram) directs calls involving virtual sockets to the /dev/socket/40 device path, which is managed by the virtual socket driver. (Here, 40 represents the virtual socket family.) In a guest, the driver talks to the virtual device (vdev-virtio-vsock) to send data to or receive data from the /dev/vsock/cid device path in the host filesystem. In the host, the driver (io-vsock) interacts directly with /dev/vsock/cid.

Note: For more information on device sharing in the QNX Hypervisor, see the section on “Devices” in the “Understanding QNX Virtual Environments” chapter of the QNX Hypervisor User's Guide.