mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-26 11:39:29 +00:00
Merge pull request #2774 from Jakob-Naucke/fix-s390x-alignment
runtime: Fix !x86 static checks
This commit is contained in:
commit
04cdf5b1f0
@ -57,51 +57,51 @@ func TestArchKernelParamHandler(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
type testData struct {
|
type testData struct {
|
||||||
onVMM bool
|
|
||||||
expectIgnore bool
|
|
||||||
fields logrus.Fields
|
fields logrus.Fields
|
||||||
msg string
|
msg string
|
||||||
|
onVMM bool
|
||||||
|
expectIgnore bool
|
||||||
}
|
}
|
||||||
|
|
||||||
data := []testData{
|
data := []testData{
|
||||||
{true, false, logrus.Fields{}, ""},
|
{logrus.Fields{}, "", true, false},
|
||||||
{false, false, logrus.Fields{}, ""},
|
{logrus.Fields{}, "", false, false},
|
||||||
|
|
||||||
{
|
{
|
||||||
false,
|
|
||||||
false,
|
|
||||||
logrus.Fields{
|
logrus.Fields{
|
||||||
// wrong type
|
// wrong type
|
||||||
"parameter": 123,
|
"parameter": 123,
|
||||||
},
|
},
|
||||||
"foo",
|
"foo",
|
||||||
|
false,
|
||||||
|
false,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
false,
|
|
||||||
false,
|
|
||||||
logrus.Fields{
|
logrus.Fields{
|
||||||
"parameter": "unrestricted_guest",
|
"parameter": "unrestricted_guest",
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
|
false,
|
||||||
|
false,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
true,
|
|
||||||
true,
|
|
||||||
logrus.Fields{
|
logrus.Fields{
|
||||||
"parameter": "unrestricted_guest",
|
"parameter": "unrestricted_guest",
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
|
true,
|
||||||
|
true,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
false,
|
|
||||||
true,
|
|
||||||
logrus.Fields{
|
logrus.Fields{
|
||||||
"parameter": "nested",
|
"parameter": "nested",
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
|
false,
|
||||||
|
true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/runtime/virtcontainers/hypervisor_arm64.go
Normal file
10
src/runtime/virtcontainers/hypervisor_arm64.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) 2021 Arm Ltd.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package virtcontainers
|
||||||
|
|
||||||
|
//Returns pefProtection if the firmware directory exists
|
||||||
|
func availableGuestProtection() (guestProtection, error) {
|
||||||
|
return noneProtection, nil
|
||||||
|
}
|
@ -26,3 +26,10 @@ func TestRunningOnVMM(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(expectedOutput, running)
|
assert.Equal(expectedOutput, running)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAvailableGuestProtection(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
out, _ := availableGuestProtection()
|
||||||
|
assert.Equal(out, noneProtection)
|
||||||
|
}
|
||||||
|
@ -158,19 +158,23 @@ const (
|
|||||||
|
|
||||||
//Intel Trust Domain Extensions
|
//Intel Trust Domain Extensions
|
||||||
//https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html
|
//https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html
|
||||||
tdxProtection
|
// Exclude from lint checking for it won't be used on arm64 code
|
||||||
|
tdxProtection //nolint
|
||||||
|
|
||||||
// AMD Secure Encrypted Virtualization
|
// AMD Secure Encrypted Virtualization
|
||||||
// https://developer.amd.com/sev/
|
// https://developer.amd.com/sev/
|
||||||
sevProtection
|
// Exclude from lint checking for it won't be used on arm64 code
|
||||||
|
sevProtection //nolint
|
||||||
|
|
||||||
// IBM POWER 9 Protected Execution Facility
|
// IBM POWER 9 Protected Execution Facility
|
||||||
// https://www.kernel.org/doc/html/latest/powerpc/ultravisor.html
|
// https://www.kernel.org/doc/html/latest/powerpc/ultravisor.html
|
||||||
pefProtection
|
// Exclude from lint checking for it won't be used on arm64 code
|
||||||
|
pefProtection //nolint
|
||||||
|
|
||||||
// IBM Secure Execution (IBM Z & LinuxONE)
|
// IBM Secure Execution (IBM Z & LinuxONE)
|
||||||
// https://www.kernel.org/doc/html/latest/virt/kvm/s390-pv.html
|
// https://www.kernel.org/doc/html/latest/virt/kvm/s390-pv.html
|
||||||
seProtection
|
// Exclude from lint checking for it won't be used on arm64 code
|
||||||
|
seProtection //nolint
|
||||||
)
|
)
|
||||||
|
|
||||||
type qemuArchBase struct {
|
type qemuArchBase struct {
|
||||||
@ -183,7 +187,8 @@ type qemuArchBase struct {
|
|||||||
Bridges []types.Bridge
|
Bridges []types.Bridge
|
||||||
memoryOffset uint64
|
memoryOffset uint64
|
||||||
networkIndex int
|
networkIndex int
|
||||||
protection guestProtection
|
// Exclude from lint checking for it is ultimately only used in architecture-specific code
|
||||||
|
protection guestProtection //nolint:structcheck
|
||||||
nestedRun bool
|
nestedRun bool
|
||||||
vhost bool
|
vhost bool
|
||||||
disableNvdimm bool
|
disableNvdimm bool
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
govmmQemu "github.com/kata-containers/govmm/qemu"
|
govmmQemu "github.com/kata-containers/govmm/qemu"
|
||||||
@ -77,6 +78,7 @@ func newQemuArch(config HypervisorConfig) (qemuArch, error) {
|
|||||||
kernelParams: kernelParams,
|
kernelParams: kernelParams,
|
||||||
disableNvdimm: config.DisableImageNvdimm,
|
disableNvdimm: config.DisableImageNvdimm,
|
||||||
dax: true,
|
dax: true,
|
||||||
|
protection: noneProtection,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,3 +159,18 @@ func (q *qemuArm64) getPFlash() ([]string, error) {
|
|||||||
return nil, fmt.Errorf("too many pflash images for arm64")
|
return nil, fmt.Errorf("too many pflash images for arm64")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *qemuArm64) enableProtection() error {
|
||||||
|
q.protection, _ = availableGuestProtection()
|
||||||
|
if q.protection != noneProtection {
|
||||||
|
return fmt.Errorf("Protection %v is not supported on arm64", q.protection)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *qemuArm64) appendProtectionDevice(devices []govmmQemu.Device, firmware string) ([]govmmQemu.Device, string, error) {
|
||||||
|
err := q.enableProtection()
|
||||||
|
virtLog.WithField("arch", runtime.GOARCH).Warnf("%v", err)
|
||||||
|
return devices, firmware, err
|
||||||
|
}
|
||||||
|
@ -105,14 +105,11 @@ func TestQemuArm64AppendImage(t *testing.T) {
|
|||||||
imageStat, err := f.Stat()
|
imageStat, err := f.Stat()
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
// save default supportedQemuMachines options
|
|
||||||
machinesCopy := make([]govmmQemu.Machine, len(supportedQemuMachines))
|
|
||||||
assert.Equal(len(supportedQemuMachines), copy(machinesCopy, supportedQemuMachines))
|
|
||||||
|
|
||||||
cfg := qemuConfig(QemuVirt)
|
cfg := qemuConfig(QemuVirt)
|
||||||
cfg.ImagePath = f.Name()
|
cfg.ImagePath = f.Name()
|
||||||
arm64 := newQemuArch(cfg)
|
arm64, err := newQemuArch(cfg)
|
||||||
assert.Contains(m.machine().Options, qemuNvdimmOption)
|
assert.NoError(err)
|
||||||
|
assert.Contains(arm64.machine().Options, qemuNvdimmOption)
|
||||||
|
|
||||||
expectedOut := []govmmQemu.Device{
|
expectedOut := []govmmQemu.Device{
|
||||||
govmmQemu.Object{
|
govmmQemu.Object{
|
||||||
@ -128,9 +125,6 @@ func TestQemuArm64AppendImage(t *testing.T) {
|
|||||||
devices, err = arm64.appendImage(context.Background(), devices, f.Name())
|
devices, err = arm64.appendImage(context.Background(), devices, f.Name())
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(expectedOut, devices)
|
assert.Equal(expectedOut, devices)
|
||||||
|
|
||||||
//restore default supportedQemuMachines options
|
|
||||||
assert.Equal(len(supportedQemuMachines), copy(supportedQemuMachines, machinesCopy))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQemuArm64AppendNvdimmImage(t *testing.T) {
|
func TestQemuArm64AppendNvdimmImage(t *testing.T) {
|
||||||
@ -171,7 +165,8 @@ func TestQemuArm64WithInitrd(t *testing.T) {
|
|||||||
|
|
||||||
cfg := qemuConfig(QemuVirt)
|
cfg := qemuConfig(QemuVirt)
|
||||||
cfg.InitrdPath = "dummy-initrd"
|
cfg.InitrdPath = "dummy-initrd"
|
||||||
arm64 := newQemuArch(cfg)
|
arm64, err := newQemuArch(cfg)
|
||||||
|
assert.NoError(err)
|
||||||
|
|
||||||
assert.NotContains(m.machine().Options, qemuNvdimmOption)
|
assert.NotContains(arm64.machine().Options, qemuNvdimmOption)
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//nolint:deadcode,unused
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
// from <linux/vhost.h>
|
// from <linux/vhost.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user