function compile_mdev_samples { set -x local kver=$(uname -r) local kvariant=$(uname -r | awk -F - '{print $NF}') if [[ "$kvariant" == "kvm" ]]; then echo "NOTE: The kvm variant of the kernel you are running does not " \ "have the mdev support required to enable the mdev samples." echo "Install the generic variant and retry." exit 1 elif [[ "$kvariant" != "generic" ]]; then echo "NOTE: This may not work on your kernel variant of $kvariant!" echo "Recommend installing the generic variant kernel instead." fi if grep deb-src /etc/apt/sources.list; then sudo sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list else sudo tee -a /etc/apt/sources.list < kernel-source.log cd linux-*/samples/vfio-mdev sed -i 's/obj-[^ ]*/obj-m/' Makefile make -C /lib/modules/$(uname -r)/build M=$(pwd) modules sudo make -C /lib/modules/$(uname -r)/build M=$(pwd) modules_install sudo depmod for mod in $NOVA_MDEV_SAMPLES; do sudo modprobe $mod done lsmod | grep mdev }