mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-13 04:49:36 +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:
@@ -241,6 +241,10 @@ valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
|
||||
# The behaviour is undefined if mem_prealloc is also set to 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
|
||||
# to enable debug output where available.
|
||||
#
|
||||
|
@@ -28,6 +28,7 @@ type RuntimeConfigOptions struct {
|
||||
AgentTraceType string
|
||||
SharedFS string
|
||||
VirtioFSDaemon string
|
||||
PFlash []string
|
||||
PCIeRootPort uint32
|
||||
DisableBlock bool
|
||||
EnableIOThreads bool
|
||||
|
@@ -91,6 +91,7 @@ type hypervisor struct {
|
||||
VirtioFSDaemonList []string `toml:"valid_virtio_fs_daemon_paths"`
|
||||
VirtioFSCache string `toml:"virtio_fs_cache"`
|
||||
VirtioFSExtraArgs []string `toml:"virtio_fs_extra_args"`
|
||||
PFlashList []string `toml:"pflashes"`
|
||||
VirtioFSCacheSize uint32 `toml:"virtio_fs_cache_size"`
|
||||
BlockDeviceCacheSet bool `toml:"block_device_cache_set"`
|
||||
BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"`
|
||||
@@ -228,6 +229,23 @@ func (h hypervisor) firmware() (string, error) {
|
||||
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 {
|
||||
var machineAccelerators string
|
||||
for _, accelerator := range strings.Split(h.MachineAccelerators, ",") {
|
||||
@@ -581,6 +599,11 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
||||
return vc.HypervisorConfig{}, err
|
||||
}
|
||||
|
||||
pflashes, err := h.PFlash()
|
||||
if err != nil {
|
||||
return vc.HypervisorConfig{}, err
|
||||
}
|
||||
|
||||
if image != "" && initrd != "" {
|
||||
return vc.HypervisorConfig{},
|
||||
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,
|
||||
ImagePath: image,
|
||||
FirmwarePath: firmware,
|
||||
PFlash: pflashes,
|
||||
MachineAccelerators: machineAccelerators,
|
||||
CPUFeatures: cpuFeatures,
|
||||
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 []string
|
||||
|
||||
// PFlash image paths
|
||||
PFlash []string
|
||||
|
||||
// customAssets is a map of 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,
|
||||
|
@@ -262,6 +262,7 @@ func (q *qemu) setup(id string, hypervisorConfig *HypervisorConfig) error {
|
||||
}
|
||||
|
||||
q.arch.setBridges(q.state.Bridges)
|
||||
q.arch.setPFlash(q.config.PFlash)
|
||||
|
||||
if create {
|
||||
q.Logger().Debug("Creating bridges")
|
||||
@@ -572,6 +573,11 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
|
||||
return err
|
||||
}
|
||||
|
||||
pflash, err := q.arch.getPFlash()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
qemuPath, err := q.qemuPath()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -595,6 +601,7 @@ func (q *qemu) createSandbox(ctx context.Context, id string, networkNS NetworkNa
|
||||
VGA: "none",
|
||||
GlobalParam: "kvm-pit.lost_tick_policy=discard",
|
||||
Bios: firmwarePath,
|
||||
PFlash: pflash,
|
||||
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(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(config HypervisorConfig)
|
||||
|
||||
@@ -151,6 +157,7 @@ type qemuArchBase struct {
|
||||
kernelParamsDebug []Param
|
||||
kernelParams []Param
|
||||
Bridges []types.Bridge
|
||||
PFlash []string
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -798,3 +805,11 @@ func (q *qemuArchBase) appendPVPanicDevice(devices []govmmQemu.Device) ([]govmmQ
|
||||
devices = append(devices, govmmQemu.PVPanicDevice{NoShutdown: true})
|
||||
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)
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user