mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +00:00
arm64: enable acpi for qemu/virt.
acpi is enabled for kata 1.x, port and rebase code for 2.x including: runtime: enable pflash; agent: add acpi support for pci bus path; packaging: enable CONFIG_RTC_DRV_EFI; Fixes: #1317 Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
This commit is contained in:
parent
4bb23ed990
commit
b7a1f752c0
@ -25,10 +25,18 @@ pub fn create_pci_root_bus_path() -> String {
|
|||||||
pub fn create_pci_root_bus_path() -> String {
|
pub fn create_pci_root_bus_path() -> String {
|
||||||
let ret = String::from("/devices/platform/4010000000.pcie/pci0000:00");
|
let ret = String::from("/devices/platform/4010000000.pcie/pci0000:00");
|
||||||
|
|
||||||
|
let acpi_root_bus_path = String::from("/devices/pci0000:00");
|
||||||
|
let mut acpi_sysfs_dir = String::from(SYSFS_DIR);
|
||||||
let mut sysfs_dir = String::from(SYSFS_DIR);
|
let mut sysfs_dir = String::from(SYSFS_DIR);
|
||||||
let mut start_root_bus_path = String::from("/devices/platform/");
|
let mut start_root_bus_path = String::from("/devices/platform/");
|
||||||
let end_root_bus_path = String::from("/pci0000:00");
|
let end_root_bus_path = String::from("/pci0000:00");
|
||||||
|
|
||||||
|
// check if there is pci bus path for acpi
|
||||||
|
acpi_sysfs_dir.push_str(&acpi_root_bus_path);
|
||||||
|
if let Ok(_) = fs::metadata(&acpi_sysfs_dir) {
|
||||||
|
return acpi_root_bus_path;
|
||||||
|
}
|
||||||
|
|
||||||
sysfs_dir.push_str(&start_root_bus_path);
|
sysfs_dir.push_str(&start_root_bus_path);
|
||||||
let entries = match fs::read_dir(sysfs_dir) {
|
let entries = match fs::read_dir(sysfs_dir) {
|
||||||
Ok(e) => e,
|
Ok(e) => e,
|
||||||
|
@ -241,6 +241,10 @@ valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
|||||||
# The behaviour is undefined if mem_prealloc is also set to true
|
# The behaviour is undefined if mem_prealloc is also set to true
|
||||||
#enable_swap = true
|
#enable_swap = true
|
||||||
|
|
||||||
|
# -pflash can add image file to VM. The arguments of it should be in format
|
||||||
|
# of ["/path/to/flash0.img", "/path/to/flash1.img"]
|
||||||
|
pflashes = []
|
||||||
|
|
||||||
# This option changes the default hypervisor and kernel parameters
|
# This option changes the default hypervisor and kernel parameters
|
||||||
# to enable debug output where available.
|
# to enable debug output where available.
|
||||||
#
|
#
|
||||||
|
@ -28,6 +28,7 @@ type RuntimeConfigOptions struct {
|
|||||||
AgentTraceType string
|
AgentTraceType string
|
||||||
SharedFS string
|
SharedFS string
|
||||||
VirtioFSDaemon string
|
VirtioFSDaemon string
|
||||||
|
PFlash []string
|
||||||
PCIeRootPort uint32
|
PCIeRootPort uint32
|
||||||
DisableBlock bool
|
DisableBlock bool
|
||||||
EnableIOThreads bool
|
EnableIOThreads bool
|
||||||
|
@ -91,6 +91,7 @@ type hypervisor struct {
|
|||||||
VirtioFSDaemonList []string `toml:"valid_virtio_fs_daemon_paths"`
|
VirtioFSDaemonList []string `toml:"valid_virtio_fs_daemon_paths"`
|
||||||
VirtioFSCache string `toml:"virtio_fs_cache"`
|
VirtioFSCache string `toml:"virtio_fs_cache"`
|
||||||
VirtioFSExtraArgs []string `toml:"virtio_fs_extra_args"`
|
VirtioFSExtraArgs []string `toml:"virtio_fs_extra_args"`
|
||||||
|
PFlashList []string `toml:"pflashes"`
|
||||||
VirtioFSCacheSize uint32 `toml:"virtio_fs_cache_size"`
|
VirtioFSCacheSize uint32 `toml:"virtio_fs_cache_size"`
|
||||||
BlockDeviceCacheSet bool `toml:"block_device_cache_set"`
|
BlockDeviceCacheSet bool `toml:"block_device_cache_set"`
|
||||||
BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"`
|
BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"`
|
||||||
@ -228,6 +229,23 @@ func (h hypervisor) firmware() (string, error) {
|
|||||||
return ResolvePath(p)
|
return ResolvePath(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h hypervisor) PFlash() ([]string, error) {
|
||||||
|
pflashes := h.PFlashList
|
||||||
|
|
||||||
|
if len(pflashes) == 0 {
|
||||||
|
return []string{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pflash := range pflashes {
|
||||||
|
_, err := ResolvePath(pflash)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, fmt.Errorf("failed to resolve path: %s: %v", pflash, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pflashes, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (h hypervisor) machineAccelerators() string {
|
func (h hypervisor) machineAccelerators() string {
|
||||||
var machineAccelerators string
|
var machineAccelerators string
|
||||||
for _, accelerator := range strings.Split(h.MachineAccelerators, ",") {
|
for _, accelerator := range strings.Split(h.MachineAccelerators, ",") {
|
||||||
@ -581,6 +599,11 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
return vc.HypervisorConfig{}, err
|
return vc.HypervisorConfig{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pflashes, err := h.PFlash()
|
||||||
|
if err != nil {
|
||||||
|
return vc.HypervisorConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
if image != "" && initrd != "" {
|
if image != "" && initrd != "" {
|
||||||
return vc.HypervisorConfig{},
|
return vc.HypervisorConfig{},
|
||||||
errors.New("having both an image and an initrd defined in the configuration file is not supported")
|
errors.New("having both an image and an initrd defined in the configuration file is not supported")
|
||||||
@ -645,6 +668,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
InitrdPath: initrd,
|
InitrdPath: initrd,
|
||||||
ImagePath: image,
|
ImagePath: image,
|
||||||
FirmwarePath: firmware,
|
FirmwarePath: firmware,
|
||||||
|
PFlash: pflashes,
|
||||||
MachineAccelerators: machineAccelerators,
|
MachineAccelerators: machineAccelerators,
|
||||||
CPUFeatures: cpuFeatures,
|
CPUFeatures: cpuFeatures,
|
||||||
KernelParams: vc.DeserializeParams(strings.Fields(kernelParams)),
|
KernelParams: vc.DeserializeParams(strings.Fields(kernelParams)),
|
||||||
|
@ -333,6 +333,9 @@ type HypervisorConfig struct {
|
|||||||
// FileBackedMemRootList is the list of valid root directories values for annotations
|
// FileBackedMemRootList is the list of valid root directories values for annotations
|
||||||
FileBackedMemRootList []string
|
FileBackedMemRootList []string
|
||||||
|
|
||||||
|
// PFlash image paths
|
||||||
|
PFlash []string
|
||||||
|
|
||||||
// customAssets is a map of assets.
|
// customAssets is a map of assets.
|
||||||
// Each value in that map takes precedence over the configured assets.
|
// Each value in that map takes precedence over the configured assets.
|
||||||
// For example, if there is a value for the "kernel" key in this map,
|
// For example, if there is a value for the "kernel" key in this map,
|
||||||
|
@ -262,6 +262,7 @@ func (q *qemu) setup(id string, hypervisorConfig *HypervisorConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
q.arch.setBridges(q.state.Bridges)
|
q.arch.setBridges(q.state.Bridges)
|
||||||
|
q.arch.setPFlash(q.config.PFlash)
|
||||||
|
|
||||||
if create {
|
if create {
|
||||||
q.Logger().Debug("Creating bridges")
|
q.Logger().Debug("Creating bridges")
|
||||||
@ -572,6 +573,11 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pflash, err := q.arch.getPFlash()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
qemuPath, err := q.qemuPath()
|
qemuPath, err := q.qemuPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -595,6 +601,7 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
|
|||||||
VGA: "none",
|
VGA: "none",
|
||||||
GlobalParam: "kvm-pit.lost_tick_policy=discard",
|
GlobalParam: "kvm-pit.lost_tick_policy=discard",
|
||||||
Bios: firmwarePath,
|
Bios: firmwarePath,
|
||||||
|
PFlash: pflash,
|
||||||
PidFile: filepath.Join(q.store.RunVMStoragePath(), q.id, "pid"),
|
PidFile: filepath.Join(q.store.RunVMStoragePath(), q.id, "pid"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +119,12 @@ type qemuArch interface {
|
|||||||
// addBridge adds a new Bridge to the list of Bridges
|
// addBridge adds a new Bridge to the list of Bridges
|
||||||
addBridge(types.Bridge)
|
addBridge(types.Bridge)
|
||||||
|
|
||||||
|
// getPFlash() get pflash from configuration
|
||||||
|
getPFlash() ([]string, error)
|
||||||
|
|
||||||
|
// setPFlash() grants access to pflash
|
||||||
|
setPFlash([]string)
|
||||||
|
|
||||||
// handleImagePath handles the Hypervisor Config image path
|
// handleImagePath handles the Hypervisor Config image path
|
||||||
handleImagePath(config HypervisorConfig)
|
handleImagePath(config HypervisorConfig)
|
||||||
|
|
||||||
@ -151,6 +157,7 @@ type qemuArchBase struct {
|
|||||||
kernelParamsDebug []Param
|
kernelParamsDebug []Param
|
||||||
kernelParams []Param
|
kernelParams []Param
|
||||||
Bridges []types.Bridge
|
Bridges []types.Bridge
|
||||||
|
PFlash []string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -798,3 +805,11 @@ func (q *qemuArchBase) appendPVPanicDevice(devices []govmmQemu.Device) ([]govmmQ
|
|||||||
devices = append(devices, govmmQemu.PVPanicDevice{NoShutdown: true})
|
devices = append(devices, govmmQemu.PVPanicDevice{NoShutdown: true})
|
||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *qemuArchBase) getPFlash() ([]string, error) {
|
||||||
|
return q.PFlash, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *qemuArchBase) setPFlash(p []string) {
|
||||||
|
q.PFlash = p
|
||||||
|
}
|
||||||
|
@ -119,3 +119,16 @@ func (q *qemuArm64) append9PVolume(devices []govmmQemu.Device, volume types.Volu
|
|||||||
devices = append(devices, d)
|
devices = append(devices, d)
|
||||||
return devices, nil
|
return devices, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *qemuArm64) getPFlash() ([]string, error) {
|
||||||
|
length := len(q.PFlash)
|
||||||
|
if length == 0 {
|
||||||
|
return nil, nil
|
||||||
|
} else if length == 1 {
|
||||||
|
return nil, fmt.Errorf("two pflash images needed for arm64")
|
||||||
|
} else if length == 2 {
|
||||||
|
return q.PFlash, nil
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("too many pflash images for arm64")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,3 +3,4 @@ CONFIG_EFI=y
|
|||||||
CONFIG_EFI_STUB=y
|
CONFIG_EFI_STUB=y
|
||||||
# ARM64 can run properly in ACPI hardware reduced mode.
|
# ARM64 can run properly in ACPI hardware reduced mode.
|
||||||
CONFIG_ACPI_REDUCED_HARDWARE_ONLY=y
|
CONFIG_ACPI_REDUCED_HARDWARE_ONLY=y
|
||||||
|
CONFIG_RTC_DRV_EFI=y
|
||||||
|
@ -24,10 +24,6 @@ CONFIG_PERF_EVENTS=y
|
|||||||
CONFIG_ARM64_PSEUDO_NMI=y
|
CONFIG_ARM64_PSEUDO_NMI=y
|
||||||
CONFIG_ARM64_SVE=y
|
CONFIG_ARM64_SVE=y
|
||||||
|
|
||||||
# Arm64 prefers to use REFCOUNT_FULL by default, disable it as the
|
|
||||||
# latest kernel has discarded it, add it to whitelist.
|
|
||||||
CONFIG_REFCOUNT_FULL=y
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# ARMv8.1 architectural features
|
# ARMv8.1 architectural features
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user