All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: ThinerLogoer <logoerthiner1@163.com>,
	"stefanha@redhat.com" <stefanha@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v1 1/3] softmmu/physmem: fallback to opening guest RAM file as readonly in a MAP_PRIVATE mapping
Date: Thu, 17 Aug 2023 15:45:46 +0100	[thread overview]
Message-ID: <ZN4ymrGbwBbLuiq7@redhat.com> (raw)
In-Reply-To: <5ee05caf-e149-9545-c6c5-abf0fc74097f@redhat.com>

On Thu, Aug 17, 2023 at 04:37:52PM +0200, David Hildenbrand wrote:
> On 17.08.23 16:37, Daniel P. Berrangé wrote:
> > On Thu, Aug 17, 2023 at 04:30:16PM +0200, David Hildenbrand wrote:
> > > 
> > > > @Stefan, do you have any concern when we would do 1) ?
> > > > 
> > > > As far as I can tell, we have to set the nvdimm to "unarmed=on" either way:
> > > > 
> > > > +   "unarmed" controls 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. Set unarmed to on when the memdev has readonly=on.
> > > > 
> > > > So changing the behavior would not really break the nvdimm use case.
> > > 
> > > Looking into the details, this seems to be the right thing to do.
> > > 
> > > This is what I have now as patch description, that also highlights how libvirt
> > > doesn't even make use of readonly=true.
> > > 
> > > 
> > >  From 42f272ace68e0cd660a8448adb5aefb3b9dd7005 Mon Sep 17 00:00:00 2001
> > > From: David Hildenbrand <david@redhat.com>
> > > Date: Thu, 17 Aug 2023 12:09:07 +0200
> > > Subject: [PATCH v2 2/4] backends/hostmem-file: Make share=off,readonly=on
> > >   result in RAM instead of ROM
> > > 
> > > For now, "share=off,readonly=on" would always result in us opening the
> > > file R/O and mmap'ing the opened file MAP_PRIVATE R/O -- effectively
> > > turning it into ROM.
> > > 
> > > As documented, readonly only specifies that we want to open the file R/O:
> > > 
> > >      @readonly: if true, the backing file is opened read-only; if false,
> > >          it is opened read-write.  (default: false)
> > > 
> > > Especially for VM templating, "share=off" is a common use case. However,
> > > that use case is impossible with files that lack write permissions,
> > > because "share=off,readonly=off" will fail opening the file, and
> > > "share=off,readonly=on" will give us ROM instead of RAM.
> > > 
> > > With MAP_PRIVATE we can easily open the file R/O and mmap it R/W, to
> > > turn it into COW RAM: private changes don't affect the file after all and
> > > don't require write permissions.
> > > 
> > > This implies that we only get ROM now via "share=on,readonly=on".
> > > "share=off,readonly=on" will give us RAM.
> > > 
> > > The sole user of ROM via memory-backend-file are R/O NVDIMMs. They
> > > also require "unarmed=on" to be set for the nvdimm device.
> > > 
> > > With this change, R/O NVDIMMs will continue working even if
> > > "share=off,readonly=on" was specified similar to when simply
> > > providing ordinary RAM to the nvdimm device and setting "unarmed=on".
> > > 
> > > Note that libvirt seems to default for a "readonly" nvdimm to
> > > * -object memory-backend-file,share=off (implying readonly=off)
> > > * -device nvdimm,unarmed=on
> > > And never seems to even set "readonly=on" for memory-backend-file. So
> > > this change won't affect libvirt, they already always get COW RAM -- not
> > > modifying the underlying file but opening it R/O.
> > > 
> > > If someone really wants ROM, they can just use "share=on,readonly=on".
> > > After all, there is not relevant difference between a R/O MAP_SHARED
> > > file mapping and a R/O MAP_PRIVATE file mapping.
> > > 
> > > Signed-off-by: David Hildenbrand <david@redhat.com>
> > 
> > This still leaves the patch having a warn_report() which I think is
> > undesirable to emit in a valid / supported use case.
> 
> No warning.
> 
> Please elaborate on "valid/supported use case".

