[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Initialize RAM from a file and save it to the file
From: |
Igor Mammedov |
Subject: |
Re: Initialize RAM from a file and save it to the file |
Date: |
Mon, 19 Jul 2021 15:03:13 +0200 |
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.
>