[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 28/28] libxl: ocaml: provide default records for libxl types


  • To: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
  • From: Rob Hoes <Rob.Hoes@xxxxxxxxxx>
  • Date: Mon, 29 Apr 2013 15:13:34 +0100
  • Accept-language: en-US
  • Acceptlanguage: en-US
  • Cc: "xen-devel@xxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxx>
  • Delivery-date: Mon, 29 Apr 2013 14:14:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>
  • Thread-index: Ac42tbiJmTZp5EjISBiwT9fPZ5hZpQOLPXDQ
  • Thread-topic: [PATCH 28/28] libxl: ocaml: provide default records for libxl types

> On Mon, 2013-03-25 at 14:45 +0000, 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.
> >
> > This commit makes OCaml records of defaults available for all libxl
> > struct and keyed-union types, which 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:
> >
> > let c_info = Xenlight.Domain_create_info.({ default with
> >     ty = Xenlight.DOMAIN_TYPE_PV;
> >     name = Some vm_name;
> >     uuid = vm_uuid;
> > }) in
> 
> This is a clever approach (and I expect good idiomatic ocaml?) but you need
> to handle the init_val IDL field for all types since not everything should be
> set to zero (e.g. some of the UInt subtypes don't default to 0, see MemKB
> for one).
> 
> I wonder if a better alternative might be to use a C binding to call
> libxl_TYPE_init() and convert that to an ocaml value? This would mean one
> less place to change in the future as well.

I see. In that case, it indeed seems better to turn "default" into a function 
that calls a libxl *_init() function and converts it to an ocaml value, rather 
than having static defaults. With that, the only thing that changes in the 
example above is that "()" is added after "default".

Cheers,
Rob
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.