From: Gianni Tedesco Subject: Re: [PATCH,RFC]: Introduce libxl_domain_create() Date: Tue, 21 Dec 2010 13:07:03 +0000 Message-ID: <1292936823.11246.80.camel@qabil.uk.xensource.com> References: <1292353212.11246.35.camel@qabil.uk.xensource.com> <1292576770.32368.11405.camel@zakaz.uk.xensource.com> <1292921096.11246.55.camel@qabil.uk.xensource.com> <19728.37132.470936.457946@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <19728.37132.470936.457946@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: Ian Campbell , Xen Devel , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Tue, 2010-12-21 at 11:35 +0000, Ian Jackson wrote: > Gianni Tedesco writes ("Re: [Xen-devel] [PATCH,RFC]: Introduce libxl_domain_create()"): > > On Fri, 2010-12-17 at 09:06 +0000, Ian Campbell wrote: > > > Should be in IDL so it gets a destructor? Could require adding an Array > > > construct to handle the foo + num_foo style stuff. > > > > I've thought about that and rejected it because C arrays don't map to > > anything useful in language bindings. It makes sense to me to keep this > > as a builtin and use functions to fill these domain creation related > > structures in for us. > > Arrays map perfectly well to a C pointer and a length. If you want to > do automatic expansion you need a separate allocated length too, which > is probably worthwhile. Python, for example, has no concept of an array nor any remotely similar data structure. The way I have developed the current xl binding is that C-structs are embedded inside python objects which wrap them. To be fair I could probably auto-generate list <-> array marshalling functions to go each way so it's not impossible. > > But then what you get is like two versions of: > > - libxl_device_add_(nic|block|etc) > > One for a live domain and one for domain creation. > > I think that's fine, particularly if they take the same struct. > > > I have been toying with the idea of using polymorphism (is that what > > it's called?) So that such a function would multiplex to different > > implementations depending on whether this is a live domain or a > > description of a domain for creation. It might need a bit of thinking > > through as how it would be used. > > Urgh. Fair enough, I didn't expect a positive response to that one. But I mentioned to Stefano that that's the sort of interface I'll end up writing in python and he suggested that it be done that way in C so that the API's people are using are similar. Gianni