[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] mem/nvdimm: ensure persistence of QEMU writes t
From: |
Haozhong Zhang |
Subject: |
[Qemu-devel] [PATCH 2/2] mem/nvdimm: ensure persistence of QEMU writes to real NVDIMM device |
Date: |
Mon, 25 Dec 2017 09:06:11 +0800 |
QEMU intercepts guest writes to vNVDIMM labels, and then stores them
to the backend. When the backend is a real NVDIMM device, QEMU needs
to ensure the write persistence before returning to guest, so that the
guest labels will not be lost if QEMU exits abnormally.
Signed-off-by: Haozhong Zhang <address@hidden>
---
hw/mem/nvdimm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index 952fce5ec8..b644876eb1 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -23,6 +23,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/pmem.h"
#include "qapi/error.h"
#include "qapi/visitor.h"
#include "hw/mem/nvdimm.h"
@@ -135,6 +136,8 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvdimm,
const void *buf,
nvdimm_validate_rw_label_data(nvdimm, size, offset);
memcpy(nvdimm->label_data + offset, buf, size);
+ /* Make QEMU writes persistent in case the backend is a real NVDIMM. */
+ pmem_persistent(nvdimm->label_data + offset, size);
mr = host_memory_backend_get_memory(dimm->hostmem, &error_abort);
backend_offset = memory_region_size(mr) - nvdimm->label_size + offset;
--
2.14.1