2

We're emulating a Cortex M3 cpu and would like to pass some parameters to the guest during run-time. The simplest idea seems to be to write directly to some memory area. I tried simply adding -mem-path /tmp/qemu.ram which did nothing. Adding

-object memory-backend-file,id=mem,size=128K,mem-path /tmp/qemu.ram \

worked in that qemu opened it at least. But nothing is written to it during run-time and there seems to be no connection between the guest memory map and the file at all.

To clarify, what I expected to happen is that QEMU, instead of mallocing guest RAM, mmaps the file and uses that instead. This would enable me to seek, read and write from this file during run-time. What am I missing? Is there any other convenient way to get write access to RAM/MMIO of the guest during run-time?

3
  • Try adding the share option: -object memory-backend-file,share=on,... (untested).
    – user313992
    Commented Oct 27, 2020 at 9:59
  • no difference :( Commented Oct 27, 2020 at 13:39
  • Look at all the other options for memory-backend-file, especially the id=ID ... -device memdev=ID combo. I'm not able to test it right now. Anyways, edit your Q and show the complete command line you're using and all the details so someone could be able to reproduce it.
    – user313992
    Commented Oct 27, 2020 at 14:10

1 Answer 1

1

I have successfully demonstrated this in qemu 8.0.3 (and failed in 4.2.1)

qemu-system-ppc -M ppce500,memory-backend=foo.ram -cpu e500 -m 256M,slots=2,maxmem=1g  -d guest_errors,unimp -bios $PWD/test.elf  -s -object memory-backend-file,size=256m,id=foo.ram,mem-path=$PWD/realmemory,share=on,prealloc=on 

The key is "memory-backend=foo.ram" and "-object memory-backend-file" that crossreferences id foo.ram. Specifically (to answer the top line question) adding "share=on" is critical to allow writes from inside the VM to be seen on the outside. Without that, reads will be seen but writes become local.

At least on this OS/program, I had to dig a bit into the backing file to see any memory changes, the first few pages of addresses were zero.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .