From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] kvm-unit-tests : The first version of VMX nested test case Date: Tue, 16 Jul 2013 18:20:35 +0300 Message-ID: <20130716152035.GB8981@redhat.com> References: <1373966841-22206-1-git-send-email-yzt356@gmail.com> <51E52035.1050401@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Arthur Chunqi Li , kvm@vger.kernel.org, jan.kiszka@web.de To: Paolo Bonzini Return-path: Received: from mx1.redhat.com ([209.132.183.28]:28585 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754902Ab3GPPUk (ORCPT ); Tue, 16 Jul 2013 11:20:40 -0400 Content-Disposition: inline In-Reply-To: <51E52035.1050401@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Jul 16, 2013 at 12:28:05PM +0200, Paolo Bonzini wrote: > > +void vmx_exit(void) > > +{ > > + test_vmxoff(); > > + printf("\nSUMMARY: %d tests, %d failures\n", tests, fails); > > + exit(fails ? -1 : 0); > > +} > > Can you try to jump back to main, and do test_vmxoff there? This will > avoid having to write our tests in callback style, which is a pain. > Basically something similar to setjmp/longjmp. In main: > > if (setjmp(jmpbuf) == 0) { > vmx_run(); > /* Should not reach here */ > report("test vmlaunch", 0); > } > test_vmxoff(); > > exit: > printf("\nSUMMARY: %d tests, %d failures\n", tests, fails); > return fails ? 1 : 0; > > In vmx_handler: > > case VMX_HLT: > printf("\nVM exit.\n"); > longjmp(jmpbuf, 1); > Why not just make vmexit occur after vmlaunch/vmresume like KVM does. It will make code much more straightforward and easer to follow. -- Gleb.