[LTP] [PATCH 2/2] kvm: Allow running multiple iterations of a test

Cyril Hrubis chrubis@suse.cz
Thu May 19 14:52:03 CEST 2022


Hi!
> This fixes running the test with "-i N" for N>1. It's a lazy fix but
> the alternative would be saving the initial CPU state in up to 3 separate
> buffers and then restoring it after each test run. And the number of buffers
> differs on different archs. And ARM64 has an extra ioctl() instead...
> 
> I also wonder whether I should implement LTP library function to free
> individual guarded buffers because I don't like calling tst_free_all()
> directly.

Well I guess that we can do that later on. It should be easy enough if
we switch to a double linked list and do a linear search, after all I
doubt that we will allocate more than a few buffers this way.

>  testcases/kernel/kvm/lib_host.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/kvm/lib_host.c b/testcases/kernel/kvm/lib_host.c
> index b8994f34e..2782e68b0 100644
> --- a/testcases/kernel/kvm/lib_host.c
> +++ b/testcases/kernel/kvm/lib_host.c
> @@ -269,16 +269,20 @@ void tst_kvm_destroy_instance(struct tst_kvm_instance *inst)
>  		SAFE_CLOSE(inst->vcpu_fd);
>  
>  	SAFE_CLOSE(inst->vm_fd);
> +	memset(inst->ram, 0, sizeof(inst->ram));
>  }
>  
>  void tst_kvm_setup(void)
>  {
> -	tst_kvm_create_instance(&test_vm, DEFAULT_RAM_SIZE);
> +
>  }
>  
>  void tst_kvm_run(void)
>  {
> +	tst_kvm_create_instance(&test_vm, DEFAULT_RAM_SIZE);
>  	tst_kvm_run_instance(&test_vm);
> +	tst_kvm_destroy_instance(&test_vm);
> +	tst_free_all();
>  }

Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list