mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
qemu: add pmem flag to memory-backend-file
According to QEMU's nvdimm documentation: When 'pmem' is 'on' and QEMU is built with libpmem support, QEMU will take necessary operations to guarantee the persistence of its own writes to the vNVDIMM backend. Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
3700c55dd7
commit
5378725f11
13
qemu/qmp.go
13
qemu/qmp.go
@ -1428,8 +1428,9 @@ func (q *QMP) ExecHotplugMemory(ctx context.Context, qomtype, id, mempath string
|
|||||||
// a NVDIMM driver with the device_add command.
|
// a NVDIMM driver with the device_add command.
|
||||||
// id is the id of the device to add. It must be a valid QMP identifier.
|
// id is the id of the device to add. It must be a valid QMP identifier.
|
||||||
// mempath is the path of the device to add, e.g., /dev/rdb0. size is
|
// mempath is the path of the device to add, e.g., /dev/rdb0. size is
|
||||||
// the data size of the device.
|
// the data size of the device. pmem is to guarantee the persistence of QEMU writes
|
||||||
func (q *QMP) ExecuteNVDIMMDeviceAdd(ctx context.Context, id, mempath string, size int64) error {
|
// to the vNVDIMM backend.
|
||||||
|
func (q *QMP) ExecuteNVDIMMDeviceAdd(ctx context.Context, id, mempath string, size int64, pmem *bool) error {
|
||||||
args := map[string]interface{}{
|
args := map[string]interface{}{
|
||||||
"qom-type": "memory-backend-file",
|
"qom-type": "memory-backend-file",
|
||||||
"id": "nvdimmbackmem" + id,
|
"id": "nvdimmbackmem" + id,
|
||||||
@ -1439,6 +1440,14 @@ func (q *QMP) ExecuteNVDIMMDeviceAdd(ctx context.Context, id, mempath string, si
|
|||||||
"share": true,
|
"share": true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if q.version.Major > 4 || (q.version.Major == 4 && q.version.Minor >= 1) {
|
||||||
|
if pmem != nil {
|
||||||
|
props := args["props"].(map[string]interface{})
|
||||||
|
props["pmem"] = *pmem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err := q.executeCommand(ctx, "object-add", args, nil)
|
err := q.executeCommand(ctx, "object-add", args, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1617,7 +1617,12 @@ func TestExecuteNVDIMMDeviceAdd(t *testing.T) {
|
|||||||
cfg := QMPConfig{Logger: qmpTestLogger{}}
|
cfg := QMPConfig{Logger: qmpTestLogger{}}
|
||||||
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
|
q := startQMPLoop(buf, cfg, connectedCh, disconnectedCh)
|
||||||
checkVersion(t, connectedCh)
|
checkVersion(t, connectedCh)
|
||||||
err := q.ExecuteNVDIMMDeviceAdd(context.Background(), "nvdimm0", "/dev/rbd0", 1024)
|
q.version = &QMPVersion{
|
||||||
|
Major: 4,
|
||||||
|
Minor: 1,
|
||||||
|
}
|
||||||
|
pmem := true
|
||||||
|
err := q.ExecuteNVDIMMDeviceAdd(context.Background(), "nvdimm0", "/dev/rbd0", 1024, &pmem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user