Re: [PATCH 6/6] KVM: selftests: Test Hyper-V extended hypercall exit to userspace

From: David Matlack
Date: Tue Nov 08 2022 - 12:45:19 EST


On Mon, Nov 7, 2022 at 6:05 PM Vipin Sharma <vipinsh@xxxxxxxxxx> wrote:
>
> On Mon, Nov 7, 2022 at 11:01 AM David Matlack <dmatlack@xxxxxxxxxx> wrote:
> >
> > On Fri, Nov 04, 2022 at 09:57:04PM -0700, Vipin Sharma wrote:
> > > +
> > > + TEST_ASSERT((run->exit_reason == KVM_EXIT_IO),
> > > + "unexpected exit reason: %u (%s)", run->exit_reason,
> > > + exit_reason_str(run->exit_reason));
> >
> > Optional: Asserting a specific exit reason is a pretty common pattern in
> > the x86 selftests. It'd be nice to create a common macro for it. e.g.
> >
> > ASSERT_EXIT_REASON(vcpu, KVM_EXIT_IO);
> >
>
> This is much better. I can add a patch which creates this API.
>
> Should it be run or vcpu? Seems like everything needed is in struct kvm_run{}.

Either one but I suspect vcpu will produce a cleaner final result
since all tests pass around struct kvm_vcpu and only use kvm_run to
check the exit reason. i.e. I suspect you'll be able to delete several
struct kvm_run local variables as part of adding ASSERT_EXIT_REASON().