Deprecate pmem=on with non-DAX capable backend file
PATCH 1/1 Deprecate pmem=on with non-DAX capable backend file
It is not safe to pretend that emulated NVDIMM supports persistence while backend actually failed to enable it and used non-persistent mapping as fall back. Instead of falling-back, QEMU should be more strict and error out with clear message that it's not supported. So if user asks for persistence (pmem=on), they should store backing file on NVDIMM.
--- docs/system/deprecated.rst | 14 ++++++++++++++ util/mmap-alloc.c | 3 +++ 2 files changed, 17 insertions(+)
docs/system/deprecated.rst +14 -0
@@ -327,6 +327,20 @@ The Raspberry Pi machines come in various models (A, A+, B, B+). To be able to distinguish which model QEMU is implementing, the ``raspi2`` and ``raspi3`` machines have been renamed ``raspi2b`` and ``raspi3b``. +Backend options +--------------- + +Using non-persistent backing file with pmem=on (since 6.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +This option is used when ``memory-backend-file`` is consumed by emulated NVDIMM +device. However enabling ``memory-backend-file.pmem`` option, when backing file +is not DAX capable or not on a filesystem that support direct mapping of persistent +memory, is not safe and may lead to data loss or corruption in case of host crash. +Using pmem=on option with such file will return error, instead of a warning. +Options are to move backing file to NVDIMM storage or modify VM configuration +to set ``pmem=off`` to continue using fake NVDIMM without persistence guaranties. + Device options --------------
util/mmap-alloc.c +3 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu/mmap-alloc.h" #include "qemu/host-utils.h" +#include "qemu/error-report.h" #define HUGETLBFS_MAGIC 0x958458f6
@@ -166,6 +167,8 @@ void *qemu_ram_mmap(int fd, "crash.\n", file_name);g_free (proc_link);g_free (file_name); +warn_report ("Deprecated using non DAX backing file with" +" pmem=on option" ); }/* * if map failed with MAP_SHARED_VALIDATE | MAP_SYNC,
Signature · 1 line
2.27.0
Quoted 21 lines · Igor Mammedov
It is not safe to pretend that emulated NVDIMM supports persistence while backend actually failed to enable it and used non-persistent mapping as fall back. Instead of falling-back, QEMU should be more strict and error out with clear message that it's not supported. So if user asks for persistence (pmem=on), they should store backing file on NVDIMM.
Signed-off-by Igor Mammedov <[email protected]>--- docs/system/deprecated.rst | 14 ++++++++++++++ util/mmap-alloc.c | 3 +++ 2 files changed, 17 insertions(+)docs/system/deprecated.rst +0
-0@@ -327,6 +327,20 @@ The Raspberry Pi machines come in various models (A, A+, B, B+). To be able to distinguish which model QEMU is implementing, the ``raspi2`` and ``raspi3`` machines have been renamed ``raspi2b`` and ``raspi3b``.
docs/system/deprecated.rst The Raspberry Pi machines come in various models (A, A+, B, B+). To be able · line 338
Quoted 10 lines
docs/system/deprecated.rst +9
-0+Backend options +--------------- + +Using non-persistent backing file with pmem=on (since 6.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +This option is used when ``memory-backend-file`` is consumed by emulated NVDIMM +device. However enabling ``memory-backend-file.pmem`` option, when backing file +is not DAX capable or not on a filesystem that support direct mapping of persistent
Maybe clearer enumerating? As:
"is a) not DAX capable or b) not on a filesystem that support direct mapping of persistent"
docs/system/deprecated.rst The Raspberry Pi machines come in various models (A, A+, B, B+). To be able · line 340
Quoted 2 lines
docs/system/deprecated.rst +2
-0+memory, is not safe and may lead to data loss or corruption in case of host crash. +Using pmem=on option with such file will return error, instead of a warning.
Not sure the difference between warn/err is important in the doc.
docs/system/deprecated.rst The Raspberry Pi machines come in various models (A, A+, B, B+). To be able · line 342
Quoted 2 lines
docs/system/deprecated.rst +2
-0+Options are to move backing file to NVDIMM storage or modify VM configuration +to set ``pmem=off`` to continue using fake NVDIMM without persistence guaranties.
Maybe:
The possibilities to continue using fake NVDIMM (without persistence guaranties) are:
- move backing file to NVDIMM storage
- modify VM configuration to set ``pmem=off``
Quoted 17 lines
docs/system/deprecated.rst +1
-0+ Device options --------------util/mmap-alloc.c +1
-0@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu/mmap-alloc.h" #include "qemu/host-utils.h" +#include "qemu/error-report.h" #define HUGETLBFS_MAGIC 0x958458f6
util/mmap-alloc.c void *qemu_ram_mmap(int fd, · line 171
Quoted 5 lines
util/mmap-alloc.c +2
-0@@ -166,6 +167,8 @@ void *qemu_ram_mmap(int fd, "crash.\n", file_name);g_free (proc_link);g_free (file_name); +warn_report ("Deprecated using non DAX backing file with" +" pmem=on option" );
Maybe "Using non DAX backing file with 'pmem=on' option is deprecated"?
Beside the nitpicking comments,
Quoted 4 lines
util/mmap-alloc.c +0
-0}/* * if map failed with MAP_SHARED_VALIDATE | MAP_SYNC,
Quoted 23 lines · On Tue, 29 Dec 2020 19:04:58 +0100 Philippe Mathieu-Daudé <[email protected]>…
Quoted 22 lines · Igor Mammedov
It is not safe to pretend that emulated NVDIMM supports persistence while backend actually failed to enable it and used non-persistent mapping as fall back. Instead of falling-back, QEMU should be more strict and error out with clear message that it's not supported. So if user asks for persistence (pmem=on), they should store backing file on NVDIMM.
Signed-off-by Igor Mammedov <[email protected]>--- docs/system/deprecated.rst | 14 ++++++++++++++ util/mmap-alloc.c | 3 +++ 2 files changed, 17 insertions(+)docs/system/deprecated.rst +0
-0@@ -327,6 +327,20 @@ The Raspberry Pi machines come in various models (A, A+, B, B+). To be able to distinguish which model QEMU is implementing, the ``raspi2`` and ``raspi3`` machines have been renamed ``raspi2b`` and ``raspi3b``.
Quoted 13 lines
docs/system/deprecated.rst The Raspberry Pi machines come in various models (A, A+, B, B+). To be able · line 338
Quoted 9 lines
docs/system/deprecated.rst +9
-0+Backend options +--------------- + +Using non-persistent backing file with pmem=on (since 6.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +This option is used when ``memory-backend-file`` is consumed by emulated NVDIMM +device. However enabling ``memory-backend-file.pmem`` option, when backing file +is not DAX capable or not on a filesystem that support direct mapping of persistentMaybe clearer enumerating? As:
"is a) not DAX capable or b) not on a filesystem that support direct mapping of persistent"
will change it to your variant in v2
Quoted 5 lines
docs/system/deprecated.rst The Raspberry Pi machines come in various models (A, A+, B, B+). To be able · line 340
Quoted 3 lines
docs/system/deprecated.rst +2
-0+memory, is not safe and may lead to data loss or corruption in case of host crash. +Using pmem=on option with such file will return error, instead of a warning.Not sure the difference between warn/err is important in the doc.
not many care about warnings until QEMU starts fine,
I've mentioned error here so that whomever reading this would know what to expect
Quoted 10 lines
docs/system/deprecated.rst The Raspberry Pi machines come in various models (A, A+, B, B+). To be able · line 342
Quoted 3 lines
docs/system/deprecated.rst +2
-0+Options are to move backing file to NVDIMM storage or modify VM configuration +to set ``pmem=off`` to continue using fake NVDIMM without persistence guaranties.Maybe:
The possibilities to continue using fake NVDIMM (without persistence guaranties) are:
- move backing file to NVDIMM storage
- modify VM configuration to set ``pmem=off``
only the later is faking nvdimm, the first is properly emulated one with persistence guaranties. Maybe:
Options are:
- modify VM configuration to set ``pmem=off`` to continue using fake NVDIMM (without persistence guaranties) on with backing file on non DAX storage
- move backing file to NVDIMM storage and keep ``pmem=on``,
to have NVDIMM with persistence guaranties.
Quoted 16 lines
Quoted 16 lines
docs/system/deprecated.rst +1
-0+ Device options --------------util/mmap-alloc.c +1
-0@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu/mmap-alloc.h" #include "qemu/host-utils.h" +#include "qemu/error-report.h" #define HUGETLBFS_MAGIC 0x958458f6
Quoted 8 lines
util/mmap-alloc.c void *qemu_ram_mmap(int fd, · line 171
Quoted 6 lines
util/mmap-alloc.c +2
-0@@ -166,6 +167,8 @@ void *qemu_ram_mmap(int fd, "crash.\n", file_name);g_free (proc_link);g_free (file_name); +warn_report ("Deprecated using non DAX backing file with" +" pmem=on option" );Maybe "Using non DAX backing file with 'pmem=on' option is deprecated"?
ok
Quoted 9 lines
Beside the nitpicking comments,
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 4 lines
util/mmap-alloc.c +0
-0}/* * if map failed with MAP_SHARED_VALIDATE | MAP_SYNC,