public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Frank Berreth <frankber@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: Save/Restore not working
Date: Tue, 19 Jul 2011 14:20:01 -0300	[thread overview]
Message-ID: <20110719172001.GB31673@amt.cnet> (raw)
In-Reply-To: <CADrbSvKdomEXAtAcHAk=t_2uDZ6GH0KbWCj14dYHgJrob-7GFw@mail.gmail.com>

On Mon, Jul 18, 2011 at 03:46:56PM -0700, Frank Berreth wrote:
> Hello,
> 
> I am working on save/restore code (independent of Qemu or KVM tools)
> and am having trouble doing 'the right thing' with KVM it seems. I do
> have trouble finding good documentation on specifically save or
> restore (besides the description of IOCTLs) and there is a high chance
> I am doing something goofy here.
> 
> The way I am save/restoring is simply saving the state I get through
> the different KVM IOCTLs and dumping it back on restore. The exception
> is restoring of the MSRs, where I first get the list, then get the
> MSRS and save/restore only those that were filled in by KVM.
> 
> The restore order is the following:
> 
> first restore memory, then
> KVM_SET_REGS
> KVM_SET_FPU
> KVM_SET_SREGS
> KVM_SET_MSRS
> KVM_SET_MPSTATE
> KVM_SET_LAPIC
> some user mode devices and then
> KVM_SET_PIT
> KVM_SET_IRQCHIP (3 times, for MASTER, SLAVE and IOAPIC)

KVM_SET_VCPU_EVENTS is missing from this list.

Also note this comment from api.txt:

NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO and KVM_EXIT_OSI, the corresponding
operations are complete (and guest state is consistent) only after
userspace
has re-entered the kernel with KVM_RUN.  The kernel side will first
finish
incomplete operations and then check for pending signals.  Userspace
can re-enter the guest with an unmasked signal pending to complete
pending operations.


> I am running different tests to test the save/restore code. One test
> for example will compile the linux kernel within the guest while the
> VM is saved, destroyed, re-create and finally restored & resumed
> during compilation (every 10 seconds) on the same physical machine.
> 
> The behavior I get is different depending on KVM version and CPU.
> 
> Running with kvm-84 gives only sporadic failures, maybe every thousand
> restores a double fault in the guest.
> 
> Running with a 2.6.34 kernel gives an 'immediate' double fault in the
> guest. The guest does resume work as megabytes of guest data get
> modified before the double fault but eventually the guest crashes -
> and always it seems in the page fault handler. This is pretty much
> 100% reproduceable even with a 'workload' that simply does a "sleep
> 1d" in a shell script.

$ echo kvm_page_fault > /sys/kernel/debug/tracing/set_event

> On Intel CPUs though I get a VMX_INVALID_GUEST_STATE error. The guest
> does not run - which tells me I am doing something wrong here.

You can load kvm-intel.ko with emulate_invalid_guest_state=1, and
inspect guest_state_valid to pinpoint which state is invalid.

> Assuming that the KVM versions work fine - what state that comes from
> KVM through one of the KVM_GET_* IOCTLs has to be modified/sanitized
> on restore?

None. Only ordering must be maintained, follow QEMU there.


  reply	other threads:[~2011-07-19 18:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18 22:46 Save/Restore not working Frank Berreth
2011-07-19 17:20 ` Marcelo Tosatti [this message]
2011-07-19 20:09   ` Jan Kiszka
2011-07-20 17:49   ` Frank Berreth

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=20110719172001.GB31673@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=frankber@google.com \
    --cc=kvm@vger.kernel.org \
    /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