Xvfb

Xvfb
Type Display server
Website www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml

Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol. In contrast to other display servers, Xvfb performs all graphical operations in memory without showing any screen output. From the point of view of the client, it acts exactly like any other X display server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to have a screen or any input device. Only a network layer is necessary.

An alternative to Xvfb is Xdummy. While Xvfb is a standalone X server which emulates a dumb framebuffer using virtual memory,[1] Xdummy is simply a script which uses an LD_PRELOAD hack to run a stock X server with the "dummy" video driver.[2]

Usage scenarios

Xvfb is primarily used for testing:

  1. Since it shares code with the real X server, it can be used to test the parts of the code that are not related to the specific hardware.
  2. It can be used to test clients in various conditions that would otherwise require a range of different hardware; for example, it can be used to test whether clients work correctly at depths or screen sizes that are rarely supported by hardware.
  3. Background running of clients. (the xwd program or a similar program for capturing a screenshot can be used to actually see the result)
  4. Running programs that require an X server to be active even when they do not use it. (e.g. Clover html reports)

Usage examples

Screenshot example

As an example, the following sequence of commands runs the virtual framebuffer as display ":1", runs a program on it, and captures the virtual screen in the file image.png using the import command of ImageMagick:

Xvfb :1 &
xv -display :1 &
import -display :1 -window root image.png

The result can be shown by running display image.png or xv image.png. The script xvfb-run is often used to automate the process of finding an available display and managing authentication.

xvfb-run command

Remote control over SSH

Xvfb is also used for remote control. VNC over SSH is slightly faster than X11 over SSH. In this case, Xvfb is often combined with a lightweight window manager such as Fluxbox and a VNC server such as X11vnc. A possible sequence of commands to start this on the server is:

export DISPLAY=:1
Xvfb :1 -screen 0 1024x768x16 &
fluxbox &
x11vnc -display :1 -bg -nopw -listen localhost -xkb

The next step is to fire up a SSH client such as PuTTY with tunneling to localhost port 5900 enabled. A vncviewer can then connect to localhost to get remote control over the server.

ssh -N -T -L 5900:localhost:5900 user@remotehost &
vncviewer -encodings 'copyrect tight zrle hextile' localhost:5900

x11vnc's man page also contains instructions.

Xvnc (not to be confused with x11vnc) is very similar to Xvfb.

See also

References

  1. See manpage for Xvfb
  2. Xdummy source code
This article is issued from Wikipedia - version of the 6/23/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.