From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Julio Montes" <julio.montes@intel.com>,
"Xiao Guangrong" <xiaoguangrong.eric@gmail.com>,
eric.g.ernst@gmail.com, "Stefan Hajnoczi" <stefanha@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Richard Henderson" <rth@twiddle.net>
Subject: [PATCH v2 3/3] nvdimm: honor -object memory-backend-file, readonly=on option
Date: Wed, 16 Sep 2020 10:51:50 +0100 [thread overview]
Message-ID: <20200916095150.755714-4-stefanha@redhat.com> (raw)
In-Reply-To: <20200916095150.755714-1-stefanha@redhat.com>
Make it possible to present read-only files to the guest as "unarmed"
NVDIMMs. The Linux NVDIMM device (/dev/pmemX) is read-only.
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
docs/nvdimm.txt | 8 +++++++-
hw/mem/nvdimm.c | 4 ++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/docs/nvdimm.txt b/docs/nvdimm.txt
index c2c6e441b3..06c2008107 100644
--- a/docs/nvdimm.txt
+++ b/docs/nvdimm.txt
@@ -17,7 +17,7 @@ following command line options:
-machine pc,nvdimm
-m $RAM_SIZE,slots=$N,maxmem=$MAX_SIZE
- -object memory-backend-file,id=mem1,share=on,mem-path=$PATH,size=$NVDIMM_SIZE
+ -object memory-backend-file,id=mem1,share=on,mem-path=$PATH,size=$NVDIMM_SIZE,readonly=off
-device nvdimm,id=nvdimm1,memdev=mem1
Where,
@@ -42,6 +42,12 @@ Where,
"share=off", then guest writes won't be applied to the backend
file and thus will be invisible to other guests.
+ "readonly=on/off" controls whether the file $PATH is opened read-only or
+ read/write (default). "readonly=on" sets the ACPI NFIT NVDIMM Region Mapping
+ Structure "NVDIMM State Flags" Bit 3 indicating that the device is "unarmed"
+ and cannot accept persistent writes. Linux guest drivers set the device to
+ read-only when this bit is present.
+
- "device nvdimm,id=nvdimm1,memdev=mem1" creates a virtual NVDIMM
device whose storage is provided by above memory backend device.
diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
index e1574bc07c..848cd65917 100644
--- a/hw/mem/nvdimm.c
+++ b/hw/mem/nvdimm.c
@@ -146,6 +146,10 @@ static void nvdimm_prepare_memory_region(NVDIMMDevice *nvdimm, Error **errp)
return;
}
+ if (memory_region_is_rom(mr)) {
+ nvdimm->unarmed = true; /* this device is read-only */
+ }
+
nvdimm->nvdimm_mr = g_new(MemoryRegion, 1);
memory_region_init_alias(nvdimm->nvdimm_mr, OBJECT(dimm),
"nvdimm-memory", mr, 0, pmem_size);
--
2.26.2
next prev parent reply other threads:[~2020-09-16 9:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 9:51 [PATCH v2 0/3] nvdimm: read-only file support Stefan Hajnoczi
2020-09-16 9:51 ` [PATCH v2 1/3] memory: add readonly support to memory_region_init_ram_from_file() Stefan Hajnoczi
2020-12-14 11:01 ` Igor Mammedov
2020-09-16 9:51 ` [PATCH v2 2/3] hostmem-file: add readonly=on|off option Stefan Hajnoczi
2020-12-14 11:10 ` Igor Mammedov
2021-01-04 15:42 ` Stefan Hajnoczi
2021-01-04 21:20 ` Eduardo Habkost
2020-09-16 9:51 ` Stefan Hajnoczi [this message]
2020-12-14 11:19 ` [PATCH v2 3/3] nvdimm: honor -object memory-backend-file, readonly=on option Igor Mammedov
2021-01-04 16:05 ` Stefan Hajnoczi
2020-09-23 12:41 ` [PATCH v2 0/3] nvdimm: read-only file support Stefan Hajnoczi
2020-12-10 16:48 ` Liam Merwick
2021-01-04 15:43 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200916095150.755714-4-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=ehabkost@redhat.com \
--cc=eric.g.ernst@gmail.com \
--cc=imammedo@redhat.com \
--cc=julio.montes@intel.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=xiaoguangrong.eric@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).