Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BinfmtMiscModuleConfigs = []string{
"CONFIG_BINFMT_MISC",
}
BinfmtMiscModuleConfigs lists the kernel config options needed for binfmt_misc support (used for QEMU user-mode emulation of cross-architecture binaries)
var BinfmtMiscModuleMap = map[string]string{
"CONFIG_BINFMT_MISC": "kernel/fs/binfmt_misc.ko.gz",
}
BinfmtMiscModuleMap maps kernel config options to module file paths
var GPUModuleConfigs = []string{
"CONFIG_DRM",
"CONFIG_DRM_KMS_HELPER",
"CONFIG_DRM_VIRTIO_GPU",
"CONFIG_VIRTIO_INPUT",
"CONFIG_INPUT_EVDEV",
}
GPUModuleConfigs lists the kernel config options needed for GPU support
var GPUModuleMap = map[string]string{
"CONFIG_DRM": "kernel/drivers/gpu/drm/drm.ko.gz",
"CONFIG_DRM_KMS_HELPER": "kernel/drivers/gpu/drm/drm_kms_helper.ko.gz",
"CONFIG_DRM_VIRTIO_GPU": "kernel/drivers/gpu/drm/virtio/virtio-gpu.ko.gz",
"CONFIG_VIRTIO_INPUT": "kernel/drivers/virtio/virtio_input.ko.gz",
"CONFIG_INPUT_EVDEV": "kernel/drivers/input/evdev.ko.gz",
}
GPUModuleMap maps kernel config options to module file paths
var VsockModuleConfigs = []string{
"CONFIG_VSOCKETS",
"CONFIG_VIRTIO_VSOCKETS",
}
VsockModuleConfigs lists the kernel config options needed for vsock support
var VsockModuleMap = map[string]string{
"CONFIG_VSOCKETS": "kernel/net/vmw_vsock/vsock.ko.gz",
"CONFIG_VIRTIO_VSOCKETS": "kernel/net/vmw_vsock/vmw_vsock_virtio_transport.ko.gz",
}
VsockModuleMap maps kernel config options to module file paths
Functions ¶
func ExportResources ¶ added in v0.0.2
func ExportResources(arch hv.CpuArchitecture, destDir string) error
ExportResources downloads the kernel for the given architecture and copies the cached files to destDir with standardized names for offline distribution. Files are named: linux-virt-<arch>.idx and linux-virt-<arch>.bin
func GetDefaultCachePath ¶
func SetDefaultCachePath ¶
func SetDefaultCachePath(path string)
Types ¶
type Kernel ¶
type Kernel interface {
Open() (File, error)
Size() (int64, error)
GetModuleDepends(name string) ([]string, error)
OpenModule(name string) ([]byte, error)
GetConfig() (map[string]Tristate, error)
GetDependMap() (map[string][]string, error)
GetSystemMap() (io.ReaderAt, error)
PlanModuleLoad(
configVars []string,
moduleMap map[string]string,
) ([]Module, error)
// GetKernelVersion returns the kernel version string (e.g., "6.6.63-0-virt").
// This is needed to construct the correct /lib/modules/<version>/ path.
GetKernelVersion() (string, error)
// GetModulesDirectory returns all files in the lib/modules/<version>/ directory.
// Files are returned with their relative paths and raw content (compressed files
// remain compressed). This is used to expose modules via virtiofs for modprobe.
GetModulesDirectory() ([]ModuleFile, error)
}
func LoadForArchitecture ¶
func LoadForArchitecture(arch hv.CpuArchitecture) (Kernel, error)
func LoadForArchitectureWithFallback ¶ added in v0.0.2
func LoadForArchitectureWithFallback(arch hv.CpuArchitecture, localResourceDir string) (Kernel, error)
LoadForArchitectureWithFallback tries to load a kernel from a local resources directory first, then falls back to downloading from the network. If localResourceDir is empty, it behaves the same as LoadForArchitecture.
func LoadFromDirectory ¶ added in v0.0.2
func LoadFromDirectory(arch hv.CpuArchitecture, dir string) (Kernel, error)
LoadFromDirectory loads a kernel from a pre-cached local directory. This is used for offline/bundled distribution where packages are stored next to the executable. The directory should contain files like: linux-virt-aarch64.idx, linux-virt-aarch64.bin for ARM64 linux-virt-x86_64.idx, linux-virt-x86_64.bin for x86_64
type ModuleFile ¶ added in v0.0.2
type ModuleFile struct {
Path string // relative path within lib/modules/<version>/
Data []byte // file content (raw, not decompressed)
Mode os.FileMode // file mode
Size int64 // file size
}
ModuleFile represents a file from the kernel modules directory. Used for exposing modules via virtiofs for modprobe support.