mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
qemu/arm: remove nvdimm/"ReadOnly" option on arm64
There is a new "ReadOnly" option added to nvdimm device in qemu and now added to kata. However, qemu used for arm64 is a little old and has no this feature. Here we remove this feature for arm. Fixes: #2320 Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
This commit is contained in:
parent
1fbfd99d37
commit
77604de80b
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user