: add libxl python binding
PATCH v2 1/1 : add libxl python binding
Changes since v2:
- Incorporated Ian Campbells suggestions viz python coding style and:
- Added autogenerated files to .hgignore
- Build-time support for python2.5
Changes since v1:
- Interpret keyword arguments in initializers: eg. xl.device_pci(bus=1, dev=2, fn=3)
- Implement domain pause/unpause/rename/pci_add/pci_del and pci_parse
- Proper type-checking in all (I hope) code-paths
- Improve API for accessing auto-generated code and types
Changes since RFC:
- split auto-generated code in to c and h files
- un-break the build system
- fix ocaml binding due to libxl API change
- lot's of tidy-ups too numerous to mention
-----8<--------------------------------------------------------------- Introduce python binding for libxl. The binding is not yet complete but serveral methods are implemented and tested. Those which are implemented provide examples of the two or three basic patterns that most future methods should follow.
Over 5,000 lines of boilerplate is automatically generated to wrap and export all relevant libxl structure definitions. There are a few places where such code cannot be fully auto-generated and special hooks are declared and stubbed where, for example, conversion between libxl_file_reference and a python file object is required.
--
.hgignore | 2 tools/python/genwrap.py | 282 ++++++++++++++++ tools/python/xen/lowlevel/xl/xl.c | 615 ++++++++++++++++++++++++++++++++++++ tools/python/Makefile | 9 tools/python/setup.py | 19 - 5 files changed, 924 insertions(+), 3 deletions(-)
--
.hgignore +2 -0
@@ -211,6 +211,8 @@ ^tools/pygrub/build/.*$ ^tools/python/build/.*$ ^tools/python/xen/util/path\.py$ +^tools/python/xen/lowlevel/xl/_pyxl_types.c +^tools/python/xen/lowlevel/xl/_pyxl_types.h ^tools/remus/imqebt/imqebt$ ^tools/remus/kmod/.*(\.cmd|\.mod|\.ko|\.mod\.c|\.symvers|\.xen)$ ^tools/security/secpol_tool$
tools/python/Makefile +8 -1
@@ -19,7 +19,12 @@ genpath-target = $(call buildmakevars2fi $(eval $(genpath-target)) .PHONY: build buildpy -buildpy: genpath +buildpy: genpath genwrap.py $(XEN_ROOT)/tools/libxl/libxl.idl \ + $(XEN_ROOT)/tools/libxl/libxltypes.py + PYTHONPATH=$(XEN_ROOT)/tools/libxl $(PYTHON) genwrap.py \ + $(XEN_ROOT)/tools/libxl/libxl.idl \ + xen/lowlevel/xl/_pyxl_types.h \ + xen/lowlevel/xl/_pyxl_types.c CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build build: buildpy refresh-pot refresh-po $(CATALOGS)
@@ -85,6 +90,8 @@ test: clean: rm -f $(XENPATH) rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS) xen/util/auxbin.pyc + rm -f xen/lowlevel/xl/_pyxl_types.h + rm -f xen/lowlevel/xl/_pyxl_types.c rm -f $(DEPS) -include $(DEPS)
tools/python/genwrap.py new file +282 -0
282 lines not on this page · raw message
tools/python/setup.py +17 -2
@@ -9,14 +9,23 @@ extra_compile_args = [ "-fno-strict-ali include_dirs = [ XEN_ROOT + "/tools/libxc", XEN_ROOT + "/tools/xenstore", XEN_ROOT + "/tools/include", + XEN_ROOT + "/tools/libxl", ] library_dirs = [ XEN_ROOT + "/tools/libxc", XEN_ROOT + "/tools/xenstore", + XEN_ROOT + "/tools/libxl", + XEN_ROOT + "/tools/blktap2/control", ] libraries = [ "xenctrl", "xenguest", "xenstore" ] +plat = os.uname()[0] +if plat == 'Linux': + uuid_libs = ["uuid"] +else: + uuid_libs = [] + xc = Extension("xc", extra_compile_args = extra_compile_args, include_dirs = include_dirs + [ "xen/lowlevel/xc" ],
@@ -83,8 +92,14 @@ netlink = Extension("netlink", sources = [ "xen/lowlevel/netlink/netlink.c", "xen/lowlevel/netlink/libnetlink.c"]) -modules = [ xc, xs, ptsname, acm, flask ] -plat = os.uname()[0] +xl = Extension("xl", + extra_compile_args = extra_compile_args, + include_dirs = include_dirs + [ "xen/lowlevel/xl" ], + library_dirs = library_dirs, + libraries = libraries + ["xenlight", "blktapctl" ] + uuid_libs, + sources = [ "xen/lowlevel/xl/xl.c", "xen/lowlevel/xl/_pyxl_types.c" ]) + +modules = [ xc, xs, ptsname, acm, flask, xl ] if plat == 'SunOS': modules.extend([ scf, process ]) if plat == 'Linux':
tools/python/xen/lowlevel/xl/xl.c new file +615 -0
615 lines not on this page · raw message
Quoted 4 lines · Gianni Tedesco
Changes since v2:
- Incorporated Ian Campbells suggestions viz python coding style and:
- Added autogenerated files to .hgignore
- Build-time support for python2.5
Obviously this is v3 :P