qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	Hiroko Shimizu <hiroko07168@gmail.com>,
	qemu-discuss <qemu-discuss@nongnu.org>
Subject: Re: Initialize RAM from a file and save it to the file
Date: Mon, 19 Jul 2021 15:03:13 +0200	[thread overview]
Message-ID: <20210719150313.382a0b01@redhat.com> (raw)
In-Reply-To: <a3af9417-d743-bb3e-2e46-597b728d1574@amsat.org>

On Mon, 19 Jul 2021 12:01:10 +0200
Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:

> Hi Hiroko,
> 
> On 7/19/21 11:34 AM, Hiroko Shimizu wrote:
> > Hello, 
> > I'd like to initialize RAM from a specific file when RAM is created.
> > Then,  I tried using memory_region_init_ram_from_file().   
...
> > Could you tell me what I need to do or another way to initialize RAM
> > from a file?
> > 
> > Also, is it possible to save RAM's value to the file when a value is
> > written to RAM which is initialized memory_region_init_ram_from_file()?  
> 
> 2 years ago I was using -mem-path /dev/shm/ (and maybe -mem-prealloc) to
> keep the ram sync on a file, pause the VM and analyse the memory, but it
> stopped working after the global memdev refactor. I don't think my use

-mem-path should still work as it's aliased to default memdev,
(see: create_default_memdev), that's assumes legacy CLI and that
board uses MachineState::ram as RAM.
(it certainly worked on mainstream boards, if you share your CLI
I can look if it's expected or a bug). 

For new CLI:
it's recommended to use '-machine memory-backend=' which points to previously
specified file backend, ex:

  -object memory-backend-file,id=myram,share=yes,size=1G,mem-path=/ram-image-file \
  -machine memory-backend=myram

Above will create memory region and assign it to MachineState::ram,
so one should use that instead of manually calling memory_region_init_ram_from_file().


> case was the expected one. Maybe I simply need to adapt to a new command
> line format :)
> 
> Now I use 'pmemsave' from the monitor:
> 
> pmemsave addr size file -- save to disk physical memory dump starting at
> 'addr' of size 'size'
> 
> If attached from GDB:
> 
> (gdb) monitor pmemsave 0x20000000 0x1000000 /tmp/ram.dump
> 
> There are other commands and probably a clever way to do that.
> 
> See also the VM snapshot feature, described here, which might be
> what you are looking for:
> https://translatedcode.wordpress.com/2015/07/06/tricks-for-debugging-qemu-savevm-snapshots/
> 
> Regards,
> 
> Phil.
> 



      reply	other threads:[~2021-07-19 13:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CACproumcn8Dba=Mt7ww-uFtb2kHpLsF36j0DiKEKQSVDtMPpcg@mail.gmail.com>
2021-07-19 10:01 ` Initialize RAM from a file and save it to the file Philippe Mathieu-Daudé
2021-07-19 13:03   ` Igor Mammedov [this message]

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=20210719150313.382a0b01@redhat.com \
    --to=imammedo@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=hiroko07168@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-discuss@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 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).