VMGL brings 3-D effects to VMs

381

Author: Mayank Sharma

Virtualized computing environments can take advantage of built-in virtualization support in modern dual-core processors, but when it comes to 3-D acceleration in virtual machines, almost all fall flat on their faces. VMGL is a little-known application written as part of Google’s Summer of Code 2006 program that lets OpenGL apps running inside a virtual machine take advantage of the graphics hardware acceleration on the host. It has limitations, but if you want 3-D in VMs, VMGL is your best bet.

The closest any virtualization platform has come to offering native 3-D in VMs is the recently released VMware 6.5 which lets you run OpenGL 2.0 apps in Windows XP guests. But it works only with certain ATI and Nvidia graphics, and not with on-board Intel graphics. This is a serious limitation, considering most recent Intel graphics have enough juice to power most shoot-’em-ups and racing simulators that run on Linux distros.

VMGL, on the other hand, works with all ATI, Nvidia, and Intel cards. Basically, if your host can do 3-D, then with VMGL so can your VMs. Another advantage in using VMGL is that it works across virtualization platforms. I’ve tried it on VMs virtualized by VMware and VirtualBox, and it should also work on Xen and KVM too.

VMGL runs apps (and games) that use the OpenGL library. The current version of VMGL supports OpenGL v1.5 with some exceptions that are mentioned in the document included in the source tarball. You can also install VMGL from the available RPMs.

You can run 3-D apps two ways in VMs using VMGL. The recommended method is to run a VMGL-modified VNC server in the VM and connect to it from the host. The second method is available only to VMware users, and because of its closed-source nature is fairly complicated. The VNC-method is easier to set up and works across virtualization platforms.

The easiest way to set up VMGL is by using the two RPMs — one for the host distro and the other for the guest. On Debian-based systems, you can either use alien to convert the RPM file to .deb, or install VMGL from the tarball as documented in the bundled install file. You’ll also need a few libraries (libXaw, libXext, libjpeg, libXmu) as well as their devel packages.

Once the dependencies have been satisfied and the packages installed, you need to tweak the Xorg configuration file on the guest distro to load the vmglext module. Edit the xorg.conf file (usually under /etc/X11) and under the Module section add the line:

Load "vmglext"

Save the file and restart X, then start the custom VNC server installed by VMGL, which if you installed the RPMs means issuing the Xvnc :1 command. If you have multiple VNC servers installed, make sure you are using the one provided by VMGL, which by default installs under /usr/local/bin.

Since the custom VNC server is based on an older release, it expects to find fonts under /usr/X11R6/lib/X11/fonts. You can work around this by either creating a symlink to the location of X11 fonts on your system (usually /usr/share/fonts) or starting Xvnc with the -fp switch followed by the path to the fonts, as in Xvnc -fp /usr/share/fonts/ :1.

Now head back to the host and use the VMGL-modified vncviewer (which by default installs under /usr/local/bin) to connect to the Xvnc server running on the guest. For instance, if the IP address of the guest VM is 192.168.2.55, vncviewer 192.168.2.55:1 will connect to the VM and open a window with a gray background, because the guest is running the Xvnc server without any apps.

Before you can run the apps, take note of the output in the window where you issued the vncviewer command. It’ll say something similar to Set GLSTUB var in guest to point to port 7001. Head to the guest, and in a terminal window issue the command export GLSTUB=192.168.2.55:7001, replacing the IP address with your guest’s address, and the port number with the one prompted by vncviewer.

You should now be all set. Run glxinfo in the guest; it should list vmgl as the glx vendor. Then compare the 3-D rendering speed between the guest and host by running glxgears on both. This isn’t an exact benchmark but it gives you some numbers to compare. If you don’t have glxinfo and glxgears, install the mesa-demos package for your distro.

Looking ahead

If VMGL doesn’t run your favorite 3-D app, don’t expect any quick updates, because the current priority for its author, H. Andrés Lagar-Cavilla, is to get his Ph.D. degree. But he does have some ideas to implement and is currently helping another developer implement Windows compatibility for VMGL, which will enable Windows guests to run 3-D apps on top of a Linux host.

Running 3-D apps via VNC with VMGL may look inconvenient at first, especially when you consider the fact that it currently works only on Linux guests over Linux hosts. But if you want your VMs to be as well equipped, graphically-speaking, as their hosts, there’s no beating VMGL.

Category:

  • Virtualization