qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Persistent Main Memory in QEmu


From: Li, Tianyou
Subject: Re: [Qemu-devel] Persistent Main Memory in QEmu
Date: Fri, 22 Apr 2016 15:35:23 +0000

I found the mmap was invoked in qemu with option MAP_ANONYMOUS, which will zero 
pages. After a simple workaround right now pc.ram region will keep its content 
through reboot/shutdown. 

Thanks Dave and Artyom for the help!

Regards,
Tianyou

-----Original Message-----
From: Li, Tianyou 
Sent: Friday, April 22, 2016 11:09 AM
To: Dr. David Alan Gilbert <address@hidden>
Cc: Artyom Tarasenko <address@hidden>; address@hidden
Subject: RE: [Qemu-devel] Persistent Main Memory in QEmu

> I wonder if QEMU or the guest (BIOS? Kernel?)  is zeroing the memory ?  For 
> normal memory I'd expect it to zero it.

Zeroing page probably happens when allocating memory, I am not sure if it did 
happen once release the page. And, I am trying to find specific pattern of the 
content I write to the physical address of the guest, in the memory backed file 
in host, using bgrep. The result is no that kind of data was written into the 
memory backed file specified in -mem-path option. Could someone help on 
elaborating more details? Thanks.

Regards,
Tianyou

-----Original Message-----
From: Dr. David Alan Gilbert [mailto:address@hidden
Sent: Thursday, April 21, 2016 6:52 PM
To: Li, Tianyou <address@hidden>
Cc: Artyom Tarasenko <address@hidden>; address@hidden
Subject: Re: [Qemu-devel] Persistent Main Memory in QEmu

* Li, Tianyou (address@hidden) wrote:
> Hi Artyom, Dave & others,
> 
> An update: I have tried to use -mem-path option to make a file-backed memory. 
> I have tried to write a particular physical address in guest Linux OS with 
> specific value to verify the persistency characteristics. The result is not 
> as we expected. Below is more details.
> 
> 
> 1. guest os launch: qemu-system-x86_64 -monitor stdio -machine pc 
> -enable-kvm -smp 1  -m 8G  -mem-path ${RAM_FILE}  -device
> e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::5555-:22
> ${SRC_DIR}/../images/snapshot/arch-snapshot1.img
> 2. install fmem kernel module in guest linux, the code is here (quick 
> & dirty workaround for mem_write, please ignore):
> https://github.com/TianyouLi/fmem 3. run printf "worldhello" | dd 
> of=/dev/fmem bs=1 count=10 seek=6294967296 conv=notrunc 4. run dd 
> if=/dev/fmem bs=1 count=10 seek=6294967296 of=out
> 5. cat out   -------> here the result is "worldhello"
> 6. poweroff ---> guest shutdown
> 7. re-launch guest use #1
> 8. run #4, get memory content of same address 9. the result is not as 
> expected, all zero there
> 
> 
> I am looking into the code in numa.c of function 
> allocate_system_memory_nonnuma, which do init memory region and call 
> qemu_ram_mmap in mmap-alloc.c. Seems the mmap with fd has been setup 
> correctly so that memory data read/write should be flushed to file and 
> survive next time of boot. I am not quite clear why step #9 failed to get the 
> value we previous set in step #4. There could be the test methodology problem 
> or can be my in-correct understanding of qemu feature. Could you please 
> elaborate more details or give me some hints? Thanks.

I wonder if QEMU or the guest (BIOS? Kernel?)  is zeroing the memory ?  For 
normal memory I'd expect it to zero it.

Dave

> 
> 
> Regards,
> Tianyou
> 
> -----Original Message-----
> From: Li, Tianyou
> Sent: Tuesday, April 19, 2016 10:53 AM
> To: Artyom Tarasenko <address@hidden>
> Cc: address@hidden
> Subject: RE: [Qemu-devel] Persistent Main Memory in QEmu
> 
> Hi Artyom,
> 
> Thanks for your pointer! I have tried the -mem-path option, and right now 
> looking into the code to see if the content of the file will be used during 
> the guest Linux running next time. Will let you know the result. 
> 
> Stefan's post is definitely helpful, thanks for letting me know. Could you 
> please let me know if you have more QEmu memory management documentation 
> about internals? I have googled around, but more likely to hear from your 
> advice. Thanks.
> 
> Regards,
> Tianyou
> 
> -----Original Message-----
> From: Artyom Tarasenko [mailto:address@hidden
> Sent: Tuesday, April 19, 2016 4:20 AM
> To: Li, Tianyou <address@hidden>
> Cc: address@hidden
> Subject: Re: [Qemu-devel] Persistent Main Memory in QEmu
> 
> Hi Tianyou,
> 
> On Mon, Apr 18, 2016 at 5:50 AM, Li, Tianyou <address@hidden> wrote:
> > Currently we are trying to implement below functionalities in QEmu: 
> > main memory in guest can be logically viewed as persistent and its 
> > content can be survived through reboot or shutdown/powerup.
> >
> > I have looked into the QEmu memory management code include memory.c, 
> > exec.c and other related source, unfortunately I do not have the 
> > chance to get clue of how to make QEmu main memory persistent. I 
> > found that pmemsave could dump physical memory of guest, but I could 
> > not find how to restore the dump file before VM startup to execution.
> >
> >
> >
> > Could anyone provide some hints to me? Thanks in advance!
> 
> Is the option "-mem-path=/path/to/mem-file" what you are looking for?
> 
> Stefan wrote a nice post about QEMU RAM internals:
> http://blog.vmsplice.net/2016/01/qemu-internals-how-guest-physical-ram
> .html
> 
> Regards,
> Artyom
> 
> 
> --
> Regards,
> Artyom Tarasenko
> 
> SPARC and PPC PReP under qemu blog: 
> http://tyom.blogspot.com/search/label/qemu
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

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