WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] Re: Xen-API C Bindings, version 0.4.1

To: Ewan Mellor <ewan@xxxxxxxxxxxxx>
Subject: [Xen-API] Re: Xen-API C Bindings, version 0.4.1
From: "Mike D. Day" <ncmike@xxxxxxxxxx>
Date: Wed, 9 Aug 2006 20:36:58 -0400
Cc: Xen-API <xen-api@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Wed, 09 Aug 2006 17:32:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20060808160023.GD28097@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
References: <20060808160023.GD28097@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.4.1i
On 08/08/06 17:00 +0100, Ewan Mellor wrote:

Attached is the latest version of the C bindings for the Xen Management API.

A record that contains references to other records (Ref in the data model) has
fields of record_opt type.  This type is a tagged union -- either a handle
referring to the object, or a full copy of the object's fields.  The
get_record calls are only shallow -- they return handles as those references,
not full copies -- but I anticipate that we shall add some deep calls later.




I've added constructors, such as xen_vm_create, that take a xen_vm_record, and
use that to supply parameters to the construction.

All items that are allocated by the library and passed to the user have a
corresponding call for deallocation (xen_vm_free, for example).


Simple style question: should we typedef structs? I like the shorthand
but linux style has some advantages. typedefs tend to hide information
about the type that can be important.
I like the internal structure of the API. It might be nice for each
type/value to have pluggable marshall/demarshall functions. The
marshall/demarshall code in xen_common.c is great but usually there
are cases where a user needs to roll his own.

Memory management:
Right now the user supplies a buffer with input values (which is
copied by the API), and the API supplies a result buffer, which the
user needs to free. This is always hard to get right. It might make
sense for the caller to provide both. This would avoid a memcpy and
would reduce memory consumption. Since the caller is also part of the
API implementation I think it would be best to avoid the memcpy.

The current prototype should make params const:

void
xen_call_(xen_session *s, const char *method_name,
-         abstract_value params[], int param_count,
+         const abstract_value params[], int param_count,
         const abstract_type *result_type, void *value)


But I would rather prefer this, with the caller supplying parameter
memory:

void
xen_call_(xen_session *s, const char *method_name,
-         abstract_value params[], int param_count,
+         const abstract_value *params[], int param_count,
         const abstract_type *result_type, void *value)


#define XEN_CALL_(method_name__)                                \
   xen_call_(session, method_name__, param_values,             \
             sizeof(param_values) / sizeof(param_values[0]),   \
             &result_type, &result)                            \

The XEN_CALL macro is kind of scary because it uses inferred
variables. It's probably because I'm not used to this convention but I
would prefer #define XEN_CALL_ xen_call_
In other words, it really isn't needed and we should just expand the
macro ourselves becuase.


More later, nice work!

Mike

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api