LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File kvm.spec of Package kvm (Project Virtualization)

# spec file for package kvm
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
# icecream 0

%bcond_without spice

%define package_true_version 1.3.1
%define package_base_version 1.3.1
%define bios_id seabios-261e870
# (this is post v1.7.1 upstream seabios code)
%define pxe_rom_id ipxe-717279a
# (this is post v1.0.0 upstream ipxe code)
%define vgabios_id vgabios-0.6c
# sgabios comes from: http://sgabios.googlecode.com/svn/trunk, Rev 8
%define sgabios_id sgabios

# note that this list doesn't include the ipxe roms since they get handled
# individually and not as a group
%define firmware_files {bios.bin sgabios.bin vgabios.bin vgabios-cirrus.bin vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin optionrom/linuxboot.bin optionrom/multiboot.bin optionrom/kvmvapic.bin}

ExclusiveArch:  %ix86 x86_64 s390x

%ifarch %ix86 x86_64
# choice of building all from source or using provided binary x86 blobs
%define build_fw_from_source 1
%define build_fw_from_source 0

%define using_buildservice 0%{?opensuse_bs}

Name:           kvm
BuildRequires:  SDL-devel
BuildRequires:  alsa
BuildRequires:  alsa-devel
BuildRequires:  glib2-devel
%if 0%{?suse_version} > 1210
BuildRequires:  libgnutls-devel
BuildRequires:  gnutls-devel
BuildRequires:  libaio-devel
BuildRequires:  libattr-devel
BuildRequires:  libcap-devel
BuildRequires:  libcap-ng-devel
BuildRequires:  libcurl-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libpng-devel
BuildRequires:  libpulse-devel
BuildRequires:  ncurses-devel
BuildRequires:  pciutils-devel
BuildRequires:  perl
BuildRequires:  python
BuildRequires:  texinfo
BuildRequires:  xfsprogs-devel
%if 0%{?suse_version} >= 1130
BuildRequires:  brlapi-devel
%ifarch %ix86 x86_64
%if %{build_fw_from_source}
# needed for building vgabios:
BuildRequires:  bin86
%ifarch x86_64
#needed by bcc compiler which is needed for building vgabios:
BuildRequires:  glibc-32bit
%if 0%{?suse_version} > 1110
BuildRequires:  acpica
BuildRequires:  pmtools
BuildRequires:  libvdeplug3-devel
%if %{with spice}
# Spice support requires pixman > 0.17, which does not included in older suse versions
%if 0%{?suse_version} >= 1130
BuildRequires:  libspice-server-devel
BuildRequires:  spice-protocol-devel
%if 0%{?suse_version} >= 1220
BuildRequires:  usbredir-devel >= 0.3.4
BuildRequires:  pwdutils
Requires:       pwdutils
Requires:       python-curses
%if 0%{?suse_version} < 1110
Requires:       kvm-kmp
Recommends:     qemu-tools
Recommends:     virt-utils
Summary:        Kernel-based Virtual Machine
License:        BSD-3-Clause and GPL-2.0 and GPL-2.0+ and LGPL-2.1+ and MIT
Group:          System/Kernel
Url:            http://www.linux-kvm.org
Version:        %{package_true_version}
Release:        0
Source0:        qemu-%{package_true_version}.tar.bz2
Source1:        60-kvm.rules
Source2:        qemu-ifup
Source3:        kvm-supported.txt
Source4:        win-virtio-drivers.iso
Source5:        win-virtio-drivers-src.tar.bz2
Source6:        %{bios_id}.tar.bz2
Source7:        %{pxe_rom_id}.tar.bz2
Source8:        bcc-0.16.17-2.i486.rpm
Source9:        %{vgabios_id}.tar.bz2
Source10:       %{sgabios_id}.tar.bz2

# ipxe patches
Patch01:        ipxe-rom-settings.patch
Patch02:        ipxe-avoid-bad-array-reference.patch

# seabios patches
Patch20:        seabios-sanitize-version.patch
Patch21:        seabios-reformat-lst-in-case-it-is-generated-by-new-iasl.patch

# vgabios patches
Patch40:        vgabios-bcc-paths.patch

# common and X86 patches
# qemu-kvm patches
Patch60:        qemu-datadir.diff
Patch61:        kvm-qemu-default-memsize.patch
Patch62:        kvm-qemu-madvise-DONTFORK-for-tight-memory-migration.patch
Patch63:        kvm-qemu-avoid-deprecated-gnutls-types.patch
Patch64:        kvm-qemu-provide-__u64-for-broken-sys-capability-h.patch
Patch65:        kvm-glibc217.patch
Patch66:        kvm-qemu-avoid-redunant-declaration-error.patch
Patch67:        kvm-qemu-enable-kvm-acceleration.patch
Patch68:        kvm-qemu-make-rtl8139-default-nic.patch

