Starting with the system I am working on:
Ryzen 9 3900x
MSI Mag b550 tomahawk
Vega 56 (host)
Gtx 1080ti (guest)
Fedora workstation 33
I have mainly been following two guides on installing the ACS patch on fedora.
https://wiki.myhypervisor.ca/books/linux/page/fedora-build-acs-override-patch-kernel
Both are similar but do have a few differences. I’m sure there are multiple ways to go about this, so it doesn’t surprise me that they do differ.
I’ve basically been copying the commands from these guides into my own bash script so that I have a history of everything I run, and can make comments to myself and whatnot.
Starting with a few questions that I have, I noticed that both guides download different ACS patches. If I remember correctly the github guide uses a patch for Fedora 5.6.x. I want to use a newer kernel (5.8 or 5.9) so I don’t think I can use that patch. The wiki.myhyperviser guide downloads a different patch and I am not sure if it will work for a newer kernel. And then there is the arch linux hosted acs patch which is what most of my googling comes to.
(https://aur.archlinux.org/pkgbase/linux-vfio/
I just want clarification on which acs patch I should use from someone that knows more than me.
My next question was about adding the build ID lines to the top of the kernel.spec file. Both guides do this and have you add the same lines of code but they don’t specify where beyond ‘near the top’. Currently, I have been inserting the build ID lines to line 31 of the kernel.spec file.
Lastly, I am stuck on the step where you compile the kernel. I’ve tried both rpmbuild -bb kernel.spec
and rpmbuild -bs ~/rpmbuild/SPECS/kernel.spec
from the two guides but neither worked. This is the error that I am receiving:
warning: Macro expanded in comment on line 758: %{rpmversion}-%{distro_build}.tar.bz2
warning: Macro expanded in comment on line 759: %{rpmversion}-%{distro_build}.tar.bz2
warning: Macro expanded in comment on line 767: %{rpmversion}-redhat.patch
error: %changelog not in descending chronological order
setting SOURCE_DATE_EPOCH=1604314239
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.tQDXsW
- umask 022
- cd /home/myname/rpmbuild/BUILD
ERROR: Patch add-acs-override.patch listed in specfile but is missing
error: Bad exit status from /var/tmp/rpm-tmp.tQDXsW (%prep)RPM build errors:
Macro expanded in comment on line 758: %{rpmversion}-%{distro_build}.tar.bz2Macro expanded in comment on line 759: %{rpmversion}-%{distro_build}.tar.bz2 Macro expanded in comment on line 767: %{rpmversion}-redhat.patch %changelog not in descending chronological order Bad exit status from /var/tmp/rpm-tmp.tQDXsW (%prep)
I’ve tried to figure out the rpm build errors but haven’t had any success on my own.
Here is the script that I have been using. There are a few duplicate commands (mostly downloading different acs patches) as I tried to see what worked best.
acs-script
#!/bin/bash
#Check for updates
sudo dnf check-update
sudo dnf upgrade#1 Add RPM Fusion
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-(rpm -E %fedora).noarch.rpm#2 Add dependencies to build your own kernel
sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel pesign rpmdevtools#3 Set home build directory
rpmdev-setuptree#4 Install the kernel source and finish installing dependencies
cd ~/rpmbuild/SOURCES
#koji download-build --arch=src kernel-4.18.5-200.fc28
#rpm -Uvh kernel-4.18.5-200.fc28.src.rpm
#changed downloaded kernel from 4.18.4-200 to 5.8.18-300 since I wanted a newer kernel than 4.18
koji download-build --arch=src kernel-5.8.18-300.fc33
rpm -Uvh kernel-5.8.18-300.fc33.src.rpm
cd ~/rpmbuild/SPECS/
sudo dnf builddep kernel.spec#5 Add the ACS patch (link) as ~/rpmbuild/SOURCES/add-acs-override.patch
#curl -o ~/rpmbuild/SOURCES/add-acs-override.patch https://raw.githubusercontent.com/Somersall-Natalie/fedora-acs-override/master/acs/add-acs-override.patch
#Here I strayed from the guides and downloaded the arch linux patch, and put it into the folder ~/acs-patch-files so that I could keep track of it easier
mkdir ~/acs-patch-files
cd ~/acs-patch-files
git clone https://aur.archlinux.org/linux-vfio.git
cp ~/acs-patch-files/linux-vfio/add-acs-overrides.patch ~/rpmbuild/SOURCES
#Then I copied the arch linux patch and put into the same folder ~/rpmbuild/SOURCES that the other guides do.#6 Edit ~/rpmbuild/SPECS/kernel.spec to set the build ID and add the patch. Since each release of the spec file could change, it’s not much help giving line numbers, but both of these should be near the top of the file.
#To set the build id, add the two lines near the top of the spec file with the other release information.
#https://stackoverflow.com/questions/487894/how-can-i-add-a-line-to-a-file-in-a-shell-script
#This edits the kernel.spec file and inserts code starting at line 31, CONFIRMED got the lines to insert and save correctly!
cd ~/rpmbuild/SPECS
ls
sed -i ‘31 i # Set buildid’ ./kernel.spec
sed -i ‘32 i %define buildid .acs’ ./kernel.spec
sed -i ‘33 i # ACS override patch’ ./kernel.spec
sed -i ‘34 i Patch1000: add-acs-override.patch’ ./kernel.spec
#This is the part of my script that inserts the build ID into the kernel.spec file#This overrights the old /rpmbuild/SPECS/add-acs-override.patch, FIXED ERROR MESSAGES, WILL KEEP
#cd ~/rpmbuild/SOURCES/
#wget https://git.myhypervisor.ca/dave/fedora-acs-override/raw/master/acs/add-acs-override.patch
#Me trying other acs patch files ^^#7 Compile! This takes a long time.
rpmbuild -bb kernel.spec
#^^^This did not seem to work well^^^^^#7 Alternate
#rpmbuild -bs ~/rpmbuild/SPECS/kernel.spec
#This also doesn’t seem to work ^^^#######################################################
Have not gotten past this point
#######################################################
#8 (ACS only) - Install the new packages!
#cd ~/rpmbuild/RPMS/x86_64
#sudo dnf update *.rpm#9 update and reboot
#sudo dnf clean all
#sudo dnf update -y
#sudo reboot
Somewhat related, what is the preferred method to post your code here? I was doing blockquotes but would prefer to have it collapsable as well. I’ll also upload a copy of my script if you’d prefer to look at it that way.fedora-acs-patch-nov102020.sh.txt (3.1 KB)
Thank you!