File: mdev_samples

package info (click to toggle)
nova 2%3A32.1.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 51,404 kB
  • sloc: python: 419,076; pascal: 1,848; sh: 991; makefile: 163; xml: 83
file content (46 lines) | stat: -rw-r--r-- 1,727 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 <<EOF
# Added by devstack
deb-src http://archive.ubuntu.com/ubuntu $DISTRO main restricted
deb-src http://archive.ubuntu.com/ubuntu $DISTRO-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu $DISTRO-security main restricted
EOF
    fi

    cat /etc/apt/sources.list
    sudo apt update
    sudo apt build-dep -y linux-image-unsigned-$kver
    sudo apt install -y libncurses-dev gawk flex bison openssl libssl-dev \
        dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf llvm \
        linux-headers-$kver

    mkdir $NOVA_KERNEL_TEMP
    cd $NOVA_KERNEL_TEMP
    apt source linux-image-unsigned-$kver > 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
}