From dfa9c5bb9a6e9548267f3456724a5a1a7f342b06 Mon Sep 17 00:00:00 2001 From: Peter Ginchev Date: Tue, 11 Oct 2016 15:34:24 +0300 Subject: Rebind kernel drivers on VPP uninstall Change-Id: Icb0ce47134146c3a212b234f088c682982480128 Signed-off-by: Peter Ginchev --- build-root/deb/debian/vpp.postrm | 21 +++++++++++++++++++++ build-root/rpm/vpp.spec | 26 +++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 build-root/deb/debian/vpp.postrm (limited to 'build-root') diff --git a/build-root/deb/debian/vpp.postrm b/build-root/deb/debian/vpp.postrm new file mode 100644 index 00000000000..ac16a459d0f --- /dev/null +++ b/build-root/deb/debian/vpp.postrm @@ -0,0 +1,21 @@ +#!/bin/sh -e + +removed= + +# Unbind user-mode PCI drivers +pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci` +for d in $pci_dirs; do + for f in ${d}/*; do + [ -e "${f}/config" ] || continue + echo 1 > ${f}/remove + basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}` + removed=y + done +done +if [ -n "${removed}" ]; then + echo "There are changes in PCI drivers, rescaning" + echo 1 > /sys/bus/pci/rescan +else + echo "There weren't PCI devices binded" +fi + diff --git a/build-root/rpm/vpp.spec b/build-root/rpm/vpp.spec index d365060e5b4..b585579ed1e 100644 --- a/build-root/rpm/vpp.spec +++ b/build-root/rpm/vpp.spec @@ -17,12 +17,15 @@ %{!?python2_minor_version: %define python2_minor_version %(%{__python} -c "import sys ; print sys.version[2:3]")} +%{?systemd_requires} + Name: vpp Summary: Vector Packet Processing License: MIT Version: %{_version} Release: %{_release} Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils, python +BuildRequires: systemd %description This package provides VPP executables: vpp, vpp_api_test, vpp_json_test @@ -171,8 +174,29 @@ done sysctl --system %systemd_post vpp.service +%preun +%systemd_preun vpp.service + %postun -%systemd_postun_with_restart vpp.service +%systemd_postun + +# Unbind user-mode PCI drivers +removed= +pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci` +for d in $pci_dirs; do + for f in ${d}/*; do + [ -e "${f}/config" ] || continue + echo 1 > ${f}/remove + basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}` + removed=y + done +done +if [ -n "${removed}" ]; then + echo "There are changes in PCI drivers, rescaning" + echo 1 > /sys/bus/pci/rescan +else + echo "There weren't PCI devices binded" +fi %files %defattr(-,bin,bin) -- cgit 1.2.3-korg