On 7/19/21 12:04 PM, Peter Maydell wrote: > On Mon, 19 Jul 2021 at 10:35, Hiroko Shimizu <hiroko07...@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.)
Ah great, this is surely what I was looking for, thanks =) Phil.