Building qemu & libvirt from scratch...

Posted on Tue 04 December 2012 in Linux • 2 min read

Pre-requirements

git clone git://git.qemu.org/qemu.git
git clone git://github.com/sahlberg/libiscsi.git
http://libvirt.org/sources/libvirt-1.0.0.tar.gz (4/12/12)
aptitude install libvdeplug2 libvdeplug2-dev libaio1 libaio-dev libcap-dev libattr1-dev libsdl-dev libxml2-dev

Building

libiscsi:

./autogen.sh
./configure
make && make install

qemu:

./configure --enable-kvm --enable-vde --enable-virtfs --enable-linux-aio --enable-libiscsi --enable-sdl --target-list=i386-softmmu,x86_64-softmmu,i386-linux-user,x86_64-linux-user --audio-drv-list=alsa
make && make install

libvirt:

(maybe you should build libvirt with python \< v3.2)

./configure
[...]
configure: Drivers
configure: 
configure:       Xen: no
configure:      QEMU: yes
configure:       UML: yes
configure:    OpenVZ: yes
configure:    VMware: yes
configure:      VBox: yes
configure:    XenAPI: no
configure:  xenlight: no
configure:       LXC: yes
configure:      PHYP: yes
configure:       ESX: yes
configure:   Hyper-V: no
configure: Parallels: yes
configure:      Test: yes
configure:    Remote: yes
configure:   Network: yes
configure:  Libvirtd: yes
configure: Interface: yes
configure:   macvtap: yes
configure:  virtport: yes
[...]
configure: Storage Drivers
configure: 
configure:      Dir: yes
configure:       FS: yes
configure:    NetFS: yes
configure:      LVM: yes
configure:    iSCSI: yes
configure:     SCSI: yes
configure:    mpath: yes
configure:     Disk: no
configure:      RBD: no
configure: Sheepdog: no
[...]
configure: Libraries
configure: 
configure:   libxml: -I/usr/include/libxml2   -lxml2  
configure:   dlopen: -ldl
configure:  libcurl: -DCURL_DISABLE_TYPECHECK   -lcurl  
configure: openwsman: no
configure:  libssh2:   -lssh2  
configure:   gnutls: -I/usr/include/p11-kit-1   -lgnutls   -lgcrypt
configure:     sasl:   -lsasl2
configure:     yajl:   -lyajl
configure:  sanlock: no
configure: firewalld: yes
configure:    avahi: no
configure:   polkit: /usr/bin/pkcheck (version 1)
configure:    audit: no
configure:  selinux: no
configure: apparmor: no
configure:  numactl: no
configure:    capng:  -lcap-ng
configure:      xen: no
configure:   xenapi: no
configure: xenlight: no
configure:      hal: no
configure:     udev:   -ludev -lrt     -lpciaccess  
configure:    netcf: no
configure:     pcap: -I/usr/include -L/usr/lib64 -Wl,-rpath,/usr/lib64 -lpcap
configure:       nl: -I/usr/include/libnl3   -I/usr/include/libnl3   -lnl-3   -lnl-route-3 -lnl-3  
configure:    mscom: no
configure:      xdr: 
configure:      rbd: no
[...]
make && make install

If you getting errors like this one

make[3]: Entering directory `/home/rmichel/src/libvirt-1.0.0/python'
  GEN    generator.py.stamp
  File "./generator.py", line 21
    print "test"
               ^
SyntaxError: invalid syntax
make[3]: *** [generator.py.stamp] Error 1

you are using python 3.2.x (or newer) and should switch back to python 2.7.x!

The problem is the 'print' function. In python 2.7.x the syntax is print "foobar" but in 3.x that's not valid anymore! Instead you should be use print("foobar") (which is also valid in 2.7.x) !!

Examples

libiscsi:

qemu [...] -drive file=iscsi://10.1.1.1/iqn.storage.test/1,if=scsi,bus=0,unit=3

vde:

vde_switch -s /tmp/vdesock1 &
qemu [...] -net nic -net vde,vlan=0,sock=/tmp/vdesock1

linux-aio:
"QEMU has two asynchronous I/O mechanisms: POSIX AIO emulation using a pool of worker threads and native Linux AIO."

qemu [...] -drive file=foo.img,aio=[threads|native]