diff mbox series

[2/2] mem/nvdimm: ensure persistence of QEMU writes to real NVDIMM device

Message ID 20171225010611.32621-3-haozhong.zhang@intel.com
State New
Headers show
Series None | expand

Commit Message

Haozhong Zhang Dec. 25, 2017, 1:06 a.m. UTC
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 <haozhong.zhang@intel.com>
---
 hw/mem/nvdimm.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

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;