qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org, Igor Mammedov <imammedo@redhat.com>
Cc: Xiao Guangrong <xiaoguangrong.eric@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Julio Montes <julio.montes@intel.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH 3/3] nvdimm: honor -object memory-backend-file, readonly=on option
Date: Fri, 21 Aug 2020 15:03:50 +0200	[thread overview]
Message-ID: <db6f0cae-88ee-fba0-2d2c-82255f52e7f6@redhat.com> (raw)
In-Reply-To: <20200804101244.1283503-4-stefanha@redhat.com>

On 8/4/20 12:12 PM, Stefan Hajnoczi wrote:
> Make it possible to present read-only files to the guest as "unarmed"
> NVDIMMs. The Linux NVDIMM device (/dev/pmemX) is read-only.
> 
> 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..c0b52de111 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 the file $PATH is opened read-only or

Double "the the".

> +   read/write (default). "readonly=on" sets the ACPI NFIT NVDIMM Region Mapping

NFIT acronym for 'NVDIMM Firmware Interface Table', "NVDIMM" sounds
redundant but makes it easier to understand, so OK.

> +   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..694223450e 100644
> --- a/hw/mem/nvdimm.c
> +++ b/hw/mem/nvdimm.c
> @@ -151,6 +151,10 @@ static void nvdimm_prepare_memory_region(NVDIMMDevice *nvdimm, Error **errp)
>                               "nvdimm-memory", mr, 0, pmem_size);
>      memory_region_set_nonvolatile(nvdimm->nvdimm_mr, true);
>      nvdimm->nvdimm_mr->align = align;
> +
> +    if (memory_region_is_rom(mr)) {
> +        nvdimm->unarmed = true; /* this device is read-only */
> +    }

Can you move this hunk before the alias creation?
(Just before nvdimm->nvdimm_mr = ...).

>  }
>  
>  static MemoryRegion *nvdimm_md_get_memory_region(MemoryDeviceState *md,

I don't understand why MemoryDeviceClass::get_memory_region() implicitly
calls DeviceClass::realize()...
Anyway unrelated to this patch.

With the comments addressed:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



  reply	other threads:[~2020-08-21 13:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-04 10:12 [PATCH 0/3] nvdimm: read-only file support Stefan Hajnoczi
2020-08-04 10:12 ` [PATCH 1/3] memory: add readonly support to memory_region_init_ram_from_file() Stefan Hajnoczi
2020-08-04 12:25   ` Philippe Mathieu-Daudé
2020-08-04 12:26     ` Philippe Mathieu-Daudé
2020-08-04 13:47       ` Stefan Hajnoczi
2020-08-04 13:57         ` Philippe Mathieu-Daudé
2020-08-04 10:12 ` [PATCH 2/3] hostmem-file: add readonly=on|off option Stefan Hajnoczi
2020-08-21 12:50   ` Philippe Mathieu-Daudé
2020-09-16  9:31     ` Stefan Hajnoczi
2020-09-16 10:17       ` Philippe Mathieu-Daudé
2020-08-04 10:12 ` [PATCH 3/3] nvdimm: honor -object memory-backend-file, readonly=on option Stefan Hajnoczi
2020-08-21 13:03   ` Philippe Mathieu-Daudé [this message]
2020-09-16  9:39     ` Stefan Hajnoczi
2020-08-04 12:28 ` [PATCH 0/3] nvdimm: read-only file support Michael S. Tsirkin
2020-08-21 12:18 ` 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=db6f0cae-88ee-fba0-2d2c-82255f52e7f6@redhat.com \
    --to=philmd@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=julio.montes@intel.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    --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).