From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: Eric Blake <eblake@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Pavel Hrdina <phrdina@redhat.com>,
Juan Quintela <quintela@redhat.com>,
Stefan Hajnoczi <stefanha@gmail.com>,
qemu-devel <qemu-devel@nongnu.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Dietmar Maurer <dietmar@proxmox.com>
Subject: Re: [Qemu-devel] [RFC] qmp interface for save vmstate to image
Date: Sat, 23 Mar 2013 12:36:18 +0800 [thread overview]
Message-ID: <514D3142.9050000@linux.vnet.ibm.com> (raw)
In-Reply-To: <514B2277.8070502@redhat.com>
于 2013-3-21 23:08, Eric Blake 写道:
> On 03/21/2013 08:56 AM, Stefan Hajnoczi wrote:
>> On Thu, Mar 21, 2013 at 02:42:23PM +0100, Paolo Bonzini wrote:
>>> Il 21/03/2013 14:38, Stefan Hajnoczi ha scritto:
>>>> There already is a guest RAM cloning mechanism: fork the QEMU process.
>>>> Then you have a copy-on-write guest RAM.
>>>>
>>>> In a little more detail:
>>>>
>>>> 1. save non-RAM device state
>>>> 2. quiesce QEMU to a state that is safe for forking
>>>> 3. create an EventNotifier for live savevm completion signal
>>>> 4. fork and pass completion EventNotifier to child
>>>> 5. parent continues running VM
>>>> 6. child performs vmsave of copy-on-write guest RAM
>>>> 7. child signals completion EventNotifier and terminates
>>>> 8. parent raises live savevm completion QMP event
>>>
>>> Forking a threaded program is not so easy, but it could be done if the
>>> child is very simple and only uses syscalls to communicate back with the
>>> parent:
>>
>> On Linux you should be able to use clone(2) to spawn a thread with
>> copy-on-write memory. Too bad it's not portable because it gets around
>> the messy fork issues.
>
> And introduces its own messy issues - once you clone() using different
> flags than what fork() does, you have invalidated the use of a LOT of
> libc interfaces in that child; in particular, any use of pthread is
> liable to break.
>
I think the core of fork() is snapshot RAM pages with RAM, just like
LVM2's block snapshot, very cool idea :).
The problem is implemention, an API like following is needed:
void *mem_snapshot(void *addr, uint64_t len);
Briefly I haven't found it on Linux, and not sure if it is available
on upstream Linux kernel/C lib. Make this API available then use it
in qemu, would be much nicer.
It is very challenge to use fork()/clone() way in qemu, I guess
there will be many sparse code preparing for fork(), and some
resource handling code after fork(), code to query progress, exception
handling, child/parent talking mechnism, ah... seems complex. But I am
looking forward to see how good it is.
Compared with migration to image, the later one use less mem with
more I/O, but is much easier to be implemented and portable, maybe
it can be used as a simple improvement for "migrate to fd", before
an underlining mem snapshot API is available.
--
Best Regards
Wenchao Xia
next prev parent reply other threads:[~2013-03-23 4:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-15 7:24 [Qemu-devel] [RFC] qmp interface for save vmstate to image Wenchao Xia
2013-03-15 14:51 ` Stefan Hajnoczi
2013-03-18 6:40 ` Wenchao Xia
2013-03-18 9:04 ` Kevin Wolf
2013-03-18 10:08 ` Paolo Bonzini
2013-03-18 10:50 ` Wenchao Xia
2013-03-18 10:47 ` Wenchao Xia
2013-03-18 10:09 ` Stefan Hajnoczi
2013-03-18 13:28 ` Pavel Hrdina
2013-03-21 6:43 ` Wenchao Xia
2013-03-21 11:48 ` Pavel Hrdina
2013-03-21 13:38 ` Stefan Hajnoczi
2013-03-21 13:42 ` Paolo Bonzini
2013-03-21 13:53 ` Pavel Hrdina
2013-03-21 14:56 ` Stefan Hajnoczi
2013-03-21 15:08 ` Eric Blake
2013-03-23 4:36 ` Wenchao Xia [this message]
2013-03-27 3:35 ` Wenchao Xia
2013-03-21 13:43 ` Pavel Hrdina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=514D3142.9050000@linux.vnet.ibm.com \
--to=xiawenc@linux.vnet.ibm.com \
--cc=dietmar@proxmox.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=phrdina@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).