mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-21 21:18:54 +00:00
kernel: support build guest kernel for gpu
Add option '-g' in build-kernel.sh to build a guest kernel that supports Intel/Nvidia GPU Fixes: #979 Signed-off-by: Jimmy Xu <junming.xjm@antfin.com>
This commit is contained in:
parent
3b88f2cd0f
commit
d248e4144c
@ -39,10 +39,16 @@ readonly default_kernel_config_dir="${GOPATH}/src/${kernel_config_repo}/kernel/c
|
||||
# Default path to search for kernel config fragments
|
||||
readonly default_config_frags_dir="${GOPATH}/src/${kernel_config_repo}/kernel/configs/fragments"
|
||||
readonly default_config_whitelist="${GOPATH}/src/${kernel_config_repo}/kernel/configs/fragments/whitelist.conf"
|
||||
# GPU vendor
|
||||
readonly GV_INTEL="intel"
|
||||
readonly GV_NVIDIA="nvidia"
|
||||
|
||||
#Path to kernel directory
|
||||
kernel_path=""
|
||||
#Experimental kernel support. Pull from virtio-fs GitLab instead of kernel.org
|
||||
experimental_kernel="false"
|
||||
#GPU kernel support
|
||||
gpu_vendor=""
|
||||
#
|
||||
patches_path=""
|
||||
#
|
||||
@ -80,11 +86,12 @@ Commands:
|
||||
|
||||
Options:
|
||||
|
||||
-c <path>: Path to config file to build a the kernel.
|
||||
-c <path> : Path to config file to build a the kernel.
|
||||
-e : Enable experimental kernel.
|
||||
-g <vendor> : GPU vendor, intel or nvidia.
|
||||
-h : Display this help.
|
||||
-k <path>: Path to kernel to build.
|
||||
-p <path>: Path to a directory with patches to apply to kernel.
|
||||
-k <path> : Path to kernel to build.
|
||||
-p <path> : Path to a directory with patches to apply to kernel.
|
||||
-t : Hypervisor_target.
|
||||
-v : Kernel version to use if kernel path not provided.
|
||||
EOT
|
||||
@ -167,6 +174,8 @@ get_major_kernel_version() {
|
||||
get_kernel_frag_path() {
|
||||
local arch_path="$1"
|
||||
local common_path="${arch_path}/../common"
|
||||
local gpu_path="${arch_path}/../gpu"
|
||||
|
||||
local kernel_path="$2"
|
||||
local cmdpath="${kernel_path}/scripts/kconfig/merge_config.sh"
|
||||
local config_path="${arch_path}/.config"
|
||||
@ -190,6 +199,12 @@ get_kernel_frag_path() {
|
||||
all_configs="${all_configs} ${experimental_configs}"
|
||||
fi
|
||||
|
||||
if [[ "${gpu_vendor}" != "" ]];then
|
||||
info "Add kernel config for GPU due to '-g ${gpu_vendor}'"
|
||||
local gpu_configs="$(ls ${gpu_path}/${gpu_vendor}.conf)"
|
||||
all_configs="${all_configs} ${gpu_configs}"
|
||||
fi
|
||||
|
||||
info "Constructing config from fragments: ${config_path}"
|
||||
|
||||
|
||||
@ -365,8 +380,17 @@ install_kata() {
|
||||
config_version=$(get_config_version)
|
||||
[ -n "${config_version}" ] || die "failed to get config version"
|
||||
install_path=$(readlink -m "${DESTDIR}/${PREFIX}/share/${project_name}")
|
||||
vmlinuz="vmlinuz-${kernel_version}-${config_version}"
|
||||
vmlinux="vmlinux-${kernel_version}-${config_version}"
|
||||
|
||||
suffix=""
|
||||
if [[ ${experimental_kernel} == "true" ]]; then
|
||||
suffix="-virtiofs"
|
||||
fi
|
||||
if [[ ${gpu_vendor} != "" ]];then
|
||||
suffix="-${gpu_vendor}-gpu${suffix}"
|
||||
fi
|
||||
|
||||
vmlinuz="vmlinuz-${kernel_version}-${config_version}${suffix}"
|
||||
vmlinux="vmlinux-${kernel_version}-${config_version}${suffix}"
|
||||
|
||||
if [ -e "arch/${arch_target}/boot/bzImage" ]; then
|
||||
bzImage="arch/${arch_target}/boot/bzImage"
|
||||
@ -392,21 +416,15 @@ install_kata() {
|
||||
|
||||
install --mode 0644 -D ./.config "${install_path}/config-${kernel_version}"
|
||||
|
||||
if [[ ${experimental_kernel} == "true" ]]; then
|
||||
sufix="-virtiofs.container"
|
||||
else
|
||||
sufix=".container"
|
||||
fi
|
||||
|
||||
ln -sf "${vmlinuz}" "${install_path}/vmlinuz${sufix}"
|
||||
ln -sf "${vmlinux}" "${install_path}/vmlinux${sufix}"
|
||||
ls -la "${install_path}/vmlinux${sufix}"
|
||||
ls -la "${install_path}/vmlinuz${sufix}"
|
||||
ln -sf "${vmlinuz}" "${install_path}/vmlinuz${suffix}.container"
|
||||
ln -sf "${vmlinux}" "${install_path}/vmlinux${suffix}.container"
|
||||
ls -la "${install_path}/vmlinux${suffix}.container"
|
||||
ls -la "${install_path}/vmlinuz${suffix}.container"
|
||||
popd >>/dev/null
|
||||
}
|
||||
|
||||
main() {
|
||||
while getopts "a:c:hk:p:t:v:e" opt; do
|
||||
while getopts "a:c:eg:hk:p:t:v:" opt; do
|
||||
case "$opt" in
|
||||
a)
|
||||
arch_target="${OPTARG}"
|
||||
@ -417,6 +435,10 @@ main() {
|
||||
e)
|
||||
experimental_kernel="true"
|
||||
;;
|
||||
g)
|
||||
gpu_vendor="${OPTARG}"
|
||||
[[ "${gpu_vendor}" == "${GV_INTEL}" || "${gpu_vendor}" == "${GV_NVIDIA}" ]] || die "GPU vendor only support intel and nvidia"
|
||||
;;
|
||||
h)
|
||||
usage 0
|
||||
;;
|
||||
|
7
kernel/configs/fragments/gpu/intel.conf
Normal file
7
kernel/configs/fragments/gpu/intel.conf
Normal file
@ -0,0 +1,7 @@
|
||||
# The following i915 kernel config options need to be enabled
|
||||
CONFIG_DRM=y
|
||||
CONFIG_DRM_I915=y
|
||||
CONFIG_DRM_I915_USERPTR=y
|
||||
|
||||
# Linux kernel version suffix
|
||||
CONFIG_LOCALVERSION="-intel-gpu"
|
14
kernel/configs/fragments/gpu/nvidia.conf
Normal file
14
kernel/configs/fragments/gpu/nvidia.conf
Normal file
@ -0,0 +1,14 @@
|
||||
# Support mmconfig PCI config space access.
|
||||
# It's used to enable the MMIO access method for PCIe devices.
|
||||
CONFIG_PCI_MMCONFIG=y
|
||||
|
||||
# Support for loading modules.
|
||||
# It is used to support loading GPU drivers.
|
||||
CONFIG_MODULES=y
|
||||
CONFIG_MODULE_UNLOAD=y
|
||||
|
||||
# CRYPTO_FIPS requires this config when loading modules is enabled.
|
||||
CONFIG_MODULE_SIG=y
|
||||
|
||||
# Linux kernel version suffix
|
||||
CONFIG_LOCALVERSION="-nvidia-gpu"
|
Loading…
Reference in New Issue
Block a user