mem/nvdimm: ensure write persistence to PMEM in label emulation

Guest writes to vNVDIMM labels are intercepted and performed on the
backend by QEMU. When the backend is a real persistent memort, QEMU
needs to take proper operations to ensure its write persistence on the
persistent memory. Otherwise, a host power failure may result in the
loss of guest label configurations.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Junyan He 2018-07-18 15:48:01 +08:00 committed by Michael S. Tsirkin
parent a4de8552b2
commit faf8a13d80
2 changed files with 38 additions and 1 deletions

30
include/qemu/pmem.h Normal file
View file

@ -0,0 +1,30 @@
/*
* QEMU header file for libpmem.
*
* Copyright (c) 2018 Intel Corporation.
*
* Author: Haozhong Zhang <address@hidden>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#ifndef QEMU_PMEM_H
#define QEMU_PMEM_H
#ifdef CONFIG_LIBPMEM
#include <libpmem.h>
#else /* !CONFIG_LIBPMEM */
static inline void *
pmem_memcpy_persist(void *pmemdest, const void *src, size_t len)
{
/* If 'pmem' option is 'on', we should always have libpmem support,
or qemu will report a error and exit, never come here. */
g_assert_not_reached();
return NULL;
}
#endif /* CONFIG_LIBPMEM */
#endif /* !QEMU_PMEM_H */