From e75d40ee12461d0befc7f5f823eaabbf8edc6685 Mon Sep 17 00:00:00 2001 From: Penny Zheng Date: Tue, 27 Nov 2018 17:45:35 +0800 Subject: [PATCH] qemu-arm64: Support nvdimm on arm64 Original guest image was reprensented as block device in qemu-aarch64, and it will bring up write lock error when running multiple containers. Thanks to the new expanded IPA_SIZE feature in kernel 4.20 and Eric Auger's related patch set in qemu(which are still under upstream review), we could fully support nvdimm on arm64. Fixes: #843 Signed-off-by: Penny Zheng --- virtcontainers/qemu_arm64.go | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/virtcontainers/qemu_arm64.go b/virtcontainers/qemu_arm64.go index 49c0923090..79e37ed98f 100644 --- a/virtcontainers/qemu_arm64.go +++ b/virtcontainers/qemu_arm64.go @@ -7,6 +7,7 @@ package virtcontainers import ( "io/ioutil" + "os" "runtime" "strings" @@ -24,7 +25,7 @@ const defaultQemuPath = "/usr/bin/qemu-system-aarch64" const defaultQemuMachineType = QemuVirt -var defaultQemuMachineOptions = "usb=off,accel=kvm,gic-version=" + getGuestGICVersion() +var defaultQemuMachineOptions = "usb=off,accel=kvm,nvdimm,gic-version=" + getGuestGICVersion() var qemuPaths = map[string]string{ QemuVirt: defaultQemuPath, @@ -37,7 +38,9 @@ var kernelParams = []Param{ } var kernelRootParams = []Param{ - {"root", "/dev/vda1"}, + {"root", "/dev/pmem0p1"}, + {"rootflags", "data=ordered,errors=remount-ro rw"}, + {"rootfstype", "ext4"}, } var supportedQemuMachines = []govmmQemu.Machine{ @@ -160,3 +163,29 @@ func (q *qemuArm64) bridges(number uint32) []types.PCIBridge { func (q *qemuArm64) appendBridges(devices []govmmQemu.Device, bridges []types.PCIBridge) []govmmQemu.Device { return genericAppendBridges(devices, bridges, q.machineType) } + +func (q *qemuArm64) appendImage(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 +}