Re: [PATCH v2 000/144] KVM: selftests: Overhaul APIs, purge VCPU_ID

Sean Christopherson
2022-06-09T15:19:22Z

On Thu, Jun 09, 2022, Andrew Jones wrote:
> On Wed, Jun 08, 2022 at 11:20:06PM +0000, Sean Christopherson wrote:
> > diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c
> > index b3116c151d1c..17f7ef975d5c 100644
> > --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c
> > +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c
> > @@ -419,7 +419,7 @@ static void run_test(struct vcpu_config *c)
> >
> > check_supported(c);
> >
> > - vm = vm_create_barebones();
> > + vm = vm_create(1);
>
> Hmm, looks like something, somewhere for AArch64 needs improving to avoid
> strangeness like this. I'll look into it after we get this series merged.

Huh, you're right, that is odd. Ah, duh, aarch64_vcpu_add() allocates a stack
for the vCPU, and that will fail if there's no memslot from which to allocate
guest memory.

So, this is my goof in

KVM: selftests: Rename vm_create() => vm_create_barebones(), drop param

get-reg-list should first be converted to vm_create_without_vcpus(). I'll also
add a comment explaining that vm_create_barebones() can be used with __vm_vcpu_add(),
but not the "full" vm_vcpu_add() or vm_arch_vcpu_add() variants.

> > prepare_vcpu_init(c, &init);
> > vcpu = aarch64_vcpu_add(vm, 0, &init, NULL);
> > finalize_vcpu(vcpu, c);
> >
>
> Thanks,
> drew
>