[Qemu-devel] [PATCH] fixup! hostmem-file: Add "discard-data" option

Eduardo Habkost posted 1 patch 8 years, 2 months ago
Failed in applying to current master (apply log)
qemu-options.hx | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH] fixup! hostmem-file: Add "discard-data" option
Posted by Eduardo Habkost 8 years, 2 months ago
On Tue, Aug 29, 2017 at 10:12:58AM -0300, Eduardo Habkost wrote:
> On Tue, Aug 29, 2017 at 12:13:45PM +0100, Daniel P. Berrange wrote:
> > On Thu, Aug 24, 2017 at 04:23:15PM -0300, Eduardo Habkost wrote:
[...]
> > > @@ -4172,6 +4172,9 @@ the path to either a shared memory or huge page filesystem mount.
> > >  The @option{share} boolean option determines whether the memory
> > >  region is marked as private to QEMU, or shared. The latter allows
> > >  a co-operating external process to access the QEMU memory region.
> > > +Setting the @option{discard-data} boolean option to @var{on}
> > > +indicates that file contents can be destroyed when QEMU exits,
> > > +to avoid unnecessarily flushing data to the backing file.
> > 
> > We should note that this only works if QEMU shuts down normally. If QEMU
> > is aggressively killed (SIGKILL) or aborts for some reason, then we'll
> > never get a chance to invoke madvise(), so presumably the kernel will
> > still flush the data
> 
> Good point.  I tried to not give any guarantees by saying
> "contents _can_ be destroyed", but users may still have different
> expectations.
> 
> I will change it to:
> 
>   Setting the @option{discard-data} boolean option to @var{on}
>   indicates that file contents can be destroyed when QEMU exits,
>   to avoid unnecessarily flushing data to the backing file.  Note
>   that @option{discard-data} is only an optimization, and QEMU
>   might not discard file contents if it aborts unexpectedly or is
>   terminated using SIGKILL.

Fixup patch:

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu-options.hx | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index ad985e4..de9a18a 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4174,7 +4174,10 @@ region is marked as private to QEMU, or shared. The latter allows
 a co-operating external process to access the QEMU memory region.
 Setting the @option{discard-data} boolean option to @var{on}
 indicates that file contents can be destroyed when QEMU exits,
-to avoid unnecessarily flushing data to the backing file.
+to avoid unnecessarily flushing data to the backing file.  Note
+that @option{discard-data} is only an optimization, and QEMU
+might not discard file contents if it aborts unexpectedly or is
+terminated using SIGKILL.
 
 @item -object rng-random,id=@var{id},filename=@var{/dev/random}
 
-- 
2.9.4

Re: [Qemu-devel] [PATCH] fixup! hostmem-file: Add "discard-data" option
Posted by Daniel P. Berrange 8 years, 2 months ago
On Tue, Aug 29, 2017 at 06:36:57PM -0300, Eduardo Habkost wrote:
> On Tue, Aug 29, 2017 at 10:12:58AM -0300, Eduardo Habkost wrote:
> > On Tue, Aug 29, 2017 at 12:13:45PM +0100, Daniel P. Berrange wrote:
> > > On Thu, Aug 24, 2017 at 04:23:15PM -0300, Eduardo Habkost wrote:
> [...]
> > > > @@ -4172,6 +4172,9 @@ the path to either a shared memory or huge page filesystem mount.
> > > >  The @option{share} boolean option determines whether the memory
> > > >  region is marked as private to QEMU, or shared. The latter allows
> > > >  a co-operating external process to access the QEMU memory region.
> > > > +Setting the @option{discard-data} boolean option to @var{on}
> > > > +indicates that file contents can be destroyed when QEMU exits,
> > > > +to avoid unnecessarily flushing data to the backing file.
> > > 
> > > We should note that this only works if QEMU shuts down normally. If QEMU
> > > is aggressively killed (SIGKILL) or aborts for some reason, then we'll
> > > never get a chance to invoke madvise(), so presumably the kernel will
> > > still flush the data
> > 
> > Good point.  I tried to not give any guarantees by saying
> > "contents _can_ be destroyed", but users may still have different
> > expectations.
> > 
> > I will change it to:
> > 
> >   Setting the @option{discard-data} boolean option to @var{on}
> >   indicates that file contents can be destroyed when QEMU exits,
> >   to avoid unnecessarily flushing data to the backing file.  Note
> >   that @option{discard-data} is only an optimization, and QEMU
> >   might not discard file contents if it aborts unexpectedly or is
> >   terminated using SIGKILL.
> 
> Fixup patch:
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  qemu-options.hx | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-options.hx b/qemu-options.hx
> index ad985e4..de9a18a 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -4174,7 +4174,10 @@ region is marked as private to QEMU, or shared. The latter allows
>  a co-operating external process to access the QEMU memory region.
>  Setting the @option{discard-data} boolean option to @var{on}
>  indicates that file contents can be destroyed when QEMU exits,
> -to avoid unnecessarily flushing data to the backing file.
> +to avoid unnecessarily flushing data to the backing file.  Note
> +that @option{discard-data} is only an optimization, and QEMU
> +might not discard file contents if it aborts unexpectedly or is
> +terminated using SIGKILL.
>  
>  @item -object rng-random,id=@var{id},filename=@var{/dev/random}

For the combined patch:

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>

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 :|