From: Ian Campbell Subject: Re: [PATCH v3-RESEND 26/28] libxl: ocaml: provide defaults for libxl types Date: Thu, 31 Oct 2013 18:43:04 +0000 Message-ID: <1383244984.5436.72.camel@dagon.hellion.org.uk> References: <1382362365-6645-1-git-send-email-rob.hoes@citrix.com> <1382362365-6645-27-git-send-email-rob.hoes@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1382362365-6645-27-git-send-email-rob.hoes@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Rob Hoes Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Mon, 2013-10-21 at 14:32 +0100, Rob Hoes wrote: > Libxl functions such as libxl_domain_create_new take large structs > of configuration parameters. Often, we would like to use the default > values for many of these parameters. > > The struct and keyed-union types in libxl have init functions, which > fill in the defaults for a given type. This commit provides an OCaml > interface to obtain records of defaults by calling the relevant init > function. > > These default records can be used as a base to construct your own > records, and to selectively override parameters where needed. > > For example, a Domain_create_info record can now be created as follows: > > Xenlight.Domain_create_info.({ default ctx () with > ty = Xenlight.DOMAIN_TYPE_PV; > name = Some vm_name; > uuid = vm_uuid; > }) > > For types with KeyedUnion fields, such as Domain_build_info, a record > with defaults is obtained by specifying the type key: > > Xenlight.Domain_build_info.default ctx ~ty:Xenlight.DOMAIN_TYPE_HVM () > > Signed-off-by: Rob Hoes I have a feeling some of this could be done better, but that's my fault for laying such crappy groundwork, sorry! Acked-by: Ian Campbell