wiki:qemu

Version 12 (modified by Tim Tassonis, 2 years ago) ( diff )

--

qemu

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

Use as a server

qemu can be built without any graphical environment and run on a server, where the display will be made available by the integrated vnc server.

Building qemu without any graphical environment on a system that has a graphical environment installed seems to be a bit tricky. I was successful with the following commands:

pathremove $XORG_PREFIX/bin             PATH
pathremove $XORG_PREFIX/lib/pkgconfig   PKG_CONFIG_PATH
pathremove $XORG_PREFIX/share/pkgconfig PKG_CONFIG_PATH

pathremove $XORG_PREFIX/lib             LIBRARY_PATH
pathremove $XORG_PREFIX/include         C_INCLUDE_PATH
pathremove $XORG_PREFIX/include         CPLUS_INCLUDE_PATH

export PATH PKG_CONFIG_PATH ACLOCAL LIBRARY_PATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH MANPATH
unset XORG_CONFIG
XORG_PREFIX=/opt/X11

mkdir build
cd build || exit

../configure --prefix=/usr --disable-pa --disable-jack \
             --disable-vte --sysconfdir=/etc --disable-sdl --disable-sdl-image \
             --disable-gtk --enable-vnc --audio-drv-list=alsa  --disable-vnc-sasl --enable-kvm \
             --disable-opengl --target-list="$TARGET_LIST"

make

Note that this probably requires to have xorg installed outside /usr, which I have.

However, you should also be able to run qemu with the display on the integrated vnc server if you have linked against xorg and gtk and whatnot, the most important thing is to build qemu with vnc support, which is achieved by building it with '--enable-vnc --disable-vnc-sasl'.

In order to then run a qemu virutal machine on a server and connect to its display on a client, you will only need vncviewer on the client.

Vnc ports usually start at 5900, so when you define your vnc port for your virtual machine, qemu adds 5900 to it for the real port number.

The following will work:

#
# start the qemu vm with vnc display on the server
# 
QEMU_LOG_FILE=/tmp/myvm.log
QEMU_SERVER_VNC_ADDR=192.168.219.5
QEMU_SERVER_VNC_PORT=1

nohup /usr/bin/qemu $ALL_YOUR_USUAL_QEMU_OPTIONS_FOR_THIS_VM -vnc $QEMU_SERVER_VNC_ADDR:$QEMU_SERVER_VNC_PORT > $QEMU_LOG_FILE 2>&1 &

qemu will then make the display of the vm available on 192.168.219.5:5901

So, on your client desktop, you can then connect to it by:

vncviewer 192.168.219.5:5901

Xorg drivers if using qemu to build an LFS desktop guest

For a plain guest BLFS x86 or x86_64 system running Xorg without spice there are two choices for the graphics driver:

1. the modesetting driver

This is now part of Xorg-server, provided you enabled libepoxy.

It requires CONFIG_FB, CONFIG_DRM_BOCHS, and you should also use CONFIG_DRM_VGEM in your kernel config to speed up video output (e.g. when listing files). For me this defaults to a 1024x768 framebuffer, but offers modes which will depend on your machine. Although you can force this with '-vga std' that is now the default.

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.

2. the vmware driver, which is in BLFS

This is only really relevant if you are using vmware. When last reviewed (2014!), this came up as 1024x768 if the CONFIG_FB and CONFIG_DRM_VMWGFX kernel options were set, or 800x600 if they were not. It supported a large maximum resolution (bigger than my screen). I have no recent experience of this.

other notes on setting up Xorg in a guest

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. 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 -s 1280x960

HOWEVER, in some circumstances (e.g. using icewm as the wm in the guest, and with xscreensaver running on the host machine), from time to time the desktop of the guest can be mostly black when you return to it. The reason for this is not understood, but for icewm right clicking on what should be an empty area of the desktop (if you have one), selecting the 'logout' menu entry and clicking on the triangle at its right end, then selecting 'restart icewm' will restore the desktop.

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.9.1/lz4-1.9.1.tar.gz &&
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

Usbredir depends only on libusb.

wget http://www.spice-space.org/download/usbredir/usbredir-0.8.0.tar.bz2 &&
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 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

spice-protocol

No additional dependencies.

wget https://gitlab.freedesktop.org/spice/spice-protocol/uploads/f18acfa4a10482062b3f3484bddeb9fa/spice-protocol-0.14.0.tar.bz2 &&
tar -xf spice-protocol-0.14.0.tar.bz2 &&
cd spice-protocol-0.14.0 &&
./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 libvpx, valgrind, and x264.

wget https://www.spice-space.org/download/releases/spice-server/spice-0.14.1.tar.bz2 &&
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

spice-gtk

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 https://www.spice-space.org/download/gtk/spice-gtk-0.36.tar.bz2 &&
tar -xf spice-gtk-0.36.tar.bz2 &&
cd spice-gtk-0.36 &&
./configure --prefix=/usr --enable-celt051 &&
make &&
sudo make install

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)
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.19.0.tar.bz2 &&
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

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

wget https://libvirt.org/sources/libvirt-5.4.0.tar.xz &&
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/libvirt-guests.service.in, src/remote/libvirtd.service.in, src/logging/virtlogd.service.in, and src/locking/virtlockd.service.in
# --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-2.1.0.tar.gz &&
tar -xf virt-manager-2.1.0.tar.gz &&
cd virt-manager-2.1.0 &&
python setup.py build &&
sudo python setup.py install --optimize=1

Up
Top

Note: See TracWiki for help on using the wiki.