aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/gentypes.py
Commit message (Collapse)AuthorAgeFilesLines
* libxl: idl: always initialise the KeyedEnum keyvar in the member init functionIan Campbell2012-08-031-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we only initialised it if an explicit keyvar_init_val was given but not if the default was implicitly 0. In the generated code this only changes the unused libxl_event_init_type function: void libxl_event_init_type(libxl_event *p, libxl_event_type type) { + assert(!p->type); + p->type = type; switch (p->type) { case LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN: break; However I think it is wrong that this function is unused, this and libxl_event_init should be used by libxl__event_new. As it happens both are just memset to zero but for correctness we should use the init functions (in case the IDL changes). In the generator we also need to properly handle init_var == 0 which the current if statements incorrectly treat as False. This doesn't actually have any impact on the generated code. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: enforce prohibitions of internal callersIan Jackson2012-08-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libxl_internal.h says: * Functions using LIBXL__INIT_EGC may *not* generally be called from * within libxl, because libxl__egc_cleanup may call back into the * application. ... and * ... [Functions which take an ao_how] MAY NOT * be called from inside libxl, because they can cause reentrancy * callbacks. However, this was not enforced. Particularly the latter restriction is easy to overlook, especially since during the transition period to the new event system we have bent this rule a couple of times, and the bad pattern simply involves passing 0 or NULL for the ao_how. So use the compiler to enforce this property, as follows: - Mark all functions which take a libxl_asyncop_how, or which use EGC_INIT or LIBXL__INIT_EGC, with a new annotation LIBXL_EXTERNAL_CALLERS_ONLY in the public header. - Change the documentation comment for asynch operations and egcs to say that this should always be done. - Arrange that if libxl.h is included via libxl_internal.h, LIBXL_EXTERNAL_CALLERS_ONLY expands to __attribute__((warning(...))), which generates a message like this: libxl.c:1772: warning: call to 'libxl_device_disk_remove' declared with attribute warning: may not be called from within libxl Otherwise, the annotation expands to nothing, so external callers are unaffected. - Forbid inclusion of both libxl.h and libxl_internal.h unless libxl_internal.h came first, so that the above check doesn't have any loopholes. Files which include libxl_internal.h should not include libxl.h as well. This is enforced explicitly using #error. However, in practice with the current tree it just changes the error message when this mistake is made; otherwise we would carry on to immediately following #define which would cause the compiler to complain that LIBXL_EXTERNAL_CALLERS_ONLY was redefined. Then the developer might be tempted to add a #ifndef which would be wrong - it would leave the affected translation unit unprotected by the new enforcement regime. So let's be explicit. - Fix the one source of files which violate the above principle, the output from the idl compiler, by removing the redundant inclusion of libxl.h from the output. Also introduce a new script "check-libxl-api-rules" which contains some ad-hoc regexps to spot and complain when libxl.h contains functions which mention libxl_asyncop_how but not LIBXL_EXTERNAL_CALLERS_ONLY. This isn't a full C parser but is likely to get the common cases right and err on the side of complaining. While we are here, the invocation of perl for the bsd queue.h seddery to $(PERL). Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: add a new Array type to the IDLIan Campbell2012-07-061-3/+39
| | | | | | | | | | | | And make all the required infrastructure updates to enable this. Since there are currently no uses of this type there is no change to the generated code. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Tested-by: Dario Faggioli <dario.faggioli@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: mark internal functions hiddenIan Campbell2012-04-241-8/+8
| | | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: autogenerate libxl_FOO_init and libxl_FOO_init_FIELDIan Campbell2012-03-011-1/+97
| | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: idl: generate KeyedUnion key member as part of the KeyedUnionIan Campbell2012-03-011-0/+3
| | | | | | Rather than specifying it twice in the IDL. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Make IDL KeyedUnion keyvar an idl.FieldIan Campbell2012-03-011-2/+2
| | | | | | | This is more logical than having keyvar_name and keyvar_type members. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Rename libxl IDL infrastructure.Ian Campbell2012-01-311-17/+17
| | | | | | | | | | | | | | | | Originally libxltypes.py provided the infrastructure and libxl.idl provided the specific types. In 23887:a543e10211f7 libxl.idl became libxl_types.idl (to allow for libxl_types_internal.idl) which means we now have libxl_types.FOO and libxltypes.FOO providing different things and annoying people in tab completion. Rename the infrastructure as idl. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: remove comment support from IDLIan Campbell2012-01-311-23/+0
| | | | | | | | | | | | | | | | People typically don't look for comments in generated source and the syntax for specifying them in the IDL makes things harder to follow. Instead just use source code comments in the IDL itself. I dropped a bunch of "foo bool # enable or disable foo" type comments. A lot of the remainder still aren't terribly useful though. No change to the generate code other than the comments being removed. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: idl: Provide struct and union tagsIan Jackson2011-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | Instead of generating: typedef struct { ... } libxl_foo; Produce: typedef struct libxl_foo { ... } libxl_foo; This makes it possible to refer to libxl idl-generated structs and unions, as incomplete types, before they have been defined. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: idl: use "dispose" rather than "destroy" for function to free IDL typesIan Campbell2011-10-181-11/+11
| | | | | | | | | | | Destroy is an overloaded term which would commonly like to be used for actual destructive operations, such as destroying a domain etc. Dispose isn't a great term but it does the job. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: IDL: autogenerate functions to produce JSON from libxl data structures.Ian Campbell2011-10-071-6/+96
| | | | | | | | | | | | | | | | | | | | Two functions are provided. TYPE_gen_json exposes an interface which is compatible with the YAGL generator infrastructure. TYPE_to_string uses this to produce a pretty printed string. The TYPE_gen_json functions are defined in a new header libxl_json.h which is not exposed via libxl.h due to the use of YAGL datatypes to avoid poluting the namespace us libxl users which don't use the library themselves. If a libxl user is interested in integrating at the YAGL level then it should #include this file itself. Also update testidl to generate a random version of each IDL datastructure and convert it to JSON. Unfortunately this requires a libxl_ctx and therefore the test must be run on a Xen system now. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: Introduce libxl_internal_types.idl.Anthony PERARD2011-09-291-4/+5
| | | | | | Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: clean up trailing whitespaces in code.Wei Liu2011-07-191-15/+15
| | | | | | | | | Commit exactly the results of running find \! -iname '*.txt' -type f -print0 | xargs -0 perl -p -i.bak -E 's/\s+\n/\n/' Signed-off-by: Wei Liu <liuw@liuw.name> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Keyed unions key off an enum instead of an arbitrary expressionIan Campbell2011-07-181-3/+4
| | | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: IDL: bring command line handling in genwrap.py into one place.Ian Campbell2011-07-141-4/+3
| | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: IDL: add helper to generate references to Aggregate type members.Ian Campbell2011-07-141-10/+4
| | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: IDL: remove libxl_C_type_ofIan Campbell2011-07-141-5/+2
| | | | | | | It's not really adding much... Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: IDL: refactor code to massage a type into a function argumentIan Campbell2011-07-141-6/+1
| | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: IDL: handle generation of pass-by-reference arguments.Ian Campbell2011-07-141-4/+4
| | | | | | | | | Up until now everything with a destructor function happened to be pass-by-reference so the current code worked but this will not be the case for *_to_string and *_to_json. Put some infrastructure in place and use it. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: IDL: s/anonynous/anonymous/Ian Campbell2011-07-141-1/+1
| | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: autogenerate to_string and from_string functions for Enumerations.Ian Campbell2011-06-211-0/+59
| | | | | | | | | | | | The generated strings are the lower case enum value names, with underscores. Accepted string for parsing are the same but are case insensitive. We provide a table of strings->value for each Enumeration as well as a convenience function to perform a lookup. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools: libxl: remove Reference meta-type from IDLIan Campbell2011-04-201-11/+7
| | | | | | | | It is tricky to map to language bindings and is now unused in any case. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* tools: libxl: remove BitField type class from IDLIan Campbell2011-04-201-3/+1
| | | | | | | | | | | | | All usages are single bit BitFields, AKA booleans. In general we prefer to use simple structures (e.g. without packing or specific layouts) in the libxl API and take care of any require structure by marshalling within the library instead of expecting users to do so (e.g. the PCI device BDF is unpacked in the libxl API). Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* tools: libxl: add an Enumeration type to the IDLIan Campbell2011-04-201-1/+22
| | | | | | | | | | | | | The IDL requires a specific value for each enumerate, this make it much easier to avoid (or at least track) ABI changes since they must now be explicit. I believe I have used the same values as would have been chosen previoulsy but have not confirmed. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
* libxl: correct indentation of _libxl_types.cIan Campbell2010-08-311-1/+1
| | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: correctly free Reference types in autogenerated destroy functionsIan Campbell2010-08-311-5/+7
| | | | | | | | References types should be recursively destroyed and then the actual reference itself should be destroyed. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: poison data objects in auto-generated destructorsGianni Tedesco2010-08-201-0/+4
| | | | | | | | | Increase the probability of blowing up badly up during any use-after-destroy scenarios. Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: do not generate a destructor for data types which do not require oneIan Campbell2010-08-191-1/+1
| | | | | | | | | | | | | | | | | libxl_dominfo, libxl_poolinfo, libxl_vminfo, libxl_domain_build_state, libxl_physinfo and libxl_sched_credit contain no members which require destruction so omit the auto generated destructor. As an exception continue to generate destructors for libxl_device_* and libxl_{devtype}* even if they have no interesting members so that all device types can be treated the same without special knowledge about the type contents being required. [PATCH 08 of 16 of libxl: autogenerate type definitions and destructor functions] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: generate destructors for each libxl defined typeIan Campbell2010-08-191-5/+73
| | | | | | | | | | | | | | | | | | | | | | | I chose the name "_destroy" rather than "_free" because the destructor functions will free only the members of a type recursively but will not free the actual type structure itself. The allocation of the type is typically done by the caller and may not be a single allocation, e.g. lists/arrays of types or embedded in other structures etc. The exceptions to this rule are libxl_string_list_destroy and libxl_key_value_list_destroy but I'm not 100% convinced they are exceptions (since they are kind-of opaque) and I couldn't see a cleanerway to express this concept. I have made a best effort attempt to implement these functions sanely but since as far as I can tell nothing in the current code base ever sets libxl_domain_create_info.{xsdata,platformdata} I'm flying somewhat blind. [PATCH 05 of 16 of libxl: autogenerate type definitions and destructor functions] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: autogenerate _libxl_types.hIan Campbell2010-08-191-0/+91
The libxl interface types are represented by a simple python data structure (which could be parsed from a bespoke language in the future). This will allow the autogeneration of functions to free the component members of the libxl types. In the future it may also enable auto generation of type marshalling code for language bindings. The generated file should be identical to before with the exception of the "DO NOT EDIT" header. It was unfortunately necessary to add explcit an dependency on _libxl_types.h (indirectly via libxl.h) to all C files since the autogenerated dependencies are not available in time. [PATCH 04 of 16 of libxl: autogenerate type definitions and destructor functions] Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>