File qemu.spec.in of Package qemu

#
# spec file for package qemu
#
# Copyright (c) 2015 SUSE LINUX 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/
#


%ifarch %ix86 x86_64
# choice of building all from source or using provided binary x86 blobs
%if 0%{?suse_version} >= 1140
%define build_x86_fw_from_source 1
%endif
%endif
%ifarch ppc64 ppc64le
%define build_slof_from_source 1
%endif
%ifarch %ix86 x86_64 ppc ppc64 ppc64le s390x %arm aarch64
%define kvm_available 1
%endif
%ifarch %ix86 x86_64 s390x
%define legacy_qemu_kvm 1
%endif
%if 0%{?suse_version} >= 1210
%define with_systemd 1
%endif
%if 0%{?suse_version} > 1110
%define noarch_supported 1
%endif
%ifarch x86_64
%define with_rbd 1
%endif

Name:           qemu
Url:            http://www.qemu.org/
Summary:        Universal CPU emulator
License:        BSD-3-Clause and GPL-2.0 and GPL-2.0+ and LGPL-2.1+ and MIT
Group:          System/Emulators/PC
QEMU_VERSION
Release:        0
Source:         qemu-2.3.1.tar.bz2
Source1:        80-kvm.rules
Source2:        qemu-ifup
Source3:        kvm.conf
Source4:        qemu-kvm.1.gz
Source5:        60-kvm.rules
Source6:        kvm-supported.txt
Source7:        80-qemu-ga.rules
Source8:        qemu-ga.service
Source9:        60-kvm.x86.rules
# Upstream First -- http://wiki.qemu-project.org/Contribute/SubmitAPatch
# This patch queue is auto-generated from https://gitlab.suse.de/virtualization/qemu
PATCH_FILES
# Please do not add QEMU patches manually here.
# Run update_git.sh to regenerate this queue.

# roms/seabios patches (and sea-vgabios)
Patch1000:      seabios_128kb.patch
Patch1001:      seabios_checkrom_typo.patch
Patch1002:      seabios_avoid_smbios_signature_string.patch
Patch1003:      vgabios-Add-config-option-for-assembler-.patch
Patch1004:      vgabios-Emulate-leal-instruction.patch
Patch1005:      seabios-mptable-Don-t-create-mptable-if-.patch
# end roms/seabios patches (and sea-vgabios)

# roms/ipxe patches
Patch1100:      ipxe-prefix-Use-.bss16-as-temporary-stac.patch
Patch1101:      ipxe-zbin-Use-LZMA-compression.patch
Patch1102:      ipxe-zbin-Perform-extra-normalisation-af.patch
Patch1103:      ipxe-zbin-Fix-check-for-existence-of-mos.patch
Patch1104:      ipxe-zbin-Remove-now-unused-unnrv2b.S-de.patch
# end roms/ipxe patches

# roms/SLOF patches
Patch1200:      SLOF_ppc64le.patch
# end roms/SLOF patches

