From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoshiaki Tamura Subject: Re: Question on skip_emulated_instructions() Date: Thu, 08 Apr 2010 15:18:46 +0900 Message-ID: <4BBD7546.7080400@lab.ntt.co.jp> References: <4BBAB46B.9010405@lab.ntt.co.jp> <20100406100522.GW5235@redhat.com> <20100407154324.GF303@redhat.com> <4BBCC2C9.1040301@redhat.com> <4BBD6959.6080003@lab.ntt.co.jp> <20100408054138.GG303@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Avi Kivity , kvm@vger.kernel.org, Marcelo Tosatti To: Gleb Natapov Return-path: Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]:64014 "EHLO tama50.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753376Ab0DHGTE (ORCPT ); Thu, 8 Apr 2010 02:19:04 -0400 In-Reply-To: <20100408054138.GG303@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Gleb Natapov wrote: > On Thu, Apr 08, 2010 at 02:27:53PM +0900, Yoshiaki Tamura wrote: >> Avi Kivity wrote: >>> On 04/07/2010 08:21 PM, Yoshiaki Tamura wrote: >>>> >>>> The problem here is that, I needed to transfer the VM state which is >>>> just *before* the output to the devices. Otherwise, the VM state has >>>> already been proceeded, and after failover, some I/O didn't work as I >>>> expected. >>>> I tracked down this issue, and figured out rip was already proceeded >>>> in KVM, >>>> and transferring this VCPU state was meaningless. >>>> >>>> I'm planning to post the patch set of Kemari soon, but I would like to >>>> solve >>>> this rip issue before that. If there is no drawback, I'm happy to work >>>> and post a patch. >>> >>> vcpu state is undefined when an mmio operation is pending, >>> Documentation/kvm/api.txt says the following: >>> >>>> 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. >> >> Thanks for the information. >> >> So the point is the vcpu state that can been observed from qemu upon >> KVM_EXIT_IO, KVM_EXIT_MMIO and KVM_EXIT_OSI should not be used >> because it's not complete/consistent? >> > Definitely. VCPU is in the middle of an instruction execution, so the > state is undefined. One instruction may generate more then one IO exit > during its execution BTW. Regarding the multiple IO exits, we're paying attention too. Although it depends on the guest behavior, if we limit the device model, one IO exit per one instruction may be practical at beggining. But thanks for pointing out. To solve the undefined VCPU state, how about keeping a copy of initial state upon VMEXIT? I guess there already is a similar shadow state in KVM. If possible we can allocate another one for this purpose.