[PATCH 2/4] KVM: selftests: Add helper macros for ioctl()s that return file descriptors

Sean Christopherson seanjc at google.com
Mon Aug 14 11:11:59 PDT 2023


On Fri, Aug 04, 2023, Sean Christopherson wrote:
> On Fri, Aug 04, 2023, Oliver Upton wrote:
> > Hi Sean,
> > 
> > On Thu, Aug 03, 2023 at 05:42:24PM -0700, Sean Christopherson wrote:
> > > Add KVM, VM, and vCPU scoped helpers for ioctl()s that return file
> > > descriptors, i.e. deduplicate code for asserting success on ioctls() for
> > > which a positive return value, not just zero, is considered success.
> > > 
> > > Signed-off-by: Sean Christopherson <seanjc at google.com>
> > 
> > I appreciate the desire to eliminate duplicate code, but I think the
> > naming just muddies the waters. TBH, when I first read the diff w/o the
> > changelog, I thought you were describing the input fd (i.e. 'kvm_fd',
> > 'vm_fd', 'vcpu_fd'). I don't think explicitly spelling out the condition
> > each time (i.e. ret >= 0) is all that difficult.
> 
> Yeah, but it's not just a desire to dedup code, I also am trying to funnel as
> many "ioctl() succeeded" asserts as possible into common code so that they naturally
> benefit from things like patch 4 (detecting dead/bugged VMs).
> 
> I agree the naming sucks.

The best naming scheme I can come up with is to be super literal:

	kvm_ioctl_non_negative
	vm_ioctl_non_negative
	vcpu_ioctl_non_negative

If that's still too kludgy and no one has a better idea, I'll just scrap this
patch.



More information about the linux-arm-kernel mailing list