mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-01 05:04:26 +00:00
qemu: support read-only nvdimm
Append `readonly=on` to a `memory-backend-file` object and `unarmed=on` to a `nvdimm` device when `ReadOnly` is set to `true` Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
f3533734ac
commit
0d21263a9b
@ -277,6 +277,9 @@ type Object struct {
|
|||||||
// ReducedPhysBits is the reduction in the guest physical address space
|
// ReducedPhysBits is the reduction in the guest physical address space
|
||||||
// This is only relevant for sev-guest objects
|
// This is only relevant for sev-guest objects
|
||||||
ReducedPhysBits uint32
|
ReducedPhysBits uint32
|
||||||
|
|
||||||
|
// ReadOnly specifies whether `MemPath` is opened read-only or read/write (default)
|
||||||
|
ReadOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid returns true if the Object structure is valid and complete.
|
// Valid returns true if the Object structure is valid and complete.
|
||||||
@ -315,6 +318,11 @@ func (object Object) QemuParams(config *Config) []string {
|
|||||||
deviceParams = append(deviceParams, string(object.Driver))
|
deviceParams = append(deviceParams, string(object.Driver))
|
||||||
deviceParams = append(deviceParams, fmt.Sprintf("id=%s", object.DeviceID))
|
deviceParams = append(deviceParams, fmt.Sprintf("id=%s", object.DeviceID))
|
||||||
deviceParams = append(deviceParams, fmt.Sprintf("memdev=%s", object.ID))
|
deviceParams = append(deviceParams, fmt.Sprintf("memdev=%s", object.ID))
|
||||||
|
|
||||||
|
if object.ReadOnly {
|
||||||
|
objectParams = append(objectParams, "readonly=on")
|
||||||
|
deviceParams = append(deviceParams, "unarmed=on")
|
||||||
|
}
|
||||||
case TDXGuest:
|
case TDXGuest:
|
||||||
objectParams = append(objectParams, string(object.Type))
|
objectParams = append(objectParams, string(object.Type))
|
||||||
objectParams = append(objectParams, fmt.Sprintf("id=%s", object.ID))
|
objectParams = append(objectParams, fmt.Sprintf("id=%s", object.ID))
|
||||||
|
@ -128,7 +128,7 @@ func TestAppendEmptyMachine(t *testing.T) {
|
|||||||
testAppend(machine, "", t)
|
testAppend(machine, "", t)
|
||||||
}
|
}
|
||||||
|
|
||||||
var deviceNVDIMMString = "-device nvdimm,id=nv0,memdev=mem0 -object memory-backend-file,id=mem0,mem-path=/root,size=65536"
|
var deviceNVDIMMString = "-device nvdimm,id=nv0,memdev=mem0,unarmed=on -object memory-backend-file,id=mem0,mem-path=/root,size=65536,readonly=on"
|
||||||
|
|
||||||
func TestAppendDeviceNVDIMM(t *testing.T) {
|
func TestAppendDeviceNVDIMM(t *testing.T) {
|
||||||
object := Object{
|
object := Object{
|
||||||
@ -138,6 +138,7 @@ func TestAppendDeviceNVDIMM(t *testing.T) {
|
|||||||
ID: "mem0",
|
ID: "mem0",
|
||||||
MemPath: "/root",
|
MemPath: "/root",
|
||||||
Size: 1 << 16,
|
Size: 1 << 16,
|
||||||
|
ReadOnly: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
testAppend(object, deviceNVDIMMString, t)
|
testAppend(object, deviceNVDIMMString, t)
|
||||||
|
Loading…
Reference in New Issue
Block a user