Version 8 (modified by DJ Lucas, 5 years ago) ( diff )

Update 2019-06-12


There are many different ways of using qemu. Hopefully, people will add notes for what they do.

Use as a server

Details required!

Xorg drivers if using qemu to build an LFS desktop guest

For a guest BLFS system, as of late 2014 there are three choices for the graphics driver:

1. the old cirrus driver, which is in BLFS

This is old, but still available. It is incompatible with KMS (Kernel Mode Setting). If you need to use it, pass '-vga cirrus' on the command line. The maximum resolution is 1024x768. If you use this and wish to use a framebuffer outside of Xorg, pass 'vga=790' on the grub commandline.

2. the vmware driver, which is also in BLFS

For me, this comes up as 1024x768 if the CONFIG_FB and CONFIG_DRM_VMWGFX kernel options are set, or 800x600 if they are not. It supports a large maximum resolution (bigger than my screen). Works ok, but the window gets some coloured pixels when it first starts (ok after a second or two). Again, it needs 'vga=790' if you want a framebuffer outside of Xorg. Invoke qemu with '-vga vmware'.

3. the modesetting driver

This is a recent development and is not yet in BLFS. The functionality has apparently been merged into the xorg server for the 1.17 version. Meanwhile, xf86-video-modesetting-0.9.0 is available alongside the other drivers, and works fine. It requires CONFIG_FB, CONFIG_DRM_BOCHS, and should also use CONFIG_DRM_CIRRUS_QEMU in your kernel config. For me this defaults to 1024x768 and offers modes up to 1600x1200 or 1680x1050. The framebuffer (1024x768 pixels) will come up without needing to be specified (yea! penguin(s)!). Invoke qemu either without specifying the vga (because this is the default), or by specifying '-vga std'.

If the 1024x768 framebuffer console is too small to read, enable the 12x22 font in the kernel, you can optionally use the LatGrkCyr-12x22 font in /etc/sysconfig/console provided you are running a UTF-8 system. On a regular machine, you could specify a smaller screen with e.g. video=800x600 or whatever on the kernel commandline, and everything would be scaled up. But in qemu that just gives you a smaller window until Xorg is active.

the vga driver

Only mentioned so I can say "Use a better driver!" This is Xorg's last-gasp attempt to provide a driver. It works, but for me it appears to provide a 1280x768 window into a 1280x960 screen (or something like that - the log mentioned 1280, I thought it was more like 1024). So, it starts with the top part of the screen, but shows the bottom when you move the mouse down.

other notes on setting up Xorg in a guest

For the mouse, use the evdev driver.

To get other screen sizes, use xrandr. To see which modes are supported you should run 'xrandr' and make a note of both the modes (sizes) and the output (in qemu, there is only one output, but its name varies with different drivers). You can then invoke xrandr with a line like the following (for the modesetting driver), and if you like it you can add it to the .xinitrc.

xrandr --output Virtual-0 --mode 1280x960

Integrating with KVM and SPICE

Please note that these instructions are preliminary. The following packages need to be added in addition to those listed currently in BLFS:


There are no additional dependencies for lz4.

wget &&
tar -xf lz4-1.9.1.tar.gz &&
cd lz4-1.9.1 &&
make -C lib PREFIX=/usr &&
make -C programs PREFIX=/usr lz4 lz4c &&
sudo make install PREFIX=/usr MANDIR=/usr/share/man/man1


Usbredir depends only on libusb.

wget &&
tar -xf usbredir-0.8.0.tar.bz2 &&
cd usbredir-0.8.0 &&
./configure --prefix=/usr &&
make &&
sudo make install

celt-0.5.1 (this version specifically does not interfere with newer versions)

Celt-0.5.1 depends on libogg.

wget &&
tar -xf celt- &&
cd celt- &&
./configure --prefix=/usr &&
make &&
sudo make install


No additional dependencies.

wget &&
tar -xf spice-protocol-0.14.0.tar.bz2 &&
cd spice-protocol-0.14.0 &&
./configure --prefix=/usr &&
make &&
sudo make install


No additional dependencies.

git clone git:// &&
cd orc &&
mkdir build &&
cd build &&
meson --prefix=/usr .. &&
ninja &&
sudo ninja install


Depends on celt-0.5.1, cyrus-sasl, glib2, gtk2, gst-libav, libjpeg, lz4, openssl, opus, orc, pixman, and python2. Optional dependencies are libvpx, valgrind, and x264.

wget &&
tar -xf spice-0.14.1.tar.bz2 &&
cd spice-0.14.1 &&
./configure --prefix=/usr --disable-static --enable-client --disable-werror --enable-celt051 &&
# --enable-smartcard
make &&
sudo make install


Depends on Cyrus-SASL, DBUS, gst-libav, gtk+-3.x, lz4, PulseAudio, and spice-server. Optionally depends on usbredir for usb redirection to host.

wget &&
tar -xf spice-gtk-0.36.tar.bz2 &&
cd spice-gtk-0.36 &&
./configure --prefix=/usr --enable-celt051 &&
make &&
sudo make install


This is needed on the guest, not the host, however, xspice can be built on any real host as well to allow remote control. This should generally perform better than VNC or XFWD, and in some cases, better than NX server. Instructions for use on real hardware will be added at a later time. Depends on spice-protocols and xorg-server.

wget &&
tar -xf xf86-video-qxl-0.1.5.tar.bz2 &&
cd xf86-video-qxl-0.1.5 &&
./configure $XORG_CONFIG &&
# --enable-xspice=yes (use if you want to use spice as a remote control application on the host)
make &&
sudo make install


This is needed on your guests (and can be useful on a real host if using spice for remote control of host) Depends on libinput, libpciaccess, and xf86-video-qxl.

wget &&
tar -xf spice-vdagent-0.19.0.tar.bz2 &&
cd spice-vdagent-0.19.0 &&
./configure --prefix=/usr --sysconfdir=/etc --with-init-script=systemd &&
# || --with-init-script=redhat # if using SysV book (but it needs to be modified)
sed 's@-Werror@@g' -i Makefile &&
make &&
sudo make install


Libvirt is a generic interface for managing multiple types of hypervisors.

wget &&
tar -xf libvirt-5.4.0.tar.xz &&
cd libvirt-5.4.0 &&
./configure --prefix=/usr -with-storage-lvm --without-xen \
            --with-udev --without-hal --disable-static \
            --with-init-script=systemd --with-qemu-user=nobody \
            --with-qemu-group=nobody --with-interface &&
# || --with-init-script=none # if using SysV book (will need to create them, look at the systemd services files in:
# tools/, src/remote/, src/logging/, and src/locking/
# --with-netcf --with-storage-iscsi # if you have these available
make &&
sudo make install

Now build qemu as per BLFS instructions, then continue on with virt-manager.


Virt-manager is a PyGTK control interface for libvirt that allows you to create, modify, monitor, and operate your VMs.

Depends on several python modules not in BLFS. For the ones in BLFS, pycairo, pygobject, and pygtk against python2 along with VTE. The others are requests and ipaddrinfo. Also need libosinfo (all to be added later).

wget &&
tar -xf virt-manager-2.1.0.tar.gz &&
cd virt-manager-2.1.0 &&
python build &&
sudo python install --optimize=1


Note: See TracWiki for help on using the wiki.