wiki:qemu

Version 3 (modified by DJ Lucas, 4 years ago) ( diff )

Add outline for libvirt, spice, and virt-manager

qemu

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:

lz4

There are no additional dependencies for lz4.

wget https://www.github.com/lz4/lz4/archive/v1.8.0/lz4-1.8.0.tar.gz &&
tar -xf lz4-1.8.0 &&
cd lz4-1.8.0 &&
make -C lib PREFIX=/usr &&
make -C programs PREFIX=/usr lz4 lz4c &&
sudo make instal PREFIX=/usr MANDIR=/usr/share/man/man1

usbredir

Usbredir depends only on libusb.

wget http://www.spice-space.org/download/usbredir/usbredir-0.7.1.tar.bz2 &&
wget http://www.linuxfromscratch.org/~dj/Spice/usbredir-0.7.1-gcc-1.patch &&
tar -xf usbredir-0.7.1.tar.bz2
patch -Np1 -i ../usbredir-0.7.1-gcc-1.patch &&
./configure --prefix=/usr &&
make &&
sudo make install &&
sudo rm -vf /usr/lib/libusbredir{host,parser}.la

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

Celt-0.5.1 depends on libogg.

wget https://downloads.us.xiph.org/releases/celt/celt-0.5.1.3.tar.gz &&
tar -xf celt-0.5.1.3.tar.gz &&
cd celt-0.5.1.3 &&
./configure --prefix=/usr &&
make &&
sudo make install &&
sudo rm -vf /usr/lib/libcelt051.la

libcard

Libcard provides smartcard support and is not strictly necessary.

git clone git://anongit.freedesktop.org/~alon/libcacard &&
cd libcard &&
./autogen.sh &&
make &&
sudo make install

spice-protocol

No additional dependencies.

wget https://www.spice-space.org/download/releases/spice-protocol-0.12.13.tar.bz2 &&
tar -xf spice-protocol-0.12.13.tar.bz2 &&
cd spice-protocol-0.12.13 &&
./configure --prefix=/usr &&
make &&
sudo make install

orc

No additional dependencies.

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

spice-server

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

wget https://www.spice-space.org/download/releases/spice-0.14.0.tar.bz2 &&
tar -xf spice-0.14.0.tar.bz2 &&
cd spice-0.14.0 &&
./configure --prefix=/usr --disable-static --enable-client --disable-werror &&
# --enable-smartcard
make &&
sudo make install &&
sudo rm -vf /usr/lib/libspice-server.la

spice-gtk

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

wget https://www.spice-space.org/download/gtk/spice-gtk-0.33.tar.bz2 &&
wget http://www.linuxfromscratch.org/~dj/Spice/spice-gtk-0.33-openssl-1.1.0-1.patch &&
tar -xf spice-gtk-0.33.tar.bz2 &&
cd spice-gtk-0.33 &&
patch -Np1 -i ../spice-gtk-0.33-openssl-1.1.0-1.patch &&
./configure --prefix=/usr &&
make &&
sudo make install &&
sudo rm -vf /usr/lib/libspice-gtk.la

xf86-video-qxl

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 http://xorg.freedesktop.org/releases/individual/driver/xf86-video-qxl-0.1.5.tar.bz2 &&
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)
# --enable-ccid # (for smartcard)
make &&
sudo make install

spice-vdagent

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 https://www.spice-space.org/download/releases/spice-vdagent-0.17.0.tar.bz2 &&
tar -xf spice-vdagent-0.17.0.tar.bz2 &&
cd spice-vdagent-0.17.0 &&
./configure --prefix=/usr --sysconfdir=/etc --with-init-script=systemd &&
# || --with-init-script=redhat # if using SysV book
make &&
sudo make install

libvirt

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

wget https://libvirt.org/sources/libvirt-3.10.0.tar.xz &&
tar -xf libvirt-3.10.0.tar.xz &&
cd libvirt-3.10.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=redhat # if using SysV book
# --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

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 https://virt-manager.org/download/sources/virt-manager/virt-manager-1.4.3.tar.gz &&
tar -xf virt-manager-1.4.3.tar.gz &&
cd virt-manager-1.4.3 &&
python setup.py build &&
python setup.py install --optimize=1

Up
Top

Note: See TracWiki for help on using the wiki.