# this is to make lint happy
Source300:      rpmlintrc
Source302:      bridge.conf
Source400:      update_git.sh
ExcludeArch:    s390
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  SDL-devel
BuildRequires:  alsa-devel
BuildRequires:  bluez-devel
%if 0%{?suse_version} >= 1130
BuildRequires:  brlapi-devel
%endif
%if 0%{?with_rbd}
BuildRequires:  ceph-devel
%endif
BuildRequires:  curl-devel
BuildRequires:  cyrus-sasl-devel
%if 0%{?build_x86_fw_from_source}
BuildRequires:  iasl
%endif
BuildRequires:  e2fsprogs-devel
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  glib2-devel
%if 0%{?suse_version} >= 1220
BuildRequires:  gtk3-devel
%else
BuildRequires:  gtk2-devel
%endif
BuildRequires:  libaio
BuildRequires:  libaio-devel
BuildRequires:  libattr-devel
BuildRequires:  libcap-devel
BuildRequires:  libcap-ng-devel
%if 0%{?suse_version} >= 1310
# 12.3 and earlier don't ship a compatible libfdt; use the bundled one there
BuildRequires:  libfdt1-devel
%endif
BuildRequires:  libgnutls-devel
BuildRequires:  libjpeg-devel
%ifarch %ix86 aarch64
%if 0%{?suse_version} > 1320
BuildRequires:  libnuma-devel
%endif
%else
%ifnarch %arm s390x
BuildRequires:  libnuma-devel
%endif
%endif
BuildRequires:  libpcap-devel
BuildRequires:  libpixman-1-0-devel
BuildRequires:  libpng-devel
BuildRequires:  libpulse-devel
BuildRequires:  librdmacm-devel
%ifarch %ix86 x86_64
BuildRequires:  libseccomp-devel
%endif
%if 0%{?suse_version} > 1310
BuildRequires:  libusb-devel
%endif
BuildRequires:  libvdeplug3-devel
%if 0%{?suse_version} > 1220
BuildRequires:  makeinfo
%endif
BuildRequires:  ncurses-devel
BuildRequires:  pwdutils
BuildRequires:  python
%if 0%{?with_systemd}
BuildRequires:  systemd
%endif
%if 0%{?sles_version} != 11
BuildRequires:  usbredir-devel
%endif
%if 0%{?suse_version} >= 1210
%if 0%{?suse_version} >= 1220
BuildRequires:  vte-devel
%else
BuildRequires:  vte2-devel
%endif
%endif
%ifarch x86_64
BuildRequires:  xen-devel
%endif
%if 0%{?build_x86_fw_from_source}
BuildRequires:  xz-devel
%endif
BuildRequires:  zlib-devel
%if 0%{?suse_version} >= 1140
%ifarch %ix86 x86_64
BuildRequires:  libspice-server-devel
BuildRequires:  spice-protocol-devel
%endif
%endif
%if "%{name}" == "qemu-testsuite"
BuildRequires:  bc
BuildRequires:  qemu-arm   = %version
BuildRequires:  qemu-extra = %version
BuildRequires:  qemu-ppc   = %version
BuildRequires:  qemu-s390  = %version
BuildRequires:  qemu-tools = %version
BuildRequires:  qemu-x86   = %version
%endif
%if 0%{?kvm_available}
BuildRequires:  udev
%if %( echo `rpm -q --queryformat %%{version} udev` ) > 190
%define _udevrulesdir /usr/lib/udev/rules.d
%else
%define _udevrulesdir /lib/udev/rules.d
%endif
Recommends:     python-curses
%endif
Requires(pre):  pwdutils
Requires(post): coreutils
%if 0%{?with_systemd}
%ifarch s390x
%{?systemd_requires}
%endif
%endif
Recommends:     qemu-block-curl
%if 0%{?with_rbd}
Recommends:     qemu-block-rbd
%endif
Recommends:     qemu-tools
Recommends:     qemu-x86
%ifarch ppc ppc64 ppc64le
Recommends:     qemu-ppc
%else
Suggests:       qemu-ppc
%endif
%ifarch s390x
Recommends:     qemu-s390
%else
Suggests:       qemu-s390
%endif
%ifarch %arm aarch64
Recommends:     qemu-arm
%else
Suggests:       qemu-arm
%endif
Suggests:       qemu-extra
Suggests:       qemu-lang

%define built_firmware_files {acpi-dsdt.aml bios.bin bios-256k.bin \
q35-acpi-dsdt.aml 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 pxe-e1000.rom pxe-pcnet.rom \
pxe-ne2k_pci.rom pxe-rtl8139.rom pxe-eepro100.rom pxe-virtio.rom}

%description
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

%if "%{name}" != "qemu-testsuite"

%package x86
Summary:        Universal CPU emulator -- x86
Group:          System/Emulators/PC
Requires:       qemu = %version
Requires:       qemu-ipxe
Requires:       qemu-seabios
Requires:       qemu-sgabios
Requires:       qemu-vgabios

%description x86
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package provides i386 and x86_64 emulation.

%package ppc
Summary:        Universal CPU emulator -- Power Architecture
Group:          System/Emulators/PC
Requires:       qemu = %version