The usage scenario that this patch aims to enable. IIUC, it will follow
the codepath that leads to the warn_report() call in this patch.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2023-08-17 14:46 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-07 19:07 [PATCH v1 0/3] softmmu/physmem: file_ram_open() readonly improvements David Hildenbrand
2023-08-07 19:07 ` [PATCH v1 1/3] softmmu/physmem: fallback to opening guest RAM file as readonly in a MAP_PRIVATE mapping David Hildenbrand
2023-08-08 21:01   ` Peter Xu
2023-08-09  5:39     ` ThinerLogoer
2023-08-09  9:20     ` David Hildenbrand
2023-08-09 15:15       ` Peter Xu
2023-08-10 14:19         ` David Hildenbrand
2023-08-10 17:06           ` ThinerLogoer
2023-08-10 21:24             ` Peter Xu
2023-08-11  5:49               ` ThinerLogoer
2023-08-11 14:31                 ` Peter Xu
2023-08-12  6:21                   ` ThinerLogoer
2023-08-22 13:35                     ` David Hildenbrand
2023-08-11 19:00                 ` David Hildenbrand
2023-08-12  5:18                   ` ThinerLogoer
2023-08-17  9:07                     ` David Hildenbrand
2023-08-17 14:30                       ` David Hildenbrand
2023-08-17 14:37                         ` Daniel P. Berrangé
2023-08-17 14:37                           ` David Hildenbrand
2023-08-17 14:45                             ` Daniel P. Berrangé [this message]
2023-08-17 14:47                               ` David Hildenbrand
2023-08-17 14:41                       ` Peter Xu
2023-08-17 15:02                         ` David Hildenbrand
2023-08-17 15:13                       ` Stefan Hajnoczi
2023-08-17 15:15                         ` David Hildenbrand
2023-08-17 15:25                           ` David Hildenbrand
2023-08-17 15:31                           ` Peter Xu
2023-08-17 15:43                             ` David Hildenbrand
2023-08-17 13:46                   ` Daniel P. Berrangé
2023-08-17 13:48                     ` David Hildenbrand
2023-08-11 14:59               ` David Hildenbrand
2023-08-11 15:26                 ` David Hildenbrand
2023-08-11 16:16                   ` Peter Xu
2023-08-11 16:17                     ` David Hildenbrand
2023-08-11 16:22                       ` Peter Xu
2023-08-11 16:25                         ` David Hildenbrand
2023-08-11 16:54                           ` Peter Xu
2023-08-11 17:39                             ` David Hildenbrand
2023-08-11 21:07                               ` Peter Xu
2023-08-21 12:20                   ` Igor Mammedov
2023-08-11 15:47                 ` Peter Xu
2023-08-17 13:42           ` Daniel P. Berrangé
2023-08-17 13:45             ` David Hildenbrand
2023-08-17 13:37   ` Daniel P. Berrangé
2023-08-17 13:44     ` David Hildenbrand
2023-08-07 19:07 ` [PATCH v1 2/3] softmmu/physmem: fail creation of new files in file_ram_open() with readonly=true David Hildenbrand
2023-08-07 19:07 ` [PATCH v1 3/3] softmmu/physmem: never return directories from file_ram_open() David Hildenbrand
2023-08-08 17:26 ` Re:[PATCH v1 0/3] softmmu/physmem: file_ram_open() readonly improvements ThinerLogoer
2023-08-10 11:11   ` [PATCH " Philippe Mathieu-Daudé
2023-08-10 16:35     ` ThinerLogoer

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=ZN4ymrGbwBbLuiq7@redhat.com \
    --to=berrange@redhat.com \
    --cc=david@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=logoerthiner1@163.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.