Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
ACPI: enable acpi for arm64 on qemu
Browse files Browse the repository at this point in the history
ACPI is dumb on arm64 when using qemu as VMM since no EFI firmware avaliable.
"-pflash" is enabled here. For arm64, EFI firmware can be stored in these
flash image and let ACPI be avaliable.

Fixes: #3078
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
  • Loading branch information
jongwu committed Dec 10, 2020
1 parent cafd967 commit 664f1b2
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/config/configuration-qemu.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ valid_file_mem_backends = @DEFVALIDFILEMEMBACKENDS@
# Default /var/run/kata-containers/cache.sock
#vm_cache_endpoint = "/var/run/kata-containers/cache.sock"

# -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 = []

[proxy.@PROJECT_TYPE@]
path = "@PROXYPATH@"

Expand Down
1 change: 1 addition & 0 deletions pkg/katatestutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type RuntimeConfigOptions struct {
AgentTraceType string
SharedFS string
VirtioFSDaemon string
PFlash []string
PCIeRootPort uint32
DisableBlock bool
EnableIOThreads bool
Expand Down
24 changes: 24 additions & 0 deletions pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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"`
Expand Down Expand Up @@ -250,6 +251,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), nil
}

for _, pflash := range pflashes {
_, err := ResolvePath(pflash)
if err != nil {
return []string{}, fmt.Errorf("pflash path doesn't exist: %s", pflash)
}
}

return pflashes, nil
}

func (h hypervisor) machineAccelerators() string {
var machineAccelerators string
for _, accelerator := range strings.Split(h.MachineAccelerators, ",") {
Expand Down Expand Up @@ -626,6 +644,11 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
return vc.HypervisorConfig{}, err
}

pflashes, err := h.PFlash()
if err != nil {
return vc.HypervisorConfig{}, err
}

machineAccelerators := h.machineAccelerators()
cpuFeatures := h.cpuFeatures()
kernelParams := h.kernelParams()
Expand Down Expand Up @@ -690,6 +713,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
VirtioFSCacheSize: h.VirtioFSCacheSize,
VirtioFSCache: h.defaultVirtioFSCache(),
VirtioFSExtraArgs: h.VirtioFSExtraArgs,
PFlash: pflashes,
MemPrealloc: h.MemPrealloc,
HugePages: h.HugePages,
IOMMU: h.IOMMU,
Expand Down
3 changes: 3 additions & 0 deletions virtcontainers/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ type HypervisorConfig struct {
// File based memory backend root directory
FileBackedMemRootDir string

// PFlash image paths
PFlash []string

// FileBackedMemRootList is the list of valid root directories values for annotations
FileBackedMemRootList []string

Expand Down
7 changes: 7 additions & 0 deletions virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,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")
Expand Down Expand Up @@ -570,6 +571,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
Expand All @@ -593,6 +599,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"),
}

Expand Down
15 changes: 15 additions & 0 deletions virtcontainers/qemu_arch_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -149,6 +155,7 @@ type qemuArchBase struct {
kernelParamsDebug []Param
kernelParams []Param
Bridges []types.Bridge
PFlash []string
}

const (
Expand Down Expand Up @@ -800,3 +807,11 @@ func (q *qemuArchBase) appendIOMMU(devices []govmmQemu.Device) ([]govmmQemu.Devi
return devices, fmt.Errorf("Machine Type %s does not support vIOMMU", q.machineType)
}
}

func (q *qemuArchBase) getPFlash() ([]string, error) {
return q.PFlash, nil
}

func (q *qemuArchBase) setPFlash(p []string) {
q.PFlash = p
}
13 changes: 13 additions & 0 deletions virtcontainers/qemu_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,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")
}
}

0 comments on commit 664f1b2

Please sign in to comment.