%description ppc
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package provides ppc and ppc64 emulation.

%package s390
Summary:        Universal CPU emulator -- S/390
Group:          System/Emulators/PC
Requires:       qemu = %version

%description s390
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package provides s390x emulation.

%package arm
Summary:        Universal CPU emulator -- ARM
Group:          System/Emulators/PC
Requires:       qemu = %version

%description arm
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package provides arm emulation.

%package extra
Summary:        Universal CPU emulator -- extra architectures
Group:          System/Emulators/PC
Requires:       qemu = %version

%description extra
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package provides some lesser used emulations, such as moxie and xtensa.

%package lang
Summary:        Universal CPU emulator -- Translations
Group:          System/Emulators/PC

%description lang
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package contains translations.

%if 0%{?legacy_qemu_kvm}
%package kvm
Url:            http://www.linux-kvm.org
Summary:        Kernel-based Virtual Machine
Group:          System/Emulators/PC
%ifarch %ix86 x86_64
Requires:       qemu-x86 = %version
%endif
%ifarch s390x
Requires:       qemu-s390 = %version
%endif
Provides:       kvm = %version
Obsoletes:      kvm < %version

%description kvm
KVM (Kernel-based Virtual Machine) is virtualization software for Linux.
It is designed to leverage the hardware virtualization features included
with various architectures. QEMU uses KVM for CPU virtualization, while
still providing emulation of other system components. This package is
not required for KVM usage, but rather facilitates its usage with tools
derived from the legacy kvm package.
%endif

%if 0%{?with_rbd}
%package block-rbd
Summary:        Universal CPU emulator -- cURL block support
Group:          System/Emulators/PC
# Needs to match {qemu-system-*,qemu-img} >= 2.0.0, but is optional.
Conflicts:      qemu < %version
Conflicts:      qemu > %version
Conflicts:      qemu-tools < %version
Conflicts:      qemu-tools > %version

%description block-rbd
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package contains a module for accessing ceph (rbd,rados)
image files.
%endif

%package block-curl
Summary:        Universal CPU emulator -- cURL block support
Group:          System/Emulators/PC
Provides:       qemu:%_libdir/%name/block-curl.so
# Needs to match {qemu-system-*,qemu-img} >= 2.0.0, but is optional.
Conflicts:      qemu < %version
Conflicts:      qemu > %version
Conflicts:      qemu-tools < %version
Conflicts:      qemu-tools > %version

%description block-curl
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package contains a module for accessing network-based image files
over a network connection from qemu-img tool and QEMU system emulation.

%package tools
Summary:        Universal CPU emulator -- Tools
Group:          System/Emulators/PC
Provides:       qemu:%_libexecdir/qemu-bridge-helper
Requires(post): permissions
Obsoletes:      virt-utils
Recommends:     qemu-block-curl
%if 0%{?with_rbd}
Recommends:     qemu-block-rbd
%endif

%description tools
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package contains various tools, including a bridge helper.

%package guest-agent
Summary:        Universal CPU emulator -- Guest agent
Group:          System/Emulators/PC
Provides:       qemu:%_bindir/qemu-ga
%if 0%{?with_systemd}
%{?systemd_requires}
%endif

%description guest-agent
QEMU is an extremely well-performing CPU emulator that allows you to
choose between simulating an entire system and running userspace
binaries for different architectures under your native operating
system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
as PC and PowerMac systems.

This sub-package contains the guest agent.

%ifarch %ix86 x86_64
%package seabios
Summary:        X86 BIOS for QEMU
Group:          System/Emulators/PC
SEABIOS_VERSION
Release:        0
%if 0%{?noarch_supported}
BuildArch:      noarch
%endif
Conflicts:      qemu < 1.6.0

%description seabios
SeaBIOS is an open source implementation of a 16bit x86 BIOS. SeaBIOS
is the default BIOS for QEMU.

%package vgabios
Summary:        VGA BIOSes for QEMU
Group:          System/Emulators/PC
Version:        1.8.1
Release:        0
%if 0%{?noarch_supported}
BuildArch:      noarch
%endif
Conflicts:      qemu < 1.6.0