# Post-release upstream patches
Patch100:       kvm-qemu-preXX-dictzip1.patch
Patch101:       kvm-qemu-preXX-dictzip2.patch
Patch102:       kvm-qemu-preXX-dictzip3.patch
Patch103:       kvm-qemu-preXX-report-default-mac-used.patch
Patch104:       kvm-qemu-preXX-console.patch
Patch105:       kvm-qemu-preXX-serial-retry-revert.patch

Patch200:       kvm-studio-slirp-nooutgoing.patch
Patch201:       kvm-studio-vnc.patch

# for S390
Patch700:       S390-qemu-early-printk.patch
Patch701:       S390-0003-Make-char-muxer-more-robust-wrt-small-FIFOs.patch

# For upstream patches:

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(pre):  /usr/sbin/groupadd

KVM (Kernel-based Virtual Machine) is virtualization software for
Linux. It is based on the hardware virtualization extensions provided
by Intel VT and AMD-V technologies. KVM kernel modules provide a
control interface at /dev/kvm which the qemu-kvm user-space program
uses to provide a hybrid emulated and actual hardware environment
sufficent to run various PC operating systems (guests) in unmodified
form, including Linux, Windows, and Mac OS X.

Since qemu-kvm is derived from the qemu processor emulator sources it
also is able to run guests using processor emulation mode, but with the
expected performance impact. Conversely, hardware virtualization
features outside the processor such as iommu and sr-iov are used by KVM
allowing for improved performance.

The seabios, vgabios and ipxe open source projects are also pulled from
to provide the firmware components included.

To increase performance over emulated hardware devices virtio drivers
are supported, and in the case of Windows, included.

KVM is compatible with various VM management solutions, including
libvirt, virt-manager and vm-install.

    Avi Kivity   <avi@qumranet.com>
    Yaniv Kamay  <yaniv@qumranet.com>
    Dor Laor     <dor.laor@qumranet.com>

%if %{build_fw_from_source}
mkdir bcc-bits
cd bcc-bits/
rpm2cpio %{SOURCE8} | cpio -id ./usr/bin/bcc ./usr/lib/bcc/bcc-cc1
%setup -q -T -D -n %{pxe_rom_id} -b 7
# ipxe patches
%patch01 -p1
%patch02 -p1
%setup -q -n qemu-%{package_true_version} -a 6 -a 9 -a 10
%if %{build_fw_from_source}
#ensure that we only end up with the ones we built
for i in %firmware_files
  rm -f pc-bios/$i
# seabios patches
%patch20 -p1
%patch21 -p1

# vgabios patches
%patch40 -p1

# convert qemu into qemu-kvm patches
# qemu-kvm patches
%patch60 -p1
%patch61 -p1
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch68 -p1

# Post-release patches
%patch100 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1

# Studio addons
%patch200 -p1
%patch201 -p1

# S390 support
%patch700 -p1
%patch701 -p1

cp %{SOURCE3} .

# change from devel version to actual version
echo "%{package_base_version}" > VERSION
echo "kvm-%{version}-%{release}" > KVM_VERSION
./configure \
        --prefix=%{_prefix} \
        --sysconfdir=%{_sysconfdir} \
        --libexecdir=%{_libexecdir} \
        --with-confsuffix=/qemu-kvm \
        --with-pkgversion="kvm-%{version}-%{release}" \
        --extra-cflags="%{optflags}" \
        --disable-debug-tcg \
        --disable-sparse \
        --disable-strip \
        --enable-werror \
        --enable-sdl \
%if 0%{?suse_version} >= 1100
        --audio-drv-list="pa alsa sdl oss" \
        --audio-drv-list="alsa sdl oss" \
        --audio-card-list="ac97 adlib cs4231a gus sb16 hda" \
%ifarch s390x
        --target-list="s390x-softmmu" \
        --target-list="x86_64-softmmu" \
        --disable-xen \
        --enable-vnc-tls \
        --disable-vnc-sasl \
        --enable-vnc-jpeg \
        --enable-vnc-png \
        --enable-curses \
        --enable-curl \
        --disable-fdt \
        --disable-bluez \
        --enable-kvm \
        --disable-user \
        --enable-vde \
        --enable-virtfs \
        --enable-cap-ng \
%if %{build_fw_from_source}
        --disable-blobs \
        --enable-docs \
%if 0%{?suse_version} == 1120
        --disable-linux-aio \
        --enable-linux-aio \
%if 0%{?suse_version} >= 1130
        --enable-brlapi \
%if %{with spice}
        --disable-brlapi \

sed -i 's/CFLAGS  =/CFLAGS  +=/' roms/vgabios/Makefile
# userspace:
make %{?_smp_mflags}

# Firmware
%ifarch %ix86 x86_64
%if %{build_fw_from_source}
echo "%{bios_id}" > roms/seabios/.version
make -C roms/seabios %{?_smp_mflags}
cp roms/seabios/out/bios.bin pc-bios/bios.bin

make -C roms/sgabios
cp roms/sgabios/sgabios.bin pc-bios/sgabios.bin

