From 7a925b3802f503a5966273e8848b1d3b05376f25 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Jun 23 2021 15:50:54 +0000 Subject: spec: More RHEL merging * Add tools_only path to only build qemu-img and qemu-guest-agent * Add a -tests subpackage * Install tracetool, simpletrace, dump-guest-memory * Add vhost modprobe file * Sync qemu-guest-agent file lists * Use udevrulesdir from systemd * Add more seabios and seavgabios roms * More use of %{name} to make paths more generic * Group all fedora specific %install content at the end * Drop the rpath stripping, in my testing it's not needed anymore * Drop the s390x iotests skippage from last year Signed-off-by: Cole Robinson --- diff --git a/95-kvm-memlock.conf b/95-kvm-memlock.conf new file mode 100644 index 0000000..31d6d2a --- /dev/null +++ b/95-kvm-memlock.conf @@ -0,0 +1,12 @@ +# The KVM HV implementation on Power can require a significant amount +# of unswappable memory (about half of which also needs to be host +# physically contiguous) to hold the guest's Hash Page Table (HPT) - +# roughly 1/64th of the guest's RAM size, minimum 16MiB. +# +# These limits allow unprivileged users to start smallish VMs, such as +# those used by libguestfs. +# +# https://bugzilla.redhat.com/show_bug.cgi?id=1293024 +# +* hard memlock 65536 +* soft memlock 65536 diff --git a/95-kvm-ppc64-memlock.conf b/95-kvm-ppc64-memlock.conf deleted file mode 100644 index 31d6d2a..0000000 --- a/95-kvm-ppc64-memlock.conf +++ /dev/null @@ -1,12 +0,0 @@ -# The KVM HV implementation on Power can require a significant amount -# of unswappable memory (about half of which also needs to be host -# physically contiguous) to hold the guest's Hash Page Table (HPT) - -# roughly 1/64th of the guest's RAM size, minimum 16MiB. -# -# These limits allow unprivileged users to start smallish VMs, such as -# those used by libguestfs. -# -# https://bugzilla.redhat.com/show_bug.cgi?id=1293024 -# -* hard memlock 65536 -* soft memlock 65536 diff --git a/README.tests b/README.tests new file mode 100644 index 0000000..9932773 --- /dev/null +++ b/README.tests @@ -0,0 +1,39 @@ +qemu-kvm-tests README +===================== + +The qemu-kvm-tests rpm contains tests that can be used to verify the +functionality of the installed qemu-kvm package + +When installed, the files from this rpm will be arranged in the following +directory structure + +tests-src/ +├── README +├── scripts +│   ├── qemu.py +│   └── qmp +└── tests + ├── acceptance + ├── Makefile.include + └── qemu-iotests + +The tests/ directory within the tests-src/ directory is setup to remain a copy +of a subset of the tests/ directory from the QEMU source tree + +The avocado_qemu tests and qemu-iotests, along with files required for the +execution of the avocado_qemu tests (scripts/qemu.py and scripts/qmp/) will be +installed in a new location - /usr/lib64/qemu-kvm/tests-src/ + +avocado_qemu tests: +The avocado_qemu tests can be executed by running the following avocado command: +avocado run -p qemu_bin=/usr/libexec/qemu-kvm /usr/lib64/qemu-kvm/tests/acceptance/ +Avocado needs to be installed separately using either pip or from source as +Avocado is not being packaged for RHEL-8. + +qemu-iotests: +symlinks to corresponding binaries need to be created for QEMU_PROG, +QEMU_IO_PROG, QEMU_IMG_PROG, and QEMU_NBD_PROG before the iotests can be +executed. + +The primary purpose of this package is to make these tests available to be +executed as gating tests for the virt module in the RHEL-8 OSCI environment. diff --git a/qemu.spec b/qemu.spec index f371c62..6daf98e 100644 --- a/qemu.spec +++ b/qemu.spec @@ -4,6 +4,8 @@ %global meson_version 0.55.3-3 %global usbredir_version 0.7.1 +%global have_memlock_limits 0 +%global need_qemu_kvm 0 %ifarch %{ix86} %global kvm_package system-x86 # need_qemu_kvm should only ever be used by x86 @@ -15,6 +17,7 @@ %global need_qemu_kvm 1 %endif %ifarch %{power64} +%global have_memlock_limits 1 %global kvm_package system-ppc %endif %ifarch s390x @@ -33,8 +36,11 @@ %global kvm_package system-riscv %endif +%global tools_only 0 + %global user_static 1 %if 0%{?rhel} +# EPEL/RHEL do not have required -static builddeps %global user_static 0 %endif @@ -129,6 +135,7 @@ %endif +%global qemudocdir %{_docdir}/%{name} %define evr %{epoch}:%{version}-%{release} %define requires_block_curl Requires: %{name}-block-curl = %{evr} @@ -234,7 +241,13 @@ %global obsoletes_some_modules \ %{obsoletes_block_gluster} \ %{obsoletes_block_rbd} \ -%{obsoletes_block_rbd} +%{obsoletes_block_rbd} \ +Obsoletes: %{name}-system-lm32 <= %{epoch}:%{version}-%{release} \ +Obsoletes: %{name}-system-lm32-core <= %{epoch}:%{version}-%{release} \ +Obsoletes: %{name}-system-moxie <= %{epoch}:%{version}-%{release} \ +Obsoletes: %{name}-system-moxie-core <= %{epoch}:%{version}-%{release} \ +Obsoletes: %{name}-system-unicore32 <= %{epoch}:%{version}-%{release} \ +Obsoletes: %{name}-system-unicore32-core <= %{epoch}:%{version}-%{release} # Release candidate version tracking # global rcver rc4 @@ -254,17 +267,14 @@ URL: http://www.qemu.org/ Source0: http://wiki.qemu-project.org/download/%{name}-%{version}%{?rcstr}.tar.xz -# guest agent service Source10: qemu-guest-agent.service -Source17: qemu-ga.sysconfig -# guest agent udev rules Source11: 99-qemu-guest-agent.rules -# /etc/qemu/bridge.conf Source12: bridge.conf -# /etc/modprobe.d/kvm.conf, for x86 +Source17: qemu-ga.sysconfig Source20: kvm-x86.modprobe.conf -# /etc/security/limits.d/95-kvm-ppc64-memlock.conf -Source21: 95-kvm-ppc64-memlock.conf +Source21: 95-kvm-memlock.conf +Source26: vhost.conf +Source36: README.tests Patch0001: 0001-vl-allow-not-specifying-size-in-m-when-using-M-memor.patch Patch0002: 0002-qemu-config-load-modules-when-instantiating-option-g.patch @@ -338,8 +348,6 @@ BuildRequires: libslirp-devel # Fedora specific BuildRequires: make BuildRequires: gcc -# chrpath calls in specfile -BuildRequires: chrpath # -display sdl support BuildRequires: SDL2-devel # pulseaudio audio output @@ -420,6 +428,12 @@ BuildRequires: glibc-static pcre-static glib2-static zlib-static %endif +%description +%{name} is an open source virtualizer that provides hardware +emulation for the KVM hypervisor. %{name} acts as a virtual +machine monitor together with the KVM kernel modules, and emulates the +hardware for a full system such as a PC and its associated peripherals. +# Requires for the Fedora 'qemu' metapackage Requires: %{name}-user = %{epoch}:%{version}-%{release} Requires: %{name}-system-aarch64 = %{epoch}:%{version}-%{release} Requires: %{name}-system-alpha = %{epoch}:%{version}-%{release} @@ -443,62 +457,62 @@ Requires: %{name}-system-xtensa = %{epoch}:%{version}-%{release} Requires: %{name}-img = %{epoch}:%{version}-%{release} -%description -QEMU is a generic and open source processor emulator which achieves a good -emulation speed by using dynamic translation. QEMU has two operating modes: - - * Full system emulation. In this mode, QEMU emulates a full system (for - example a PC), including a processor and various peripherials. It can be - used to launch different Operating Systems without rebooting the PC or - to debug system code. - * User mode emulation. In this mode, QEMU can launch Linux processes compiled - for one CPU on another CPU. - -As QEMU requires no host kernel patches to run, it is safe and easy to use. - - -%package common +%package common Summary: QEMU common files needed by all QEMU targets -Requires: ipxe-roms-qemu Requires(post): /usr/bin/getent Requires(post): /usr/sbin/groupadd Requires(post): /usr/sbin/useradd Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units -Obsoletes: %{name}-system-lm32 <= %{epoch}:%{version}-%{release} -Obsoletes: %{name}-system-lm32-core <= %{epoch}:%{version}-%{release} -Obsoletes: %{name}-system-moxie <= %{epoch}:%{version}-%{release} -Obsoletes: %{name}-system-moxie-core <= %{epoch}:%{version}-%{release} -Obsoletes: %{name}-system-unicore32 <= %{epoch}:%{version}-%{release} -Obsoletes: %{name}-system-unicore32-core <= %{epoch}:%{version}-%{release} %{obsoletes_some_modules} +Requires: ipxe-roms-qemu %description common -This package provides the common files needed by all QEMU targets +%{name} is an open source virtualizer that provides hardware emulation for +the KVM hypervisor. + +This package provides documentation and auxiliary programs used with %{name}. %package docs -Summary: QEMU documentation +Summary: %{name} documentation %description docs -This package provides QEMU documentation files +%{name}-docs provides documentation files regarding %{name}. + + +%package -n qemu-img +Summary: QEMU command line tool for manipulating disk images +%description -n qemu-img +This package provides a command line tool for manipulating disk images. -%package guest-agent +%package -n qemu-guest-agent Summary: QEMU guest agent Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units -%description guest-agent +%description -n qemu-guest-agent +%{name} is an open source virtualizer that provides hardware emulation for +the KVM hypervisor. + This package provides an agent to run inside guests, which communicates with the host over a virtio-serial channel named "org.qemu.guest_agent.0" This package does not need to be installed on the host OS. -%package img -Summary: QEMU command line tool for manipulating disk images -%description img -This package provides a command line tool for manipulating disk images +%package tests +Summary: tests for the %{name} package +Requires: %{name} = %{epoch}:%{version}-%{release} + +%define testsdir %{_libdir}/%{name}/tests-src + +%description tests +The %{name}-tests rpm contains tests that can be used to verify +the functionality of the installed %{name} package + +Install this package if you want access to the avocado_qemu +tests, or qemu-iotests. %package block-curl @@ -511,6 +525,50 @@ Install this package if you want to access remote disks over http, https, ftp and other transports provided by the CURL library. +%package block-iscsi +Summary: QEMU iSCSI block driver +Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} +%description block-iscsi +This package provides the additional iSCSI block driver for QEMU. + +Install this package if you want to access iSCSI volumes. + + +%if %{have_block_rbd} +%package block-rbd +Summary: QEMU Ceph/RBD block driver +Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} +%description block-rbd +This package provides the additional Ceph/RBD block driver for QEMU. + +Install this package if you want to access remote Ceph volumes +using the rbd protocol. +%endif + + +%package block-ssh +Summary: QEMU SSH block driver +Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} +%description block-ssh +This package provides the additional SSH block driver for QEMU. + +Install this package if you want to access remote disks using +the Secure Shell (SSH) protocol. + + +%if %{have_opengl} +%package ui-opengl +Summary: QEMU opengl support +Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} +Requires: mesa-libGL +Requires: mesa-libEGL +Requires: mesa-dri-drivers +%description ui-opengl +This package provides opengl support. +%endif + + +# Fedora specific %package block-dmg Summary: QEMU block driver for DMG disk images Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} @@ -531,15 +589,6 @@ Install this package if you want to access remote Gluster storage. %endif -%package block-iscsi -Summary: QEMU iSCSI block driver -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} -%description block-iscsi -This package provides the additional iSCSI block driver for QEMU. - -Install this package if you want to access iSCSI volumes. - - %if %{have_block_nfs} %package block-nfs Summary: QEMU NFS block driver @@ -552,27 +601,6 @@ Install this package if you want to access remote NFS storage. %endif -%if %{have_block_rbd} -%package block-rbd -Summary: QEMU Ceph/RBD block driver -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} -%description block-rbd -This package provides the additional Ceph/RBD block driver for QEMU. - -Install this package if you want to access remote Ceph volumes -using the rbd protocol. -%endif - -%package block-ssh -Summary: QEMU SSH block driver -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} -%description block-ssh -This package provides the additional SSH block driver for QEMU. - -Install this package if you want to access remote disks using -the Secure Shell (SSH) protocol. - - %package audio-alsa Summary: QEMU ALSA audio driver Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} @@ -633,12 +661,6 @@ Requires: %{name}-ui-opengl%{?_isa} = %{epoch}:%{version}-%{release} %description ui-egl-headless This package provides the additional egl-headless UI for QEMU. -%package ui-opengl -Summary: QEMU OpenGL driver -Requires: %{name}-common%{?_isa} = %{epoch}:%{version}-%{release} -%description ui-opengl -This package provides the additional opengl UI for QEMU. - %package char-baum Summary: QEMU Baum chardev driver @@ -1103,7 +1125,6 @@ pathfix.py -pni "%{__python3} %{py3_shbang_opts}" scripts/qemu-trace-stap - %build # --build-id option is used for giving info to the debug packages. buildldflags="VL_LDFLAGS=-Wl,--build-id" @@ -1402,12 +1423,27 @@ run_configure \ %endif --enable-zstd \ -make V=1 %{?_smp_mflags} $buildldflags -popd +%if %{tools_only} +make V=1 %{?_smp_mflags} $buildldflags qemu-img +make V=1 %{?_smp_mflags} $buildldflags qemu-io +make V=1 %{?_smp_mflags} $buildldflags qemu-nbd +make V=1 %{?_smp_mflags} $buildldflags storage-daemon/qemu-storage-daemon +make V=1 %{?_smp_mflags} $buildldflags docs/qemu-img.1 +make V=1 %{?_smp_mflags} $buildldflags docs/qemu-nbd.8 +make V=1 %{?_smp_mflags} $buildldflags docs/qemu-storage-daemon.1 +make V=1 %{?_smp_mflags} $buildldflags docs/qemu-storage-daemon-qmp-ref.7 + +make V=1 %{?_smp_mflags} $buildldflags qga/qemu-ga +make V=1 %{?_smp_mflags} $buildldflags docs/qemu-ga.8 +# endif tools_only +%endif +%if !%{tools_only} +make V=1 %{?_smp_mflags} $buildldflags +popd # Fedora build for qemu-user-static %if %{user_static} @@ -1417,121 +1453,135 @@ run_configure \ --enable-attr \ --enable-linux-user \ --enable-tcg \ + --disable-blobs \ --static make V=1 %{?_smp_mflags} $buildldflags - -popd +popd # static +%endif +# endif !tools_only %endif %install - -%global _udevdir /lib/udev/rules.d -%global qemudocdir %{_docdir}/%{name} - - -# Install rules to use the bridge helper with libvirt's virbr0 -install -D -m 0644 %{_sourcedir}/bridge.conf %{buildroot}%{_sysconfdir}/qemu/bridge.conf - - # Install qemu-guest-agent service and udev rules -install -D -p -m 0644 %{_sourcedir}/qemu-guest-agent.service %{buildroot}%{_unitdir}/qemu-guest-agent.service -install -D -p -m 0644 %{_sourcedir}/qemu-ga.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/qemu-ga -install -D -m 0644 %{_sourcedir}/99-qemu-guest-agent.rules %{buildroot}%{_udevdir}/99-qemu-guest-agent.rules +install -D -m 0644 %{_sourcedir}/qemu-guest-agent.service %{buildroot}%{_unitdir}/qemu-guest-agent.service +install -D -m 0644 %{_sourcedir}/qemu-ga.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/qemu-ga +install -D -m 0644 %{_sourcedir}/99-qemu-guest-agent.rules %{buildroot}%{_udevrulesdir}/99-qemu-guest-agent.rules # Install qemu-ga fsfreeze bits mkdir -p %{buildroot}%{_sysconfdir}/qemu-ga/fsfreeze-hook.d -install -p -m 0755 scripts/qemu-guest-agent/fsfreeze-hook %{buildroot}%{_sysconfdir}/qemu-ga -install -p -m 0644 scripts/qemu-guest-agent/fsfreeze-hook.d/*.sample %{buildroot}%{_sysconfdir}/qemu-ga/fsfreeze-hook.d/ -mkdir -p %{buildroot}%{_localstatedir}/log -touch %{buildroot}%{_localstatedir}/log/qga-fsfreeze-hook.log - - -# Install qemu-pr-helper service -install -m 0644 ./contrib/systemd/qemu-pr-helper.service %{buildroot}%{_unitdir} -install -m 0644 ./contrib/systemd/qemu-pr-helper.socket %{buildroot}%{_unitdir} +install -p scripts/qemu-guest-agent/fsfreeze-hook %{buildroot}%{_sysconfdir}/qemu-ga/fsfreeze-hook +mkdir -p %{buildroot}%{_datadir}/%{name}/qemu-ga/fsfreeze-hook.d/ +install -p -m 0644 scripts/qemu-guest-agent/fsfreeze-hook.d/*.sample %{buildroot}%{_datadir}/%{name}/qemu-ga/fsfreeze-hook.d/ +mkdir -p -v %{buildroot}%{_localstatedir}/log/qemu-ga/ -# Install ppc64 memlock -%ifarch %{power64} -install -d %{buildroot}%{_sysconfdir}/security/limits.d -install -m 0644 %{_sourcedir}/95-kvm-ppc64-memlock.conf %{buildroot}%{_sysconfdir}/security/limits.d +%if %{tools_only} +pushd %{qemu_kvm_build} +install -D -p -m 0755 qga/qemu-ga %{buildroot}%{_bindir}/qemu-ga +install -D -p -m 0755 qemu-img %{buildroot}%{_bindir}/qemu-img +install -D -p -m 0755 qemu-io %{buildroot}%{_bindir}/qemu-io +install -D -p -m 0755 qemu-nbd %{buildroot}%{_bindir}/qemu-nbd +install -D -p -m 0755 storage-daemon/qemu-storage-daemon %{buildroot}%{_bindir}/qemu-storage-daemon + +mkdir -p %{buildroot}%{_mandir}/man1/ +mkdir -p %{buildroot}%{_mandir}/man7/ +mkdir -p %{buildroot}%{_mandir}/man8/ + +install -D -p -m 644 docs/qemu-img.1* %{buildroot}%{_mandir}/man1 +install -D -p -m 644 docs/qemu-nbd.8* %{buildroot}%{_mandir}/man8 +install -D -p -m 644 docs/qemu-storage-daemon.1* %{buildroot}%{_mandir}/man1 +install -D -p -m 644 docs/qemu-storage-daemon-qmp-ref.7* %{buildroot}%{_mandir}/man7 +install -D -p -m 644 docs/qemu-ga.8* %{buildroot}%{_mandir}/man8 +popd +# endif tools_only %endif -# Install qemu-user-static tree -mkdir -p %{buildroot}%{_bindir} -%if %{user_static} -pushd %{static_builddir} -make DESTDIR=%{buildroot} install +%if !%{tools_only} +# Install rules to use the bridge helper with libvirt's virbr0 +install -D -m 0644 %{_sourcedir}/bridge.conf %{buildroot}%{_sysconfdir}/%{name}/bridge.conf -# Rename all QEMU user emulators to have a -static suffix -for src in %{buildroot}%{_bindir}/qemu-* -do - mv $src $src-static -done +# Install qemu-pr-helper service +install -m 0644 contrib/systemd/qemu-pr-helper.service %{buildroot}%{_unitdir} +install -m 0644 contrib/systemd/qemu-pr-helper.socket %{buildroot}%{_unitdir} -# Rename trace files to match -static suffix -for src in %{buildroot}%{_datadir}/systemtap/tapset/qemu-*.stp -do - dst=`echo $src | sed -e 's/.stp/-static.stp/'` - mv $src $dst - perl -i -p -e 's/(qemu-\w+)/$1-static/g; s/(qemu\.user\.\w+)/$1.static/g' $dst -done +%if %{have_memlock_limits} +install -D -p -m 644 %{_sourcedir}/95-kvm-memlock.conf %{buildroot}%{_sysconfdir}/security/limits.d/95-kvm-memlock.conf +%endif -popd +%if %{have_kvm} +install -D -p -m 0644 %{_sourcedir}/vhost.conf %{buildroot}%{_sysconfdir}/modprobe.d/vhost.conf %endif +%if %{defined modprobe_kvm_conf} +install -D -p -m 0644 %{modprobe_kvm_conf} %{buildroot}%{_sysconfdir}/modprobe.d/kvm.conf +%endif -# Install main qemu-system-* tree -pushd %{qemu_kvm_build} -make DESTDIR=%{buildroot} install -popd -%find_lang %{name} +# Copy some static data into place +install -D -p -m 0644 -t %{buildroot}%{qemudocdir} README.rst COPYING COPYING.LIB LICENSE docs/interop/qmp-spec.txt +install -D -p -m 0644 qemu.sasl %{buildroot}%{_sysconfdir}/sasl2/%{name}.conf +install -m 0644 scripts/dump-guest-memory.py %{buildroot}%{_datadir}/%{name} -# Copy some static data into place -install -D -p -m 0644 -t %{buildroot}%{qemudocdir} README.rst -install -D -p -m 0644 qemu.sasl %{buildroot}%{_sysconfdir}/sasl2/qemu.conf +# Install simpletrace +install -m 0755 scripts/simpletrace.py %{buildroot}%{_datadir}/%{name}/simpletrace.py +mkdir -p %{buildroot}%{_datadir}/%{name}/tracetool +install -m 0644 -t %{buildroot}%{_datadir}/%{name}/tracetool scripts/tracetool/*.py +mkdir -p %{buildroot}%{_datadir}/%{name}/tracetool/backend +install -m 0644 -t %{buildroot}%{_datadir}/%{name}/tracetool/backend scripts/tracetool/backend/*.py +mkdir -p %{buildroot}%{_datadir}/%{name}/tracetool/format +install -m 0644 -t %{buildroot}%{_datadir}/%{name}/tracetool/format scripts/tracetool/format/*.py -# Generate qemu-system-* man pages -chmod -x %{buildroot}%{_mandir}/man1/* -for emu in %{buildroot}%{_bindir}/qemu-system-*; do - ln -sf qemu.1.gz %{buildroot}%{_mandir}/man1/$(basename $emu).1.gz -done +# Create new directories and put them all under tests-src +mkdir -p %{buildroot}%{testsdir}/python +mkdir -p %{buildroot}%{testsdir}/tests +mkdir -p %{buildroot}%{testsdir}/tests/acceptance +mkdir -p %{buildroot}%{testsdir}/tests/qemu-iotests +mkdir -p %{buildroot}%{testsdir}/scripts/qmp -# Install kvm specific source bits, and qemu-kvm manpage -%if 0%{?need_qemu_kvm} -ln -sf qemu.1.gz %{buildroot}%{_mandir}/man1/qemu-kvm.1.gz -ln -sf qemu-system-x86_64 %{buildroot}%{_bindir}/qemu-kvm -install -D -p -m 0644 %{_sourcedir}/kvm-x86.modprobe.conf %{buildroot}%{_sysconfdir}/modprobe.d/kvm.conf -%endif +# Install avocado_qemu tests +cp -R %{qemu_kvm_build}/tests/acceptance/* %{buildroot}%{testsdir}/tests/acceptance/ +# Install qemu.py and qmp/ scripts required to run avocado_qemu tests +cp -R %{qemu_kvm_build}/python/qemu %{buildroot}%{testsdir}/python +cp -R %{qemu_kvm_build}/scripts/qmp/* %{buildroot}%{testsdir}/scripts/qmp +install -p -m 0755 tests/Makefile.include %{buildroot}%{testsdir}/tests/ -# Install binfmt -%global binfmt_dir %{buildroot}%{_exec_prefix}/lib/binfmt.d -mkdir -p %{binfmt_dir} +# Install qemu-iotests +cp -R tests/qemu-iotests/* %{buildroot}%{testsdir}/tests/qemu-iotests/ +cp -ur %{qemu_kvm_build}/tests/qemu-iotests/* %{buildroot}%{testsdir}/tests/qemu-iotests/ +# Avoid ambiguous 'python' interpreter name +find %{buildroot}%{testsdir}/tests/qemu-iotests/* -maxdepth 1 -type f -exec sed -i -e '1 s+/usr/bin/env \(python\|python3\)+%{__python3}+' {} \; +find %{buildroot}%{testsdir}/scripts/qmp/* -maxdepth 1 -type f -exec sed -i -e '1 s+/usr/bin/env \(python\|python3\)+%{__python3}+' {} \; +find %{buildroot}%{testsdir}/scripts/qmp/* -maxdepth 1 -type f -exec sed -i -e '1 s+/usr/bin/\(python\|python3\)+%{__python3}+' {} \; -./scripts/qemu-binfmt-conf.sh --systemd ALL --exportdir %{binfmt_dir} --qemu-path %{_bindir} -for i in %{binfmt_dir}/*; do - mv $i $(echo $i | sed 's/.conf/-dynamic.conf/') -done +# Install our custom tests README +install -p -m 0644 %{_sourcedir}/README.tests %{buildroot}%{testsdir}/README -%if %{user_static} -for regularfmt in %{binfmt_dir}/*; do - staticfmt="$(echo $regularfmt | sed 's/-dynamic/-static/g')" - cat $regularfmt | tr -d '\n' | sed "s/:$/-static:F/" > $staticfmt -done -%endif +# Do the actual qemu tree install +pushd %{qemu_kvm_build} +make DESTDIR=%{buildroot} \ + sharedir="%{_datadir}/%{name}" \ + datadir="%{_datadir}/%{name}" \ + install +popd + + +# We need to make the block device modules and other qemu SO files executable +# otherwise RPM won't pick up their dependencies. +chmod +x %{buildroot}%{_libdir}/%{name}/*.so + +# Remove docs we don't care about +find %{buildroot}%{qemudocdir} -name .buildinfo -delete +rm -rf %{buildroot}%{qemudocdir}/specs -# XXX With qemu 2.11 we can probably drop this symlinking with use of -# configure --firmwarepath, see qemu git 3d5eecab4 # Provided by package openbios rm -rf %{buildroot}%{_datadir}/%{name}/openbios-ppc @@ -1545,17 +1595,17 @@ rm -rf %{buildroot}%{_datadir}/%{name}/efi*rom # Provided by package seavgabios rm -rf %{buildroot}%{_datadir}/%{name}/vgabios*bin # Provided by package seabios -rm -rf %{buildroot}%{_datadir}/%{name}/bios.bin -rm -rf %{buildroot}%{_datadir}/%{name}/bios-256k.bin +rm -rf %{buildroot}%{_datadir}/%{name}/bios*.bin # Provided by package sgabios rm -rf %{buildroot}%{_datadir}/%{name}/sgabios.bin -# Provided by package edk2 +# Provided by edk2 rm -rf %{buildroot}%{_datadir}/%{name}/edk2* -rm -rf %{buildroot}%{_datadir}/%{name}/firmware/*edk2*.json +rm -rf %{buildroot}%{_datadir}/%{name}/firmware + pxe_link() { - ln -s ../ipxe/$2.rom %{buildroot}%{_datadir}/%{name}/pxe-$1.rom - ln -s ../ipxe.efi/$2.rom %{buildroot}%{_datadir}/%{name}/efi-$1.rom + ln -s ../ipxe/$2.rom %{buildroot}%{_datadir}/%{name}/pxe-$1.rom + ln -s ../ipxe.efi/$2.rom %{buildroot}%{_datadir}/%{name}/efi-$1.rom } pxe_link e1000 8086100e @@ -1579,42 +1629,79 @@ rom_link ../seavgabios/vgabios-vmware.bin vgabios-vmware.bin rom_link ../seavgabios/vgabios-virtio.bin vgabios-virtio.bin rom_link ../seavgabios/vgabios-ramfb.bin vgabios-ramfb.bin rom_link ../seavgabios/vgabios-bochs-display.bin vgabios-bochs-display.bin +rom_link ../seavgabios/vgabios-isavga.bin vgabios-isavga.bin rom_link ../seavgabios/vgabios-ati.bin vgabios-ati.bin rom_link ../seabios/bios.bin bios.bin rom_link ../seabios/bios-256k.bin bios-256k.bin +rom_link ../seabios/bios-microvm.bin bios-microvm.bin rom_link ../sgabios/sgabios.bin sgabios.bin -# When building using 'rpmbuild' or 'fedpkg local', RPATHs can be left in -# the binaries and libraries (although this doesn't occur when -# building in Koji, for some unknown reason). Some discussion here: -# -# https://lists.fedoraproject.org/pipermail/devel/2013-November/192553.html -# -# In any case it should always be safe to remove RPATHs from -# the final binaries: -for f in %{buildroot}%{_bindir}/* %{buildroot}%{_libdir}/* \ - %{buildroot}%{_libexecdir}/*; do - if file $f | grep -q ELF | grep -q -i shared; then chrpath --delete $f; fi -done +# Fedora specific stuff below +%find_lang %{name} +# Generate qemu-system-* man pages +chmod -x %{buildroot}%{_mandir}/man1/* +for emu in %{buildroot}%{_bindir}/qemu-system-*; do + ln -sf qemu.1.gz %{buildroot}%{_mandir}/man1/$(basename $emu).1.gz + done -# We need to make the modules executable else -# RPM won't pick up their dependencies. -chmod +x %{buildroot}%{_libdir}/qemu/*.so +# Install kvm specific source bits, and qemu-kvm manpage +%if %{need_qemu_kvm} +ln -sf qemu.1.gz %{buildroot}%{_mandir}/man1/qemu-kvm.1.gz +ln -sf qemu-system-x86_64 %{buildroot}%{_bindir}/qemu-kvm +install -D -p -m 0644 %{_sourcedir}/kvm-x86.modprobe.conf %{buildroot}%{_sysconfdir}/modprobe.d/kvm.conf + %endif +# Install binfmt +%global binfmt_dir %{buildroot}%{_exec_prefix}/lib/binfmt.d +mkdir -p %{binfmt_dir} -%check -# 2020-08-31: tests passing, but s390x fails due to -# spurious warning breaking an iotest case -# https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg03279.html -%ifarch s390x -perl -i -p -e 's/^(127|267)/# $1/' tests/qemu-iotests/group +./scripts/qemu-binfmt-conf.sh --systemd ALL --exportdir %{binfmt_dir} --qemu-path %{_bindir} +for i in %{binfmt_dir}/*; do mv $i $(echo $i | sed 's/.conf/-dynamic.conf/'); done + + +# Install qemu-user-static tree +%if %{user_static} +%define static_buildroot %{buildroot}/static/ +mkdir -p %{static_buildroot} + +pushd %{static_builddir} +make DESTDIR=%{static_buildroot} install +popd # static + +# Rename all QEMU user emulators to have a -static suffix +for src in %{static_buildroot}%{_bindir}/qemu-*; do + mv $src %{buildroot}%{_bindir}/$(basename $src)-static; done + +# Rename trace files to match -static suffix +for src in %{static_buildroot}%{_datadir}/systemtap/tapset/qemu-*.stp; do + dst=`echo $src | sed -e 's/.stp/-static.stp/'` + mv $src $dst + perl -i -p -e 's/(qemu-\w+)/$1-static/g; s/(qemu\.user\.\w+)/$1.static/g' $dst + mv $dst %{buildroot}%{_datadir}/systemtap/tapset + done + +for regularfmt in %{binfmt_dir}/*; do + staticfmt="$(echo $regularfmt | sed 's/-dynamic/-static/g')" + cat $regularfmt | tr -d '\n' | sed "s/:$/-static:F/" > $staticfmt + done + +rm -rf %{static_buildroot} +# endif user_static + %endif +# end Fedora specific +# endif !tools_only %endif -pushd %{qemu_kvm_build} + +%check +%if !%{tools_only} + +pushd %{qemu_kvm_build} +echo "Testing %{name}-build" # 2021-06: s390x tests randomly failing with 'Broken pipe' errors # dhorak couldn't reproduce locally on an s390x machine so guessed # it's a resource issue @@ -1625,13 +1712,29 @@ make check V=1 popd +# endif !tools_only +%endif + +%post -n qemu-guest-agent +%systemd_post qemu-guest-agent.service +%preun -n qemu-guest-agent +%systemd_preun qemu-guest-agent.service +%postun -n qemu-guest-agent +%systemd_postun_with_restart qemu-guest-agent.service + + +%if !%{tools_only} %post common getent group kvm >/dev/null || groupadd -g 36 -r kvm getent group qemu >/dev/null || groupadd -g 107 -r qemu getent passwd qemu >/dev/null || \ - useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ - -c "qemu user" qemu +useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ + -c "qemu user" qemu + + + + %post user-binfmt @@ -1645,169 +1748,160 @@ getent passwd qemu >/dev/null || \ %postun user-static /bin/systemctl --system try-restart systemd-binfmt.service &>/dev/null || : %endif +# endif !tools_only +%endif + + + +%files -n qemu-img +%{_bindir}/qemu-img +%{_bindir}/qemu-io +%{_bindir}/qemu-nbd +%{_bindir}/qemu-storage-daemon +%{_mandir}/man1/qemu-img.1* +%{_mandir}/man8/qemu-nbd.8* +%{_mandir}/man1/qemu-storage-daemon.1* +%{_mandir}/man7/qemu-storage-daemon-qmp-ref.7* -%post guest-agent -%systemd_post qemu-guest-agent.service -%preun guest-agent -%systemd_preun qemu-guest-agent.service -%postun guest-agent -%systemd_postun_with_restart qemu-guest-agent.service +%files -n qemu-guest-agent +%doc COPYING README.rst +%{_bindir}/qemu-ga +%{_mandir}/man8/qemu-ga.8* +%{_unitdir}/qemu-guest-agent.service +%{_udevrulesdir}/99-qemu-guest-agent.rules +%config(noreplace) %{_sysconfdir}/sysconfig/qemu-ga +%{_sysconfdir}/qemu-ga +%{_datadir}/%{name}/qemu-ga +%dir %{_localstatedir}/log/qemu-ga +%if !%{tools_only} %files # Deliberately empty +%files docs +%doc %{qemudocdir} + %files common -f %{name}.lang -%license COPYING -%license COPYING.LIB -%license LICENSE +%license COPYING COPYING.LIB LICENSE +%{_bindir}/qemu-edid +%{_bindir}/qemu-keymap +%{_bindir}/qemu-pr-helper +%{_bindir}/qemu-trace-stap %dir %{_datadir}/%{name}/ -%{_datadir}/applications/qemu.desktop -%{_datadir}/icons/hicolor/*/apps/* -%exclude %{_datadir}/%{name}/qemu-nsis.bmp +%{_datadir}/icons/* +%{_datadir}/%{name}/dump-guest-memory.py* %{_datadir}/%{name}/keymaps/ +%{_datadir}/%{name}/linuxboot_dma.bin +%{_datadir}/%{name}/simpletrace.py* %{_datadir}/%{name}/trace-events-all -%{_datadir}/%{name}/vgabios.bin -%{_datadir}/%{name}/vgabios-cirrus.bin -%{_datadir}/%{name}/vgabios-qxl.bin -%{_datadir}/%{name}/vgabios-stdvga.bin -%{_datadir}/%{name}/vgabios-vmware.bin -%{_datadir}/%{name}/vgabios-virtio.bin -%{_datadir}/%{name}/vgabios-ramfb.bin -%{_datadir}/%{name}/vgabios-bochs-display.bin -%{_datadir}/%{name}/vgabios-ati.bin -%{_datadir}/%{name}/pxe-e1000.rom -%{_datadir}/%{name}/efi-e1000.rom -%{_datadir}/%{name}/pxe-e1000e.rom -%{_datadir}/%{name}/efi-e1000e.rom -%{_datadir}/%{name}/pxe-eepro100.rom -%{_datadir}/%{name}/efi-eepro100.rom -%{_datadir}/%{name}/pxe-ne2k_pci.rom -%{_datadir}/%{name}/efi-ne2k_pci.rom -%{_datadir}/%{name}/pxe-pcnet.rom -%{_datadir}/%{name}/efi-pcnet.rom -%{_datadir}/%{name}/pxe-rtl8139.rom -%{_datadir}/%{name}/efi-rtl8139.rom -%{_datadir}/%{name}/pxe-virtio.rom -%{_datadir}/%{name}/efi-virtio.rom -%{_datadir}/%{name}/pxe-vmxnet3.rom -%{_datadir}/%{name}/efi-vmxnet3.rom +%{_datadir}/%{name}/tracetool/*.py* +%{_datadir}/%{name}/tracetool/backend/*.py* +%{_datadir}/%{name}/tracetool/format/*.py* %{_datadir}/%{name}/vhost-user/50-qemu-virtiofsd.json -%{_mandir}/man1/qemu.1* +%attr(4755, -, -) %{_libexecdir}/qemu-bridge-helper +%{_libexecdir}/virtiofsd +%{_mandir}/man1/%{name}.1* %{_mandir}/man1/qemu-trace-stap.1* -%{_mandir}/man1/virtfs-proxy-helper.1* %{_mandir}/man1/virtiofsd.1* %{_mandir}/man7/qemu-block-drivers.7* %{_mandir}/man7/qemu-cpu-models.7* -%{_mandir}/man7/qemu-qmp-ref.7* %{_mandir}/man7/qemu-ga-ref.7* +%{_mandir}/man7/qemu-qmp-ref.7* %{_mandir}/man8/qemu-pr-helper.8* -%{_bindir}/elf2dmp -%{_bindir}/qemu-edid -%{_bindir}/qemu-keymap -%{_bindir}/qemu-pr-helper -%{_bindir}/qemu-trace-stap +%dir %{_sysconfdir}/%{name} +%config(noreplace) %{_sysconfdir}/%{name}/bridge.conf +%if %{have_kvm} +%config(noreplace) %{_sysconfdir}/modprobe.d/vhost.conf +%endif +%config(noreplace) %{_sysconfdir}/sasl2/%{name}.conf %{_unitdir}/qemu-pr-helper.service %{_unitdir}/qemu-pr-helper.socket -%attr(4755, root, root) %{_libexecdir}/qemu-bridge-helper -%{_libexecdir}/virtfs-proxy-helper -%{_libexecdir}/virtiofsd -%config(noreplace) %{_sysconfdir}/sasl2/qemu.conf -%dir %{_sysconfdir}/qemu -%config(noreplace) %{_sysconfdir}/qemu/bridge.conf -%dir %{_libdir}/qemu -%files docs -%doc %{qemudocdir} +# Fedora specific +%{_bindir}/elf2dmp +%{_datadir}/applications/qemu.desktop +%exclude %{_datadir}/%{name}/qemu-nsis.bmp +%{_libexecdir}/virtfs-proxy-helper +%{_mandir}/man1/virtfs-proxy-helper.1* +%{_datadir}/%{name}/vgabios*.bin +%{_datadir}/%{name}/pxe*.rom +%{_datadir}/%{name}/efi*.rom -%files guest-agent -%{_bindir}/qemu-ga -%{_mandir}/man8/qemu-ga.8* -%{_unitdir}/qemu-guest-agent.service -%{_udevdir}/99-qemu-guest-agent.rules -%config(noreplace) %{_sysconfdir}/sysconfig/qemu-ga -%{_sysconfdir}/qemu-ga -%ghost %{_localstatedir}/log/qga-fsfreeze-hook.log +%files tests +%{testsdir} +%files block-curl +%{_libdir}/%{name}/block-curl.so +%files block-iscsi +%{_libdir}/%{name}/block-iscsi.so +%if %{have_block_rbd} +%files block-rbd +%{_libdir}/%{name}/block-rbd.so +%endif +%files block-ssh +%{_libdir}/%{name}/block-ssh.so -%files img -%{_bindir}/qemu-img -%{_bindir}/qemu-io -%{_bindir}/qemu-nbd -%{_bindir}/qemu-storage-daemon -%{_mandir}/man1/qemu-img.1* -%{_mandir}/man8/qemu-nbd.8* -%{_mandir}/man1/qemu-storage-daemon.1* -%{_mandir}/man7/qemu-storage-daemon-qmp-ref.7* +%if %{have_opengl} +%files ui-opengl +%{_libdir}/%{name}/ui-opengl.so +%endif -%files block-curl -%{_libdir}/qemu/block-curl.so %files block-dmg -%{_libdir}/qemu/block-dmg-bz2.so +%{_libdir}/%{name}/block-dmg-bz2.so %if %{have_block_gluster} %files block-gluster -%{_libdir}/qemu/block-gluster.so -%endif -%files block-iscsi -%{_libdir}/qemu/block-iscsi.so -%if %{have_block_rbd} -%files block-rbd -%{_libdir}/qemu/block-rbd.so +%{_libdir}/%{name}/block-gluster.so %endif -%files block-ssh -%{_libdir}/qemu/block-ssh.so %if %{have_block_nfs} %files block-nfs -%{_libdir}/qemu/block-nfs.so +%{_libdir}/%{name}/block-nfs.so %endif - %files audio-alsa -%{_libdir}/qemu/audio-alsa.so +%{_libdir}/%{name}/audio-alsa.so %files audio-oss -%{_libdir}/qemu/audio-oss.so +%{_libdir}/%{name}/audio-oss.so %files audio-pa -%{_libdir}/qemu/audio-pa.so +%{_libdir}/%{name}/audio-pa.so %files audio-sdl -%{_libdir}/qemu/audio-sdl.so +%{_libdir}/%{name}/audio-sdl.so %if %{have_jack} %files audio-jack -%{_libdir}/qemu/audio-jack.so +%{_libdir}/%{name}/audio-jack.so %endif %files ui-curses -%{_libdir}/qemu/ui-curses.so +%{_libdir}/%{name}/ui-curses.so %files ui-gtk -%{_libdir}/qemu/ui-gtk.so +%{_libdir}/%{name}/ui-gtk.so %files ui-sdl -%{_libdir}/qemu/ui-sdl.so +%{_libdir}/%{name}/ui-sdl.so %files ui-egl-headless -%{_libdir}/qemu/ui-egl-headless.so -%files ui-opengl -%{_libdir}/qemu/ui-opengl.so +%{_libdir}/%{name}/ui-egl-headless.so %files char-baum -%{_libdir}/qemu/chardev-baum.so +%{_libdir}/%{name}/chardev-baum.so %files device-display-virtio-gpu -%{_libdir}/qemu/hw-display-virtio-gpu.so +%{_libdir}/%{name}/hw-display-virtio-gpu.so %files device-display-virtio-gpu-pci -%{_libdir}/qemu/hw-display-virtio-gpu-pci.so +%{_libdir}/%{name}/hw-display-virtio-gpu-pci.so %files device-display-virtio-gpu-ccw -%{_libdir}/qemu/hw-s390x-virtio-gpu-ccw.so +%{_libdir}/%{name}/hw-s390x-virtio-gpu-ccw.so %files device-display-virtio-vga -%{_libdir}/qemu/hw-display-virtio-vga.so +%{_libdir}/%{name}/hw-display-virtio-vga.so %files device-usb-redirect -%{_libdir}/qemu/hw-usb-redirect.so +%{_libdir}/%{name}/hw-usb-redirect.so %files device-usb-smartcard -%{_libdir}/qemu/hw-usb-smartcard.so +%{_libdir}/%{name}/hw-usb-smartcard.so %if %{have_virgl} @@ -1818,15 +1912,15 @@ getent passwd qemu >/dev/null || \ %if %{have_spice} %files audio-spice -%{_libdir}/qemu/audio-spice.so +%{_libdir}/%{name}/audio-spice.so %files char-spice -%{_libdir}/qemu/chardev-spice.so +%{_libdir}/%{name}/chardev-spice.so %files device-display-qxl -%{_libdir}/qemu/hw-display-qxl.so +%{_libdir}/%{name}/hw-display-qxl.so %files ui-spice-core -%{_libdir}/qemu/ui-spice-core.so +%{_libdir}/%{name}/ui-spice-core.so %files ui-spice-app -%{_libdir}/qemu/ui-spice-app.so +%{_libdir}/%{name}/ui-spice-app.so %endif @@ -2011,8 +2105,8 @@ getent passwd qemu >/dev/null || \ %{_datadir}/%{name}/skiboot.lid %{_datadir}/%{name}/u-boot.e500 %{_datadir}/%{name}/u-boot-sam460-20100605.bin -%ifarch %{power64} -%{_sysconfdir}/security/limits.d/95-kvm-ppc64-memlock.conf +%if %{have_memlock_limits} +%{_sysconfdir}/security/limits.d/95-kvm-memlock.conf %endif @@ -2082,12 +2176,11 @@ getent passwd qemu >/dev/null || \ %{_datadir}/%{name}/bios-microvm.bin %{_datadir}/%{name}/kvmvapic.bin %{_datadir}/%{name}/linuxboot.bin -%{_datadir}/%{name}/linuxboot_dma.bin %{_datadir}/%{name}/multiboot.bin %{_datadir}/%{name}/pvh.bin %{_datadir}/%{name}/qboot.rom %{_datadir}/%{name}/sgabios.bin -%if 0%{?need_qemu_kvm} +%if %{need_qemu_kvm} %{_bindir}/qemu-kvm %{_mandir}/man1/qemu-kvm.1* %config(noreplace) %{_sysconfdir}/modprobe.d/kvm.conf @@ -2101,6 +2194,8 @@ getent passwd qemu >/dev/null || \ %{_datadir}/systemtap/tapset/qemu-system-xtensa*.stp %{_mandir}/man1/qemu-system-xtensa.1* %{_mandir}/man1/qemu-system-xtensaeb.1* +# endif !tools_only +%endif %changelog diff --git a/vhost.conf b/vhost.conf new file mode 100644 index 0000000..68d6d7f --- /dev/null +++ b/vhost.conf @@ -0,0 +1,3 @@ +# Increase default vhost memory map limit to match +# KVM's memory slot limit +options vhost max_mem_regions=509