hostmem-file: add the 'pmem' option
PATCH RESEND v7 3/7 hostmem-file: add the 'pmem' option
From: Junyan He <[email protected]>
When QEMU emulates vNVDIMM labels and migrates vNVDIMM devices, it needs to know whether the backend storage is a real persistent memory, in order to decide whether special operations should be performed to ensure the data persistence.
This boolean option 'pmem' allows users to specify whether the backend storage of memory-backend-file is a real persistent memory. If 'pmem=on', QEMU will set the flag RAM_PMEM in the RAM block of the corresponding memory region.
--- backends/hostmem-file.c | 39 ++++++++++++++++++++++++++++++++++++++- docs/nvdimm.txt | 18 ++++++++++++++++++ exec.c | 9 +++++++++ include/exec/memory.h | 4 ++++ include/exec/ram_addr.h | 3 +++ qemu-options.hx | 7 +++++++ 6 files changed, 79 insertions(+), 1 deletion(-)
backends/hostmem-file.c +38 -1
@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/error-report.h" #include "sysemu/hostmem.h" #include "sysemu/sysemu.h" #include "qom/object_interfaces.h"
@@ -34,6 +35,7 @@ struct HostMemoryBackendFile {bool discard_data;char *mem_path;uint64_t align; +bool is_pmem; }; static void
@@ -59,7 +61,8 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)memory_region_init_ram_from_file (&backend->mr,OBJECT (backend), path, backend->size, fb->align, - backend->share ?RAM_SHARED :0 , + (backend->share ?RAM_SHARED :0 ) | + (fb->is_pmem ?RAM_PMEM :0 ), fb->mem_path, errp);g_free (path); }
@@ -131,6 +134,37 @@ static void file_memory_backend_set_align(Object *o, Visitor *v,error_propagate (errp, local_err); } +static bool file_memory_backend_get_pmem (Object *o,Error **errp) +{ +return MEMORY_BACKEND_FILE (o)->is_pmem; +} + +static void file_memory_backend_set_pmem (Object *o,bool value,Error **errp) +{ +HostMemoryBackend *backend =MEMORY_BACKEND (o); +HostMemoryBackendFile *fb =MEMORY_BACKEND_FILE (o); + +if (host_memory_backend_mr_inited (backend)) { +error_setg (errp,"cannot change property 'pmem' of %s '%s'" , +object_get_typename (o), +object_get_canonical_path_component (o)); +return ; + } + +#ifndef CONFIG_LIBPMEM +if (value) { +error_report ("Lack of libpmem support while setting the 'pmem=on'" +" of %s '%s'. We can not ensure the persistence of it" +" without libpmem support, this may cause serious" +" problems." ,object_get_typename (o), +object_get_canonical_path_component (o)); +exit (1 ); + } +#endif + + fb->is_pmem = value; +} +static void file_backend_unparent (Object *obj) {HostMemoryBackend *backend =MEMORY_BACKEND (obj);
@@ -162,6 +196,9 @@ file_backend_class_init(ObjectClass *oc, void *data) file_memory_backend_get_align, file_memory_backend_set_align, NULL, NULL, &error_abort); +object_class_property_add_bool (oc,"pmem" , + file_memory_backend_get_pmem, file_memory_backend_set_pmem, + &error_abort); }static void file_backend_instance_finalize (Object *o)
docs/nvdimm.txt +18 -0
@@ -180,3 +180,21 @@ supports CPU Cache Flush and Memory Controller Flush on Power Loss, etc. For a complete list of the flags available and for more detailed descriptions, please consult the ACPI spec. + +guest software that this vNVDIMM device contains a region that cannot +accept persistent writes. In result, for example, the guest Linux +NVDIMM driver, marks such vNVDIMM device as read-only. + +If the vNVDIMM backend is on the host persistent memory that can be +accessed in SNIA NVM Programming Model [1] (e.g., Intel NVDIMM), it's +suggested to set the 'pmem' option of memory-backend-file to 'on'. When +'pmem=on' and QEMU is built with libpmem [2] support (configured with +--enable-libpmem), QEMU will take necessary operations to guarantee +the persistence of its own writes to the vNVDIMM backend (e.g., in +vNVDIMM label emulation and live migration). + +References +---------- + +[1] SNIA NVM Programming Model: https://www.snia.org/sites/default/files/technical_work/final/NVMProgrammingModel_v1.2.pdf +[2] PMDK: http://pmem.io/pmdk/
exec.c +9 -0
@@ -2077,6 +2077,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,Error *local_err =NULL ;int64_t file_size; +/* Just support these ram flags by now. */ +assert (ram_flags ==0 || (ram_flags & (RAM_SHARED |RAM_PMEM ))); +if (xen_enabled ()) {error_setg (errp,"-mem-path not supported with Xen" );return NULL ;
@@ -4007,6 +4010,11 @@ err: return ret; } +bool ramblock_is_pmem (RAMBlock *rb) +{ +return rb->flags &RAM_PMEM ; +} +#endif void page_size_init (void )
@@ -4105,3 +4113,4 @@ void mtree_print_dispatch(fprintf_function mon, void *f, }#endif +
include/exec/memory.h +4 -0
@@ -122,6 +122,9 @@ typedef struct IOMMUNotifier IOMMUNotifier;/* RAM can be migrated */ #define RAM_MIGRATABLE (1 << 4) +/* RAM is a persistent kind memory */ +#define RAM_PMEM (1 << 5) +static inline void iommu_notifier_init (IOMMUNotifier *n,IOMMUNotify fn,IOMMUNotifierFlag flags,hwaddr start,hwaddr end)
@@ -613,6 +616,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,* (getpagesize()) will be used. * @ram_flags: Memory region features: * - RAM_SHARED: memory must be mmaped with the MAP_SHARED flag +* - RAM_PMEM: the memory is persistent memory * Other bits are ignored now. * @path: the path in which to allocate the RAM. * @errp: pointer to Error*, to store an error if it happens.
include/exec/ram_addr.h +3 -0
@@ -70,6 +70,8 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,return host_addr_offset >>TARGET_PAGE_BITS ; } +bool ramblock_is_pmem (RAMBlock *rb); +long qemu_getrampagesize (void );unsigned long last_ram_page (void );
@@ -84,6 +86,7 @@ unsigned long last_ram_page(void);* @ram_flags: specify the properties of the ram block, which can be one * or bit-or of following values * - RAM_SHARED: mmap the backing file or device with MAP_SHARED +* - RAM_PMEM: the backend @mem_path or @fd is persistent memory * Other bits are ignored. * @mem_path or @fd: specify the backing file or device * @errp: pointer to Error*, to store an error if it happens
qemu-options.hx +7 -0
@@ -4045,6 +4045,13 @@ requires an alignment different than the default one used by QEMU, eg the device DAX /dev/dax0.0 requires 2M alignment rather than 4K. In such cases, users can specify the required alignment via this option. +The @option{pmem} option specifies whether the backing file specified +by @option{mem-path} is on the persistent memory that can be accessed +using the SNIA NVM programming model (e.g. Intel NVDIMM). +If @option{pmem}, QEMU will take necessary operations to +guarantee the persistence of its own writes to @option{mem-path} +(e.g. in vNVDIMM label emulation and live migration). + @item -object memory-backend-ram,id=@var{id},merge=@var{on|off},dump=@var{on|off},share=@var{on|off},prealloc=@var{on|off},size=@var{size},host-nodes=@var{host-nodes},policy=@var{default|preferred|bind|interleave} Creates a memory backend object, which can be used to back the guest RAM.
Signature · 1 line
2.7.4
Quoted 7 lines · On Tue, 19 Jun 2018 11:28:19 +0800 [email protected] wrote:
From: Junyan He <[email protected]>
When QEMU emulates vNVDIMM labels and migrates vNVDIMM devices, it needs to know whether the backend storage is a real persistent memory, in order to decide whether special operations should be performed to ensure the data persistence.
Quoted 8 lines
This boolean option 'pmem' allows users to specify whether the backend storage of memory-backend-file is a real persistent memory. If 'pmem=on', QEMU will set the flag
RAM_PMEMin the RAM block of the corresponding memory region.Signed-off-by Junyan He <[email protected]>Signed-off-by Haozhong Zhang <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>
a couple suggestion wrt patch submission.
1.
do not sent next version of a patch from series on its own, you should rather send it as reply to the patch it replaces or resend whole series. to send as reply one can use
git send-email --in-reply-to="Message-Id value we are replying to" ...
2. it would be nice if you add changelog here after signatures like:
---
vX:
* the thing that changed wrt X-1
Quoted 97 lines
--- backends/hostmem-file.c | 39 ++++++++++++++++++++++++++++++++++++++- docs/nvdimm.txt | 18 ++++++++++++++++++ exec.c | 9 +++++++++ include/exec/memory.h | 4 ++++ include/exec/ram_addr.h | 3 +++ qemu-options.hx | 7 +++++++ 6 files changed, 79 insertions(+), 1 deletion(-)backends/hostmem-file.c +38
-1@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/error-report.h" #include "sysemu/hostmem.h" #include "sysemu/sysemu.h" #include "qom/object_interfaces.h" @@ -34,6 +35,7 @@ struct HostMemoryBackendFile {bool discard_data;char *mem_path;uint64_t align; +bool is_pmem; }; static void@@ -59,7 +61,8 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)memory_region_init_ram_from_file (&backend->mr,OBJECT (backend), path, backend->size, fb->align, - backend->share ?RAM_SHARED :0 , + (backend->share ?RAM_SHARED :0 ) | + (fb->is_pmem ?RAM_PMEM :0 ), fb->mem_path, errp);g_free (path); }@@ -131,6 +134,37 @@ static void file_memory_backend_set_align(Object *o, Visitor *v,error_propagate (errp, local_err); } +static bool file_memory_backend_get_pmem (Object *o,Error **errp) +{ +return MEMORY_BACKEND_FILE (o)->is_pmem; +} + +static void file_memory_backend_set_pmem (Object *o,bool value,Error **errp) +{ +HostMemoryBackend *backend =MEMORY_BACKEND (o); +HostMemoryBackendFile *fb =MEMORY_BACKEND_FILE (o); + +if (host_memory_backend_mr_inited (backend)) { +error_setg (errp,"cannot change property 'pmem' of %s '%s'" , +object_get_typename (o), +object_get_canonical_path_component (o)); +return ; + } + +#ifndef CONFIG_LIBPMEM +if (value) { +error_report ("Lack of libpmem support while setting the 'pmem=on'" +" of %s '%s'. We can not ensure the persistence of it" +" without libpmem support, this may cause serious" +" problems." ,object_get_typename (o), +object_get_canonical_path_component (o)); +exit (1 ); + } +#endif + + fb->is_pmem = value; +} +static void file_backend_unparent (Object *obj) {HostMemoryBackend *backend =MEMORY_BACKEND (obj);@@ -162,6 +196,9 @@ file_backend_class_init(ObjectClass *oc, void *data) file_memory_backend_get_align, file_memory_backend_set_align, NULL, NULL, &error_abort); +object_class_property_add_bool (oc,"pmem" , + file_memory_backend_get_pmem, file_memory_backend_set_pmem, + &error_abort); }static void file_backend_instance_finalize (Object *o)docs/nvdimm.txt +2
-0@@ -180,3 +180,21 @@ supports CPU Cache Flush and Memory Controller Flush on Power Loss, etc. For a complete list of the flags available and for more detailed descriptions, please consult the ACPI spec. + +guest software that this vNVDIMM device contains a region that cannot
docs/nvdimm.txt supports CPU Cache Flush and Memory Controller Flush on Power Loss, etc. · line 194
Quoted 10 lines
docs/nvdimm.txt +10
-0+accept persistent writes. In result, for example, the guest Linux +NVDIMM driver, marks such vNVDIMM device as read-only. + +If the vNVDIMM backend is on the host persistent memory that can be +accessed in SNIA NVM Programming Model [1] (e.g., Intel NVDIMM), it's +suggested to set the 'pmem' option of memory-backend-file to 'on'. When +'pmem=on' and QEMU is built with libpmem [2] support (configured with +--enable-libpmem), QEMU will take necessary operations to guarantee +the persistence of its own writes to the vNVDIMM backend (e.g., in +vNVDIMM label emulation and live migration).
will libpmem guarantee data persistence even if backend's file is not on persistent memory?
Quoted 98 lines
docs/nvdimm.txt +6
-0+ +References +---------- + +[1] SNIA NVM Programming Model: https://www.snia.org/sites/default/files/technical_work/final/NVMProgrammingModel_v1.2.pdf +[2] PMDK: http://pmem.io/pmdk/exec.c +9
-0@@ -2077,6 +2077,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,Error *local_err =NULL ;int64_t file_size; +/* Just support these ram flags by now. */ +assert (ram_flags ==0 || (ram_flags & (RAM_SHARED |RAM_PMEM ))); +if (xen_enabled ()) {error_setg (errp,"-mem-path not supported with Xen" );return NULL ;@@ -4007,6 +4010,11 @@ err: return ret; } +bool ramblock_is_pmem (RAMBlock *rb) +{ +return rb->flags &RAM_PMEM ; +} +#endif void page_size_init (void )@@ -4105,3 +4113,4 @@ void mtree_print_dispatch(fprintf_function mon, void *f, }#endif +include/exec/memory.h +4
-0@@ -122,6 +122,9 @@ typedef struct IOMMUNotifier IOMMUNotifier;/* RAM can be migrated */ #define RAM_MIGRATABLE (1 << 4) +/* RAM is a persistent kind memory */ +#define RAM_PMEM (1 << 5) +static inline void iommu_notifier_init (IOMMUNotifier *n,IOMMUNotify fn,IOMMUNotifierFlag flags,hwaddr start,hwaddr end)@@ -613,6 +616,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,* (getpagesize()) will be used. * @ram_flags: Memory region features: * - RAM_SHARED: memory must be mmaped with the MAP_SHARED flag +* - RAM_PMEM: the memory is persistent memory * Other bits are ignored now. * @path: the path in which to allocate the RAM. * @errp: pointer to Error*, to store an error if it happens. include/exec/ram_addr.h +3
-0@@ -70,6 +70,8 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,return host_addr_offset >>TARGET_PAGE_BITS ; } +bool ramblock_is_pmem (RAMBlock *rb); +long qemu_getrampagesize (void );unsigned long last_ram_page (void );@@ -84,6 +86,7 @@ unsigned long last_ram_page(void);* @ram_flags: specify the properties of the ram block, which can be one * or bit-or of following values * - RAM_SHARED: mmap the backing file or device with MAP_SHARED +* - RAM_PMEM: the backend @mem_path or @fd is persistent memory * Other bits are ignored. * @mem_path or @fd: specify the backing file or device * @errp: pointer to Error*, to store an error if it happens qemu-options.hx +7
-0@@ -4045,6 +4045,13 @@ requires an alignment different than the default one used by QEMU, eg the device DAX /dev/dax0.0 requires 2M alignment rather than 4K. In such cases, users can specify the required alignment via this option. +The @option{pmem} option specifies whether the backing file specified +by @option{mem-path} is on the persistent memory that can be accessed +using the SNIA NVM programming model (e.g. Intel NVDIMM). +If @option{pmem}, QEMU will take necessary operations to +guarantee the persistence of its own writes to @option{mem-path} +(e.g. in vNVDIMM label emulation and live migration). + @item -object memory-backend-ram,id=@var{id},merge=@var{on|off},dump=@var{on|off},share=@var{on|off},prealloc=@var{on|off},size=@var{size},host-nodes=@var{host-nodes},policy=@var{default|preferred|bind|interleave} Creates a memory backend object, which can be used to back the guest RAM.
Hi:
Do I still need to do something before it can be merged?
Thanks
Junyan
-----Original Message-----
From: Igor Mammedov [mailto:[email protected]]
Sent: Thursday, June 21, 2018 9:20 PM
To: [email protected]
Cc: [email protected]; Haozhong Zhang <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; He, Junyan <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH 3/7 V7 RESEND] hostmem-file: add the 'pmem' option
Quoted 7 lines · On Tue, 19 Jun 2018 11:28:19 +0800 [email protected] wrote:
From: Junyan He <[email protected]>
When QEMU emulates vNVDIMM labels and migrates vNVDIMM devices, it needs to know whether the backend storage is a real persistent memory, in order to decide whether special operations should be performed to ensure the data persistence.
Quoted 8 lines
This boolean option 'pmem' allows users to specify whether the backend storage of memory-backend-file is a real persistent memory. If 'pmem=on', QEMU will set the flag
RAM_PMEMin the RAM block of the corresponding memory region.Signed-off-by Junyan He <[email protected]>Signed-off-by Haozhong Zhang <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>
a couple suggestion wrt patch submission.
1.
do not sent next version of a patch from series on its own, you should rather send it as reply to the patch it replaces or resend whole series. to send as reply one can use git send-email --in-reply-to="Message-Id value we are replying to" ...
2. it would be nice if you add changelog here after signatures like:
---
vX:
* the thing that changed wrt X-1
Quoted 92 lines
--- backends/hostmem-file.c | 39 ++++++++++++++++++++++++++++++++++++++- docs/nvdimm.txt | 18 ++++++++++++++++++ exec.c | 9 +++++++++ include/exec/memory.h | 4 ++++ include/exec/ram_addr.h | 3 +++ qemu-options.hx | 7 +++++++ 6 files changed, 79 insertions(+), 1 deletion(-)backends/hostmem-file.c index renamed from backends/hostmem-file.c +0
-034c68bb..4607651 100644
backends/hostmem-file.c +37
-1@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/error-report.h" #include "sysemu/hostmem.h" #include "sysemu/sysemu.h" #include "qom/object_interfaces.h" @@ -34,6 +35,7 @@ struct HostMemoryBackendFile {bool discard_data;char *mem_path;uint64_t align; +bool is_pmem; }; static void@@ -59,7 +61,8 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)memory_region_init_ram_from_file (&backend->mr,OBJECT (backend), path, backend->size, fb->align, - backend->share ?RAM_SHARED :0 , + (backend->share ?RAM_SHARED :0 ) | + (fb->is_pmem ?RAM_PMEM :0 ), fb->mem_path, errp);g_free (path); }@@ -131,6 +134,37 @@ static void file_memory_backend_set_align(Object *o, Visitor *v,error_propagate (errp, local_err); } +static bool file_memory_backend_get_pmem (Object *o,Error **errp) { +return MEMORY_BACKEND_FILE (o)->is_pmem; } + +static void file_memory_backend_set_pmem (Object *o,bool value,Error +**errp) { +HostMemoryBackend *backend =MEMORY_BACKEND (o); +HostMemoryBackendFile *fb =MEMORY_BACKEND_FILE (o); + +if (host_memory_backend_mr_inited (backend)) { +error_setg (errp,"cannot change property 'pmem' of %s '%s'" , +object_get_typename (o), +object_get_canonical_path_component (o)); +return ; + } + +#ifndef CONFIG_LIBPMEM +if (value) { +error_report ("Lack of libpmem support while setting the 'pmem=on'" +" of %s '%s'. We can not ensure the persistence of it" +" without libpmem support, this may cause serious" +" problems." ,object_get_typename (o), +object_get_canonical_path_component (o)); +exit (1 ); + } +#endif + + fb->is_pmem = value; +} +static void file_backend_unparent (Object *obj) { HostMemoryBackend *backend = MEMORY_BACKEND(obj); @@ -162,6 +196,9 @@ file_backend_class_init(ObjectClass *oc, void *data) file_memory_backend_get_align, file_memory_backend_set_align, NULL, NULL, &error_abort); +object_class_property_add_bool (oc,"pmem" , + file_memory_backend_get_pmem, file_memory_backend_set_pmem, + &error_abort); } static void file_backend_instance_finalize(Object *o) diff --git
a/docs/nvdimm.txtb/docs/nvdimm.txtindex 8b48fb4..2f7d348 100644docs/nvdimm.txt +0
-0@@ -180,3 +180,21 @@ supports CPU Cache Flush and Memory Controller Flush on Power Loss, etc. For a complete list of the flags available and for more detaileddescriptions, please consult the ACPI spec.
docs/nvdimm.txt +2
-0+ +guest software that this vNVDIMM device contains a region that cannot
docs/nvdimm.txt supports CPU Cache Flush and Memory Controller Flush on Power Loss, etc.
Quoted 10 lines
docs/nvdimm.txt +10
-0+accept persistent writes. In result, for example, the guest Linux +NVDIMM driver, marks such vNVDIMM device as read-only. + +If the vNVDIMM backend is on the host persistent memory that can be +accessed in SNIA NVM Programming Model [1] (e.g., Intel NVDIMM), it's +suggested to set the 'pmem' option of memory-backend-file to 'on'. +When 'pmem=on' and QEMU is built with libpmem [2] support (configured +with --enable-libpmem), QEMU will take necessary operations to +guarantee the persistence of its own writes to the vNVDIMM backend +(e.g., in vNVDIMM label emulation and live migration).
will libpmem guarantee data persistence even if backend's file is not on persistent memory?
Quoted 101 lines
docs/nvdimm.txt +8
-0+ +References +---------- + +[1] SNIA NVM Programming Model: +https://www.snia.org/sites/default/files/technical_work/final/NVMProg +rammingModel_v1.2.pdf +[2] PMDK: http://pmem.io/pmdk/exec.c +9
-0@@ -2077,6 +2077,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,Error *local_err =NULL ;int64_t file_size; +/* Just support these ram flags by now. */ +assert (ram_flags ==0 || (ram_flags & (RAM_SHARED |RAM_PMEM ))); +if (xen_enabled ()) {error_setg (errp,"-mem-path not supported with Xen" );return NULL ;@@ -4007,6 +4010,11 @@ err: return ret; } +bool ramblock_is_pmem (RAMBlock *rb) +{ +return rb->flags &RAM_PMEM ; +} +#endif void page_size_init (void )@@ -4105,3 +4113,4 @@ void mtree_print_dispatch(fprintf_function mon, void *f, }#endif +include/exec/memory.h index renamed from include/exec/memory.h +0
-03769c06..7dd43b0 100644
include/exec/memory.h +3
-1@@ -122,6 +122,9 @@ typedef struct IOMMUNotifier IOMMUNotifier;/* RAM can be migrated */ #define RAM_MIGRATABLE (1 << 4) +/* RAM is a persistent kind memory */ #define RAM_PMEM (1 << 5) + static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn, IOMMUNotifierFlag flags, hwaddr start, hwaddr end) @@ -613,6 +616,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, * (getpagesize()) will be used. * @ram_flags: Memory region features: * - RAM_SHARED: memory must be mmaped with the MAP_SHARED flag + * - RAM_PMEM: the memory is persistent memory * Other bits are ignored now. * @path: the path in which to allocate the RAM. * @errp: pointer to Error*, to store an error if it happens.include/exec/ram_addr.h index renamed from include/exec/ram_addr.h +0
-05545cf3..3c65643 100644
include/exec/ram_addr.h +3
-1@@ -70,6 +70,8 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,return host_addr_offset >>TARGET_PAGE_BITS ; } +bool ramblock_is_pmem (RAMBlock *rb); +long qemu_getrampagesize (void );unsigned long last_ram_page (void );@@ -84,6 +86,7 @@ unsigned long last_ram_page(void);* @ram_flags: specify the properties of the ram block, which can be one * or bit-or of following values * - RAM_SHARED: mmap the backing file or device with MAP_SHARED +* - RAM_PMEM: the backend @mem_path or @fd is persistent memory * Other bits are ignored. * @mem_path or @fd: specify the backing file or device * @errp: pointer to Error*, to store an error if it happens diff --git a/qemu-options.hx b/qemu-options.hx index c0d3951..006ca44 100644
qemu-options.hx +0
-0@@ -4045,6 +4045,13 @@ requires an alignment different than thedefault one used by QEMU, eg the device DAX
/dev/dax0.0requires 2M
alignment rather than 4K. In such cases, users can specify the required alignment via this option.qemu-options.hx +7
-0+The @option{pmem} option specifies whether the backing file specified +by @option{mem-path} is on the persistent memory that can be accessed +using the SNIA NVM programming model (e.g. Intel NVDIMM). +If @option{pmem}, QEMU will take necessary operations to guarantee +the persistence of its own writes to @option{mem-path} (e.g. in +vNVDIMM label emulation and live migration). + @item -objectmemory-backend-ram,id=@var{id},merge=@var{on|off},dump=@var{on|off},sh are=@var{on|off},prealloc=@var{on|off},size=@var{size},host-nodes=@var {host-nodes},policy=@var{default|preferred|bind|interleave}
Creates a memory backend object, which can be used to back the guest RAM.
Quoted 3 lines · Junyan
Hi:
Do I still need to do something before it can be merged?
Unfortunately this missed 3.0 soft freeze (July 3).
I can still queue it for 3.1, but Igor had a question below that is still unanswered, and I have a new question below.
If you have to send a new version of a patch, please send it as a new version (e.g. "v8" instead of "v7 RESEND"). I thought this patch was the same as "[PATCH 3/7 V7]".
Questions below:
[...]
Quoted 12 lines
Quoted 12 lines
backends/hostmem-file.c +12
-0+static void file_memory_backend_set_pmem (Object *o,bool value,Error +**errp) { +HostMemoryBackend *backend =MEMORY_BACKEND (o); +HostMemoryBackendFile *fb =MEMORY_BACKEND_FILE (o); + +if (host_memory_backend_mr_inited (backend)) { +error_setg (errp,"cannot change property 'pmem' of %s '%s'" , +object_get_typename (o), +object_get_canonical_path_component (o)); +return ; + } +
Quoted 8 lines
backends/hostmem-file.c static void file_memory_backend_set_align(Object *o, Visitor *v, · line 161
Quoted 8 lines
backends/hostmem-file.c +8
-0+#ifndef CONFIG_LIBPMEM +if (value) { +error_report ("Lack of libpmem support while setting the 'pmem=on'" +" of %s '%s'. We can not ensure the persistence of it" +" without libpmem support, this may cause serious" +" problems." ,object_get_typename (o), +object_get_canonical_path_component (o)); +exit (1 );
Why error_report()+exit() instead of error_setg(errp)?
Quoted 6 lines
Quoted 6 lines
backends/hostmem-file.c +6
-0+ } +#endif + + fb->is_pmem = value; +} +
[...]
Quoted 23 lines
Quoted 10 lines
static void
file_backend_instance_finalize(Object *o)diff --gita/docs/nvdimm.txtb/docs/nvdimm.txtindex 8b48fb4..2f7d348 100644docs/nvdimm.txt +0
-0@@ -180,3 +180,21 @@ supports CPU Cache Flush and Memory Controller Flush on Power Loss, etc. For a complete list of the flags available and for more detaileddescriptions, please consult the ACPI spec.
docs/nvdimm.txt +2
-0+ +guest software that this vNVDIMM device contains a region that cannotdocs/nvdimm.txt supports CPU Cache Flush and Memory Controller Flush on Power Loss, etc.
Quoted 10 lines
docs/nvdimm.txt +10
-0+accept persistent writes. In result, for example, the guest Linux +NVDIMM driver, marks such vNVDIMM device as read-only. + +If the vNVDIMM backend is on the host persistent memory that can be +accessed in SNIA NVM Programming Model [1] (e.g., Intel NVDIMM), it's +suggested to set the 'pmem' option of memory-backend-file to 'on'. +When 'pmem=on' and QEMU is built with libpmem [2] support (configured +with --enable-libpmem), QEMU will take necessary operations to +guarantee the persistence of its own writes to the vNVDIMM backend +(e.g., in vNVDIMM label emulation and live migration).will libpmem guarantee data persistence even if backend's file is not on persistent memory?
Signature · 1 line
Eduardo