%description vgabios
VGABIOS provides the video ROM BIOSes for the following variants of VGA
emulated devices: Std VGA, QXL, Cirrus CLGD 5446 and VMware emulated
video card.

%package sgabios
Summary:        Serial Graphics Adapter BIOS for QEMU
Group:          System/Emulators/PC
Version:        8
Release:        0
%if 0%{?noarch_supported}
BuildArch:      noarch
%endif
Conflicts:      qemu < 1.6.0

%description sgabios
The Google Serial Graphics Adapter BIOS or SGABIOS provides a means for legacy
x86 software to communicate with an attached serial console as if a video card
were attached.

%package ipxe
Summary:        PXE ROMs for QEMU NICs
Group:          System/Emulators/PC
Version:        1.0.0
Release:        0
%if 0%{?noarch_supported}
BuildArch:      noarch
%endif
Conflicts:      qemu < 1.6.0

%description ipxe
Preboot Execution Environment (PXE) ROM support for various emulated network
adapters available with QEMU.
%endif

%endif # !qemu-testsuite

%prep
%setup -q -n qemu-2.3.1
PATCH_EXEC

%if 0%{?build_x86_fw_from_source}
pushd roms/seabios
%patch1000 -p1
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
%patch1004 -p1
%patch1005 -p1
popd
pushd roms/ipxe
%patch1100 -p1
%patch1101 -p1
%patch1102 -p1
%patch1103 -p1
%patch1104 -p1
popd

# as a safeguard, delete the firmware files that we intend to build
for i in %built_firmware_files
do
  %{__rm} -f pc-bios/$i
done
%endif

%if 0%{?build_slof_from_source}
pushd roms/SLOF
%patch1200 -p1
popd
%{__rm} -f pc-bios/slof.bin
%endif

%build
./configure --prefix=%_prefix --sysconfdir=%_sysconfdir \
	--libdir=%_libdir \
	--libexecdir=%_libexecdir \
	--localstatedir=%_localstatedir \
	--extra-cflags="%{optflags}" \
	--disable-stack-protector \
	--disable-strip \
	--enable-system --disable-linux-user \
	--enable-tools --enable-guest-agent \
	--enable-pie \
	--enable-docs \
	--audio-drv-list="pa alsa sdl oss" \
%if 0%{?suse_version} >= 1130
        --enable-brlapi \
%endif
	--enable-cap-ng \
	--enable-curl \
	--enable-curses \
	--enable-gtk \
%if 0%{?suse_version} >= 1220
	--with-gtkabi=3.0 \
%endif
%if 0%{?kvm_available}
	--enable-kvm \
%endif
%if 0%{?suse_version} > 1310
	--enable-libusb \
%endif
	--enable-linux-aio \
	--enable-modules \
%ifarch %ix86 aarch64
%if 0%{?suse_version} > 1320
	--enable-numa \
%else
	--disable-numa \
%endif
%else
%ifarch %arm s390x
	--disable-numa \
%else
	--enable-numa \
%endif
%endif
%if 0%{?with_rbd}
	--enable-rbd \
%endif
	--enable-rdma \
	--enable-sdl \
	--with-sdlabi=1.2 \
%if 0%{?suse_version} > 1220
%ifarch %ix86 x86_64
	--enable-seccomp \
%endif
%endif
%if 0%{?suse_version} >= 1140
%ifarch %ix86 x86_64
	--enable-spice \
%else
	--disable-spice \
%endif
%else
	--disable-spice \
%endif
	--enable-tpm \
%if 0%{?sles_version} != 11
	--enable-usb-redir \
%endif
	--enable-vde \
	--enable-virtfs \
	--enable-vnc-jpeg \
	--enable-vnc-png \
	--enable-vnc-sasl \
	--enable-vnc-tls \
	--enable-vnc-ws \
%ifarch x86_64
	--enable-xen \
%endif

%if "%{name}" != "qemu-testsuite"

make %{?_smp_mflags} V=1

