Re: [PATCH] kvm-unit-tests : The first version of VMX nested test case

Arthur Chunqi Li
2013-07-16T15:29:21Z

On Tue, Jul 16, 2013 at 11:20 PM, Gleb Natapov <gleb@redhat.com> wrote:
> 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.
The concept "easier to follow" may have different meanings in
different view. This achievement puts all the test cases in main
function instead of scattering everywhere, which is another view to
"easy to follow". As this is just a test case, I prefer this one.

Besides, this way we can start another VM following the previous one
simply in main function. This is flexible if we want to test re-enter
to VMX mode or so.

Arthur
>
> --
> Gleb.

--
Arthur Chunqi Li
Department of Computer Science
School of EECS
Peking University
Beijing, China