make -C roms/vgabios %{?_smp_mflags}
cp roms/vgabios/VGABIOS-lgpl-latest.bin pc-bios/vgabios.bin
cp roms/vgabios/VGABIOS-lgpl-latest.cirrus.bin pc-bios/vgabios-cirrus.bin
cp roms/vgabios/VGABIOS-lgpl-latest.stdvga.bin pc-bios/vgabios-stdvga.bin
cp roms/vgabios/VGABIOS-lgpl-latest.vmware.bin pc-bios/vgabios-vmware.bin
cp roms/vgabios/VGABIOS-lgpl-latest.qxl.bin pc-bios/vgabios-qxl.bin
cd ../%{pxe_rom_id}/src
# work around bogus aliasing warning in 32 bit v4.3 gcc compiler
%if 0%{?suse_version} == 1110
%ifarch %ix86
make NO_WERROR=1 bin/byteswap_test.o %{?_smp_mflags}
make bin/blib.a %{?_smp_mflags}
make bin/8086100e.rom %{?_smp_mflags}
make bin/10222000.rom %{?_smp_mflags}
make bin/10500940.rom %{?_smp_mflags}
make bin/10ec8139.rom %{?_smp_mflags}
make bin/80861209.rom %{?_smp_mflags}
make bin/1af41000.rom %{?_smp_mflags}

make install DESTDIR=%{buildroot} %{?_smp_mflags}
mkdir -p %{buildroot}%{_docdir}/kvm
cp qemu-doc.html qemu-kvm.html
cp qemu-tech.html qemu-kvm-tech.html
cp QMP/qmp-commands.txt qmp-commands.txt
install -m 755 scripts/kvm/kvm_stat %{buildroot}%{_bindir}/
%if %{build_fw_from_source}
for i in %firmware_files
  install -m 644 pc-bios/$i %{buildroot}%{_datadir}/qemu-kvm/
install_rom() {
  install -m 644 $1.rom %{buildroot}%{_datadir}/qemu-kvm/$2.rom
cd ../%{pxe_rom_id}/src/bin/
install_rom 8086100e pxe-e1000
install_rom 10222000 pxe-pcnet
install_rom 10500940 pxe-ne2k_pci
install_rom 10ec8139 pxe-rtl8139
install_rom 80861209 pxe-eepro100
install_rom 1af41000 pxe-virtio
cd %{buildroot}
rm .%_bindir/{qemu-img,qemu-io,qemu-ga,qemu-nbd,virtfs-proxy-helper}
rm -r .{%_libexecdir/qemu-bridge-helper,%_datadir/doc/qemu}
%if !%{build_fw_from_source}
rm .%_datadir/qemu-kvm/{openbios-sparc32,openbios-sparc64,ppc_rom.bin,openbios-ppc,bamboo.dtb,petalogix-ml605.dtb,petalogix-s3adsp1800.dtb}
%ifarch s390x
rm .%_datadir/qemu-kvm/bios.bin
mv %{buildroot}%{_sysconfdir}/qemu-kvm/target-x86_64.conf \
rm -r .%_mandir/man1/qemu-img.1
rm -r .%_mandir/man1/virtfs-proxy-helper.1
rm -r .%_mandir/man8/qemu-nbd.8
mv .%_bindir/{qemu-system*,qemu-kvm}
mv .%_mandir/man1/{qemu.1,qemu-kvm.1}
chmod 644 .%_mandir/man1/*
install -D -m 644 %{SOURCE1} %{buildroot}/etc/udev/rules.d/60-kvm.rules
install -D -m 755 %{SOURCE2} %{buildroot}/usr/share/qemu-kvm/qemu-ifup
install -D -m 644 %{SOURCE4} %{buildroot}/usr/share/qemu-kvm/win-virtio-drivers.iso

cd ../
rm -rf bcc-bits
rm -rf %{pxe_rom_id}

%{_bindir}/getent group kvm >/dev/null || %{_sbindir}/groupadd -r kvm 2>/dev/null
%{_bindir}/getent group qemu >/dev/null || %{_sbindir}/groupadd -r qemu 2>/dev/null
%{_bindir}/getent passwd qemu >/dev/null || \
  %{_sbindir}/useradd -r -g qemu -G kvm -d / -s /sbin/nologin \
  -c "qemu user" qemu

%doc COPYING COPYING.LIB Changelog README qemu-kvm.html qemu-kvm-tech.html kvm-supported.txt qmp-commands.txt
%attr(755,root,kvm) %{_bindir}/qemu-kvm
%attr(755,root,kvm) %{_bindir}/kvm_stat
%dir %attr(0755,root,kvm) %{_sysconfdir}/qemu-kvm/
%ifarch s390x
%config %attr(644,root,kvm) %{_sysconfdir}/qemu-kvm/target-s390x.conf
%config %attr(644,root,kvm) %{_sysconfdir}/qemu-kvm/target-x86_64.conf
%config %{_sysconfdir}/udev/rules.d/60-kvm.rules