All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zack Cornelius <zack.cornelius@kove.net>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 0/3] hostmem-file: Add "discard-data" option
Date: Mon, 4 Sep 2017 11:56:14 -0500 (CDT)	[thread overview]
Message-ID: <985325221.20010.1504544174723.JavaMail.zimbra@kove.net> (raw)
In-Reply-To: <20170824192315.5897-1-ehabkost@redhat.com>

I've tested this patch set, and it has the expected results.

On a clean exit, with discard-data=on, madvise(MADV_REMOVE) is called, clearing any dirty data from RAM without needing to flush, and removing data from the underlying memory file. These results match our expected operation.


Run with the options:

qemu-system-x86_64 -smp 2 -m 8192 -enable-kvm -name ubuntu -vnc 0.0.0.0:5901 -object memory-backend-file,id=mem,size=4096M,mem-path=$MEM_PATH,share=on,discard-data=on -numa node,memdev=mem -mem-prealloc -hda $HD_PATH

While running (First output is the size on disk):

[root@sr3 qemu]# ls -ls /root/qemu_mem/qemu_memory.raw --block-size 1
8589934592 -rw-r--r--. 1 root root 8589934592 Sep  4 11:34 /root/qemu_mem/qemu_memory.raw

At exit, dirty data was dropped, instead of flushed to disk.

After shutting down, actual size on disk is 0:

[root@sr3 qemu]# ls -ls /root/qemu_mem/qemu_memory.raw 
0 -rw-r--r--. 1 root root 8589934592 Sep  4 11:35 /root/qemu_mem/qemu_memory.raw

--
Zack

----- Original Message -----
> From: "Eduardo Habkost" <ehabkost@redhat.com>
> To: qemu-devel@nongnu.org
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>, "Zack Cornelius" <zack.cornelius@kove.net>, "Paolo Bonzini"
> <pbonzini@redhat.com>, "Daniel P. Berrange" <berrange@redhat.com>, "Igor Mammedov" <imammedo@redhat.com>
> Sent: Thursday, August 24, 2017 2:23:12 PM
> Subject: [PATCH v2 0/3] hostmem-file: Add "discard-data" option

> This series adds a new "discard-data" option to
> memory-backend-file.  The new option will be useful if somebody
> is sharing RAM contents on a pre-existing file using share=on,
> but don't need data to be flushed to disk when QEMU exits.
> 
> Internally, it will trigger a madvise(MADV_REMOVE) call when the
> memory backend is removed or when QEMU exits.
> 
> To make we actually trigger the new code when QEMU exits, the
> first patch in the series ensures we destroy all user-created
> objects when exiting QEMU.
> 
> Changes v1 -> v2:
> * Original subject line of v1 was:
>  '[PATCH 0/5] hostmem-file: Add "persistent" option'
> * Replaced 'persistent=no' with 'discard-data=yes', to make it
>  clear that the flag will destroy data on the backing file.
> * Use qemu_madvise() instead of madvise()
>  * New patch added to series: "osdep: define QEMU_MADV_REMOVE"
> * Call qemu_madvise() directly from the backend unparent()
>  method, insteead of adding a new flag to the memory API and
>  reusing ram_block_discard_range()
>  * In addition to simplifying the code a lot, this fixes a bug,
>    because v1 relied on getting the memory region reference
>    count back to 0, which doesn't happen when QEMU is exiting
>    because there's no machine cleanup code to ensure that.
> 
> Eduardo Habkost (3):
>  vl: Clean up user-creatable objects when exiting
>  osdep: Define QEMU_MADV_REMOVE
>  hostmem-file: Add "discard-data" option
> 
> include/qemu/osdep.h            |  7 +++++++
> include/qom/object_interfaces.h |  8 ++++++++
> backends/hostmem-file.c         | 29 +++++++++++++++++++++++++++++
> qom/object_interfaces.c         |  5 +++++
> vl.c                            |  1 +
> qemu-options.hx                 |  5 ++++-
> 6 files changed, 54 insertions(+), 1 deletion(-)
> 
> --
> 2.9.4

  parent reply	other threads:[~2017-09-04 16:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 19:23 [Qemu-devel] [PATCH v2 0/3] hostmem-file: Add "discard-data" option Eduardo Habkost
2017-08-24 19:23 ` [Qemu-devel] [PATCH v2 1/3] vl: Clean up user-creatable objects when exiting Eduardo Habkost
2017-08-25 12:08   ` Philippe Mathieu-Daudé
2017-08-24 19:23 ` [Qemu-devel] [PATCH v2 2/3] osdep: Define QEMU_MADV_REMOVE Eduardo Habkost
2017-08-25 15:02   ` Dr. David Alan Gilbert
2017-08-24 19:23 ` [Qemu-devel] [PATCH v2 3/3] hostmem-file: Add "discard-data" option Eduardo Habkost
2017-08-29 11:13   ` Daniel P. Berrange
2017-08-29 13:12     ` Eduardo Habkost
2017-08-29 21:36       ` [Qemu-devel] [PATCH] fixup! " Eduardo Habkost
2017-08-30 10:15         ` Daniel P. Berrange
2017-09-04 16:56 ` Zack Cornelius [this message]
2017-09-14 19:35 ` [Qemu-devel] [PATCH v2 0/3] " Eduardo Habkost

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=985325221.20010.1504544174723.JavaMail.zimbra@kove.net \
    --to=zack.cornelius@kove.net \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.