From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rusty Russell Subject: Re: [RFC 0/5] Making KVM_GET_ONE_REG/KVM_SET_ONE_REG generic. Date: Sat, 01 Sep 2012 22:05:52 +0930 Message-ID: <873931539z.fsf@rustcorp.com.au> References: <877gsia8rm.fsf@rustcorp.com.au> <87mx1dsfuc.fsf@rustcorp.com.au> <5041D3AE.6090804@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Peter Maydell , Christoffer Dall , Alexander Graf , kvmarm@lists.cs.columbia.edu, kvm-devel To: Avi Kivity , Rusty Russell Return-path: Received: from ozlabs.org ([203.10.76.45]:48625 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751141Ab2IAMgF (ORCPT ); Sat, 1 Sep 2012 08:36:05 -0400 In-Reply-To: <5041D3AE.6090804@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Avi Kivity writes: >> -Capability: basic >> +Capability: KVM_CAP_REG_LIST >> Architectures: arm > > all OK, I guess that's to be true in future. Fixed. >> Type: vcpu ioctl >> -Parameters: struct kvm_msr_list (in/out) >> +Parameters: struct kvm_reg_list (in/out) >> Returns: 0 on success; -1 on error >> Errors: >> - E2BIG: the msr index list is too big to fit in the array specified by >> - the user. >> + E2BIG: the reg index list is too big to fit in the array specified by >> + the user (the number required will be written into n). >> >> struct kvm_msr_list { >> - __u32 nmsrs; /* number of msrs in entries */ >> - __u32 indices[0]; >> + __u64 n; /* number of registers in reg[] */ >> + __u64 reg[0]; >> }; >> > > People complain that this interface is hard to use. > > How about supplying the address of the array (in addition to n) so you > don't have to deal with variable sized arrays, and dropping E2BIG in > favour of always updating n (n changed to something bigger than you had > -> reallocate and rerun) We re-write n anyway, *and* return -E2BIG. Not returning an error is asking for trouble. Passing an address in a struct is pretty bad, since it involves compatibility wrappers. I don't think that is what makes the API hard to use. Cheers, Rusty.