mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-27 11:31:05 +00:00
Merge pull request #2441 from jongwu/ro_nv-2.1
backport: remove nvdimm/"ReadOnly" option on arm64
This commit is contained in:
commit
c243dd9500
@ -9,6 +9,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"os"
|
||||
|
||||
govmmQemu "github.com/kata-containers/govmm/qemu"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
@ -100,6 +101,35 @@ func (q *qemuArm64) appendImage(ctx context.Context, devices []govmmQemu.Device,
|
||||
return q.appendBlockImage(ctx, devices, path)
|
||||
}
|
||||
|
||||
// There is no nvdimm/readonly feature in qemu 5.1 which is used by arm64 for now,
|
||||
// so we temporarily add this specific implementation for arm64 here until
|
||||
// the qemu used by arm64 is capable for that feature
|
||||
func (q *qemuArm64) appendNvdimmImage(devices []govmmQemu.Device, path string) ([]govmmQemu.Device, error) {
|
||||
imageFile, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer imageFile.Close()
|
||||
|
||||
imageStat, err := imageFile.Stat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
object := govmmQemu.Object{
|
||||
Driver: govmmQemu.NVDIMM,
|
||||
Type: govmmQemu.MemoryBackendFile,
|
||||
DeviceID: "nv0",
|
||||
ID: "mem0",
|
||||
MemPath: path,
|
||||
Size: (uint64)(imageStat.Size()),
|
||||
}
|
||||
|
||||
devices = append(devices, object)
|
||||
|
||||
return devices, nil
|
||||
}
|
||||
|
||||
func (q *qemuArm64) setIgnoreSharedMemoryMigrationCaps(_ context.Context, _ *govmmQemu.QMP) error {
|
||||
// x-ignore-shared not support in arm64 for now
|
||||
return nil
|
||||
|
@ -126,10 +126,43 @@ func TestQemuArm64AppendImage(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.Equal(expectedOut, devices)
|
||||
|
||||
// restore default supportedQemuMachines options
|
||||
//restore default supportedQemuMachines options
|
||||
assert.Equal(len(supportedQemuMachines), copy(supportedQemuMachines, machinesCopy))
|
||||
}
|
||||
|
||||
func TestQemuArm64AppendNvdimmImage(t *testing.T) {
|
||||
var devices []govmmQemu.Device
|
||||
assert := assert.New(t)
|
||||
|
||||
f, err := ioutil.TempFile("", "img")
|
||||
assert.NoError(err)
|
||||
defer func() { _ = f.Close() }()
|
||||
defer func() { _ = os.Remove(f.Name()) }()
|
||||
|
||||
imageStat, err := f.Stat()
|
||||
assert.NoError(err)
|
||||
|
||||
cfg := qemuConfig(QemuVirt)
|
||||
cfg.ImagePath = f.Name()
|
||||
arm64, err := newQemuArch(cfg)
|
||||
assert.NoError(err)
|
||||
|
||||
expectedOut := []govmmQemu.Device{
|
||||
govmmQemu.Object{
|
||||
Driver: govmmQemu.NVDIMM,
|
||||
Type: govmmQemu.MemoryBackendFile,
|
||||
DeviceID: "nv0",
|
||||
ID: "mem0",
|
||||
MemPath: f.Name(),
|
||||
Size: (uint64)(imageStat.Size()),
|
||||
},
|
||||
}
|
||||
|
||||
devices, err = arm64.appendNvdimmImage(devices, f.Name())
|
||||
assert.NoError(err)
|
||||
assert.Equal(expectedOut, devices)
|
||||
}
|
||||
|
||||
func TestQemuArm64WithInitrd(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
@ -8,6 +8,11 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
ARCH=$(uname -m)
|
||||
|
||||
# Currently, Cloud Hypervisor only support arm64 and x86_64
|
||||
[ "${ARCH}" != "aarch64" ] && [ "${ARCH}" != "x86_64" ] && exit
|
||||
|
||||
script_dir=$(dirname $(readlink -f "$0"))
|
||||
kata_version="${kata_version:-}"
|
||||
|
||||
@ -50,7 +55,7 @@ build_clh_from_source() {
|
||||
popd
|
||||
}
|
||||
|
||||
if ! pull_clh_released_binary; then
|
||||
info "failed to pull cloud-hypervisor released binary, trying to build from source"
|
||||
if [ ${ARCH} == "aarch64" ] || ! pull_clh_released_binary; then
|
||||
info "arch is aarch64 or failed to pull cloud-hypervisor released binary on x86_64, trying to build from source"
|
||||
build_clh_from_source
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user