qemu-discuss
[Top][All Lists]
Advanced

[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: Peter Maydell
Subject: Re: Initialize RAM from a file and save it to the file
Date: Mon, 19 Jul 2021 11:04:15 +0100

On Mon, 19 Jul 2021 at 10:35, Hiroko Shimizu <hiroko07168@gmail.com> 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().

If you want to put something specific into RAM on startup the
easiest way is to use the 'generic loader' on the command line:
https://qemu-project.gitlab.io/qemu/system/generic-loader.html

You only need to use memory_region_init_ram_from_file() if you
want guest changes to the RAM as it runs to be written back to
the file.

> I wonder what file format is necessary.

The file is mmap()ed, so it is raw binary.

If you really need the "write back guest memory changes" behaviour,
I would suggest that rather than making your machine create the
RAM memory region in a specific file-backed way, you instead
create the RAM memory region normally, and on the commandline
use
  -object memory-backend-file,id=myram,[other-options] -machine
memory-backend=myram
to make QEMU use that file backend for the machine's main RAM.
(Check the docs for what the 'other-options' ought to be.)

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]