From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wenchao Xia Subject: Re: [Qemu-devel] Are there plans to achieve ram live Snapshot feature? Date: Tue, 13 Aug 2013 10:53:23 +0800 Message-ID: <52099FA3.6010207@linux.vnet.ibm.com> References: <33FB050264B7AD4DBD6583581F2E03104B764728@nkgeml511-mbx.china.huawei.com> <20130812095903.GF29880@stefanha-thinkpad.redhat.com> <232DEBC1058FA4A5BD76D16A@Ximines.local> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Alex Bligh , Anthony Liguori , kvm , Marcelo Tosatti , qemu-devel , Chijianchun , Avi Kivity , Paul Brook , fred.konrad@greensocs.com To: Stefan Hajnoczi Return-path: Received: from e28smtp09.in.ibm.com ([122.248.162.9]:35910 "EHLO e28smtp09.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757196Ab3HMCyp (ORCPT ); Mon, 12 Aug 2013 22:54:45 -0400 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Aug 2013 08:19:00 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id A76A01258051 for ; Tue, 13 Aug 2013 08:24:19 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7D2txUh28704876 for ; Tue, 13 Aug 2013 08:25:59 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r7D2sc6Q004019 for ; Tue, 13 Aug 2013 08:24:39 +0530 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: =E4=BA=8E 2013-8-12 19:33, Stefan Hajnoczi =E5=86=99=E9=81=93: > On Mon, Aug 12, 2013 at 12:26 PM, Alex Bligh wrote= : >> --On 12 August 2013 11:59:03 +0200 Stefan Hajnoczi >> wrote: >> >>> The idea that was discussed on qemu-devel@nongnu.org uses fork(2) t= o >>> capture the state of guest RAM and then send it back to the parent >>> process. The guest is only paused for a brief instant during fork(= 2) >>> and can continue to run afterwards. >> >> >> How would you capture the state of emulated hardware which might not >> be in the guest RAM? > > Exactly the same way vmsave works today. It calls the device's save > functions which serialize state to file. > > The difference between today's vmsave and the fork(2) approach is tha= t > QEMU does not need to wait for guest RAM to be written to file before > resuming the guest. > > Stefan > I have a worry about what glib says: "On Unix, the GLib mainloop is incompatible with fork(). Any program using the mainloop must either exec() or exit() from the child without returning to the mainloop. " There is another way to do it: intercept the write in kvm.ko(or othe= r kernel code). Since the key is intercept the memory change, we can do it in userspace in TCG mode, thus we can add the missing part in KVM mode. Another benefit of this way is: the used memory can be controlled. For example, with ioctl(), set a buffer of a fixed size which keeps the intercepted write data by kernel code, which can avoid frequently switch back to user space qemu code. when it is full always return back to userspace's qemu code, let qemu code save the data into disk. I haven't check the exactly behavior of Intel guest mode about how to handle page fault, so can't estimate the performance caused by switching of guest mode and root mode, but it should not be worse than fork(). --=20 Best Regards Wenchao Xia