# Firmware
%if 0%{?build_x86_fw_from_source}
# sizes produced are ok for migration except pxe, which needs help (see below)
make -C roms bios
make -C roms seavgabios
make -C roms sgabios
make -C roms pxerom
# enforce pxe rom sizes for migration compatability from SLE 11 SP3 forward
# the following need to be > 64K
%define supported_nics_large {e1000 rtl8139}
# the following need to be <= 64K
%define supported_nics_small {virtio}
# Though not required, make unsupported pxe roms migration compatable as well
%define unsupported_nics {eepro100 ne2k_pci pcnet}

for i in %supported_nics_large %unsupported_nics
  do
    if test "`stat -c '%s' pc-bios/pxe-$i.rom`" -gt "131072" ; then
    echo "pxe rom is too large"
    exit 1
  fi
  if test "`stat -c '%s' pc-bios/pxe-$i.rom`" -le "65536" ; then
    ./roms/ipxe/src/util/padimg.pl pc-bios/pxe-$i.rom -s 65536 -b 255
    echo -ne "SEGMENT OVERAGE\0" >> pc-bios/pxe-$i.rom
  fi
done
for i in %supported_nics_small
  do
    if test "`stat -c '%s' pc-bios/pxe-$i.rom`" -gt "65536" ; then
    echo "pxe rom is too large"
    exit 1
  fi
done
%endif
%if 0%{?build_slof_from_source}
make -C roms slof
%endif
%ifarch s390x
cp pc-bios/s390-ccw/s390-ccw.img pc-bios/s390-ccw.img
%endif

%else # qemu-testsuite

ln -s %{_bindir}/qemu-img qemu-img

