X-Window (or simply X11) client apps currently don't natively support VSOCK connections. However, when X11 client apps are connecting to an X-Window server via the DISPLAY environment variable, most of them use XCB (X protocol C-language Binding) library for actually making connections to the server. Hence, we can modify the library and transparently add the VSOCK support to all your X11 client apps that are linked to the XCB library.

The following GitLab repository shows how the XCB library can be modified to natively support VSOCK. It's based on the official release of the XCB library version 1.14 and only two files are modified (configure.ac and src/xcb_util.c). After compiling the library, you just need to replace your existing libxcb.so.1.1.0 with your newly compiled one. You should also be able to find compiled binaries for x64 and aarch64/arm64 Linux systems in the repository.


After updating your XCB library, don't forget to enable the VSOCK options in X410. X410 currently supports VSOCK connections from Hyper-V virtual machines and WSL2.

EXAMPLE: Replacing 'libxcb.so.1.1.0' in Ubuntu 20.04 / WSL2

Compile or download the new library

If you're downloading a pre-built library from the GitLab page mentioned above, you need to extract it first:

$ tar xzvf libxcb-1.14-vsock-x64.tar.gz

Once extracted, you should be able to find a compiled libxcb.so.1.1.0 in the newly created libxcb-1.14-vsock-x64 directory.

For your information, the compiled binaries available in the aforementioned GitLab repository don't include any debug symbols. Hence you may find the file size for those binaries smaller than the one you built directly from the source codes. For removing debug symbols from your compiled ones, you can use strip command as shown below (you may need to adjust the file path according to your current working directory):

strip --remove-section=.comment --remove-section=.note --strip-unneeded src/.libs/libxcb.so.1.1.0

Find libxcb.so.1.1.0 in your WSL2 distro

If you're using an Intel/AMD Windows system, it should be in /usr/lib/x86_64-linux-gnu directory. For ARM64 Windows systems, look for it in /usr/lib/aarch64-linux-gnu directory.

$ cd /usr/lib/x86_64-linux-gnu
$ ls -al libxcb.*
lrwxrwxrwx 1 root root     15 Jun 21  2018 libxcb.so.1 -> libxcb.so.1.1.0
-rw-r--r-- 1 root root 162232 Jun 21  2018 libxcb.so.1.1.0

Rename the existing libxcb.so.1.1.0 to libxcb.backup.so.1.1.0

In case you want to go back to the original file later, you should rename the existing file instead of completely overwriting it with the new one. You can use any name for the current file, however, we inserted .backup after the main name instead of appending it to the end.

sudo mv libxcb.so.1.1.0 libxcb.backup.so.1.1.0

It seems Ubuntu/WSL2 is recreating some symbolic links whenever it's rebooted and libxcb.so.1 seems to be one of them. For example, if you change the original name, libxcb.so.1.1.0 to libxcb.so.1.1.0.backup, Ubuntu/WSL2 automagically creates a new symbolic link libxcb.so.1 that points to libxcb.so.1.1.0.backup when you restart Windows or WSL2. Renaming it to libxcb.backup.so.1.1.0 should prevent such problems from happening.

Copy your new libxcb.so.1.1.0 to the directory found in Step 2

sudo cp ~/libxcb-1.14-vsock-x64/libxcb.so.1.1.0 /usr/lib/x86_64-linux-gnu/.

Once you have the new libxcb.so.1.1.0 installed, you can simply set the DISPLAY environment variable in the following format:

export DISPLAY=vsock/[<VMADDR_CID>]:<display_number>[.<screen_number>]

For example, when you have X410 and WSL2 running in the same Windows computer, you can just set the DISPLAY environment variable as the following and have your X11 client apps (ex. GNU Octave) render their graphical output on X410:

export DISPLAY=vsock/2:0.0

It can also be shortened as the following:

export DISPLAY=vsock/:0

2 is the assigned number for VMADDR_CID_HOST and it's used as a default value when it's not found in the DISPLAY environment variable. For a port number, it can be any 'unsigned int', but in order to maintain consistency, it's defined the same as the TCP connection method: 6000 + <display_number>.

Unlike WSL2, if you want to use the new libxcb.so.1.1.0 in Hyper-V virtual machines,
you also need to add entries in Windows registry.

Share This Story, Choose Your Platform!