for conf in default-configs/*-softmmu.mak; do
  arch=`echo "$conf" | sed -e 's|default-configs/\(.*\)-softmmu.mak|\1|g'`
  ln -s %{_bindir}/qemu-system-$arch $arch-softmmu/qemu-system-$arch
done

%endif

%check
%if "%{name}" == "qemu-testsuite"
make check-report.html V=1
install -D -m 644 check-report.html %{buildroot}%{_datadir}/qemu/check-report.html
install -D -m 644 check-report.xml %{buildroot}%{_datadir}/qemu/check-report.xml
%endif

%install
%if "%{name}" != "qemu-testsuite"
make install DESTDIR=%{buildroot}
%{__rm} -fr %{buildroot}%{_datadir}/doc
%ifnarch %ix86 x86_64
for f in acpi-dsdt.aml q35-acpi-dsdt.aml bios-256k.bin bios.bin efi-*.rom pxe-*.rom sgabios.bin \
         vgabios-cirrus.bin vgabios-qxl.bin vgabios-stdvga.bin vgabios-vmware.bin vgabios.bin; do
  %{__rm} -f %{buildroot}%{_datadir}/%name/$f
done
%endif
%{__install} -D -m 0644 %{SOURCE302} %{buildroot}%{_sysconfdir}/qemu/bridge.conf
%{__install} -D -m 0755 %{SOURCE2} %{buildroot}%{_datadir}/%name/qemu-ifup
%find_lang %name
%if 0%{?legacy_qemu_kvm}
cat > %{buildroot}%{_bindir}/qemu-kvm << 'EOF'
#!/bin/sh

%ifarch s390x
exec %{_bindir}/qemu-system-s390x -machine accel=kvm "$@"
%else
exec %{_bindir}/qemu-system-x86_64 -machine accel=kvm "$@"
%endif
EOF
chmod 0755 %{buildroot}%{_bindir}/qemu-kvm
%{__install} -D -m 0644 %{SOURCE4} %{buildroot}%{_mandir}/man1/qemu-kvm.1.gz
%{__install} -D -m 0644 %{SOURCE6} %{buildroot}%{_docdir}/qemu-kvm/kvm-supported.txt
%endif
%if 0%{?kvm_available}
%{__install} -D -m 0755 scripts/kvm/kvm_stat %{buildroot}%{_bindir}/kvm_stat
%if 0%{?suse_version} >= 1230
%{__install} -D -m 0644 %{SOURCE1} %{buildroot}%{_udevrulesdir}/80-kvm.rules
%else
%ifarch %ix86 x86_64
%{__install} -D -m 0644 %{SOURCE9} %{buildroot}%{_udevrulesdir}/60-kvm.rules
%else
%{__install} -D -m 0644 %{SOURCE5} %{buildroot}%{_udevrulesdir}/60-kvm.rules
%endif
%endif
%endif
%if 0%{?with_systemd}
%{__install} -D -m 0644 %{SOURCE8} %{buildroot}%{_unitdir}/qemu-ga.service
%{__install} -D -m 0644 %{SOURCE7} %{buildroot}%{_udevrulesdir}/80-qemu-ga.rules
%ifarch s390x
%{__install} -D -m 0644 %{SOURCE3} %{buildroot}%{_libexecdir}/modules-load.d/kvm.conf
%endif
%endif
%fdupes -s %{buildroot}
%endif

%if "%{name}" != "qemu-testsuite"

%pre
%{_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

%if 0%{?kvm_available}
%post
%if 0%{?with_systemd}
%ifarch s390x
if [ -c /dev/kvm ]; then
%{_bindir}/chmod 0666 /dev/kvm
%{_bindir}/chgrp kvm /dev/kvm
fi
%endif
%endif
if [ "$(readlink -f /proc/1/root)" = "/" ]; then
  setfacl --remove-all /dev/kvm &> /dev/null || :
  /sbin/udevadm control --reload-rules  || :
  /sbin/udevadm trigger || :
fi
%endif

%if 0%{?with_systemd}
%pre guest-agent
%service_add_pre qemu-ga.service

%preun guest-agent
%service_del_preun qemu-ga.service

%post guest-agent
if [ "$(readlink -f /proc/1/root)" = "/" ]; then
  /sbin/udevadm control --reload-rules  || :
  /sbin/udevadm trigger || :
fi
%service_add_post qemu-ga.service

%postun guest-agent
%service_del_postun qemu-ga.service
%endif

%if 0%{?suse_version} >= 1130
%post tools
%set_permissions %_libexecdir/qemu-bridge-helper

%verifyscript tools
%verify_permissions %_libexecdir/qemu-bridge-helper
%endif

%endif # !qemu-testsuite

%files
%defattr(-, root, root)
%if "%{name}" != "qemu-testsuite"
%doc COPYING COPYING.LIB Changelog README VERSION qemu-doc.html qemu-tech.html
%doc %_mandir/man1/qemu.1.gz
%dir %_datadir/%name
%_datadir/%name/keymaps
%_datadir/%name/trace-events
%_datadir/%name/qemu-icon.bmp
%_datadir/%name/qemu-ifup
%_datadir/%name/qemu_logo_no_text.svg
%dir %_sysconfdir/%name
%if 0%{?kvm_available}
%_bindir/kvm_stat
%if 0%{?suse_version} >= 1230
%{_udevrulesdir}/80-kvm.rules
%else
%{_udevrulesdir}/60-kvm.rules
%endif
%endif
%if 0%{?with_systemd}
%ifarch s390x
%_libexecdir/modules-load.d/kvm.conf
%endif
%endif

%files x86
%defattr(-, root, root)
%_bindir/qemu-system-i386
%_bindir/qemu-system-x86_64
%_datadir/%name/kvmvapic.bin
%_datadir/%name/linuxboot.bin
%_datadir/%name/multiboot.bin
%config %_sysconfdir/%name/target-x86_64.conf

%files ppc
%defattr(-, root, root)
%_bindir/qemu-system-ppc
%_bindir/qemu-system-ppc64
%_bindir/qemu-system-ppcemb
%_datadir/%name/ppc_rom.bin
%_datadir/%name/openbios-ppc
%_datadir/%name/slof.bin
%_datadir/%name/spapr-rtas.bin
%_datadir/%name/u-boot.e500
%_datadir/%name/bamboo.dtb
%_datadir/%name/petalogix-ml605.dtb

%files s390
%defattr(-, root, root)
%_bindir/qemu-system-s390x
%_datadir/%name/s390-zipl.rom
%_datadir/%name/s390-ccw.img

%files arm
%defattr(-, root, root)
%_bindir/qemu-system-arm
%_bindir/qemu-system-aarch64

%files extra
%defattr(-, root, root)
%_bindir/qemu-system-*
%exclude %_bindir/qemu-system-i386
%exclude %_bindir/qemu-system-x86_64
%exclude %_bindir/qemu-system-ppc
%exclude %_bindir/qemu-system-ppc64
%exclude %_bindir/qemu-system-ppcemb
%exclude %_bindir/qemu-system-s390x
%exclude %_bindir/qemu-system-arm
%exclude %_bindir/qemu-system-aarch64
%_datadir/%name/palcode-clipper
%_datadir/%name/openbios-sparc32
%_datadir/%name/openbios-sparc64
%_datadir/%name/petalogix-s3adsp1800.dtb
%_datadir/%name/QEMU,cgthree.bin
%_datadir/%name/QEMU,tcx.bin

%if 0%{?legacy_qemu_kvm}
%files kvm
%defattr(-,root,root)
%_bindir/qemu-kvm
%_mandir/man1/qemu-kvm.1.gz
%dir %_docdir/qemu-kvm/
%_docdir/qemu-kvm/kvm-supported.txt
%endif

%files lang -f %name.lang
%defattr(-, root, root)

%ifarch %ix86 x86_64
%files seabios
%defattr(-, root, root)
%_datadir/%name/bios.bin
%_datadir/%name/bios-256k.bin
%_datadir/%name/acpi-dsdt.aml
%_datadir/%name/q35-acpi-dsdt.aml

%files vgabios
%defattr(-, root, root)
%_datadir/%name/vgabios.bin
%_datadir/%name/vgabios-cirrus.bin
%_datadir/%name/vgabios-qxl.bin
%_datadir/%name/vgabios-stdvga.bin
%_datadir/%name/vgabios-vmware.bin

%files sgabios
%defattr(-, root, root)
%_datadir/%name/sgabios.bin

%files ipxe
%defattr(-, root, root)
%_datadir/%name/pxe-e1000.rom
%_datadir/%name/pxe-eepro100.rom
%_datadir/%name/pxe-pcnet.rom
%_datadir/%name/pxe-ne2k_pci.rom
%_datadir/%name/pxe-rtl8139.rom
%_datadir/%name/pxe-virtio.rom
%_datadir/%name/efi-e1000.rom
%_datadir/%name/efi-eepro100.rom
%_datadir/%name/efi-pcnet.rom
%_datadir/%name/efi-ne2k_pci.rom
%_datadir/%name/efi-rtl8139.rom
%_datadir/%name/efi-virtio.rom
%endif

%files block-curl
%defattr(-, root, root)
%dir %_libdir/%name
%_libdir/%name/block-curl.so

%if 0%{?with_rbd}
%files block-rbd
%defattr(-, root, root)
%dir %_libdir/%name
%_libdir/%name/block-rbd.so
%endif

%files tools
%defattr(-, root, root)
%doc %_mandir/man1/qemu-img.1.gz
%doc %_mandir/man1/virtfs-proxy-helper.1.gz
%doc %_mandir/man8/qemu-nbd.8.gz
%_bindir/qemu-io
%_bindir/qemu-img
%_bindir/qemu-nbd
%_bindir/virtfs-proxy-helper
%verify(not mode) %_libexecdir/qemu-bridge-helper
%dir %_sysconfdir/%name
%config %_sysconfdir/%name/bridge.conf

%files guest-agent
%defattr(-, root, root)
%attr(755,root,root) %_bindir/qemu-ga
%if 0%{?with_systemd}
%{_unitdir}/qemu-ga.service
%{_udevrulesdir}/80-qemu-ga.rules
%endif

%else # qemu-testsuite
%doc %_datadir/qemu/check-report.xml
%doc %_datadir/qemu/check-report.html
%endif

%changelog