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-devel

[Xen-devel] [PATCH 23 of 24] tools: ocaml: lay ground work for auto gene

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 23 of 24] tools: ocaml: lay ground work for auto generating xl datatypes
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Wed, 13 Apr 2011 15:37:04 +0100
Cc: Vincent Hanquez <Vincent.Hanquez@xxxxxxxxxxxxx>, Dave Scott <Dave.Scott@xxxxxxxxxxxxx>
Delivery-date: Wed, 13 Apr 2011 08:06:30 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1302705401@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1302705401@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302698152 -3600
# Node ID 5bbea737a0dc092bf377129a057b01b15944b041
# Parent  3c51e7bfe28948bcd354cfc2ab2083d2ddb94d22
tools: ocaml: lay ground work for auto generating xl datatypes.

Doesn't actually generate anything yet but puts all the moving parts
into place. In particular sets up the
xl.ml.in+_libxl_types.ml.in->xl.ml transformation using sed. This
appears to be the only/best way to do this for ocaml due to the lack
of a preprocessor and/or an include mechanism which has an inmpact on
namespacing.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 3c51e7bfe289 -r 5bbea737a0dc .hgignore
--- a/.hgignore Wed Apr 13 13:35:52 2011 +0100
+++ b/.hgignore Wed Apr 13 13:35:52 2011 +0100
@@ -295,6 +295,11 @@
 ^tools/ocaml/.*/.*\.cmx?a$
 ^tools/ocaml/.*/META$
 ^tools/ocaml/.*/\.ocamldep\.make$
+^tools/ocaml/libs/xl/_libxl_types\.ml\.in$
+^tools/ocaml/libs/xl/_libxl_types\.mli\.in$
+^tools/ocaml/libs/xl/_libxl_types\.inc$
+^tools/ocaml/libs/xl/xl\.ml$
+^tools/ocaml/libs/xl/xl\.mli$
 ^tools/ocaml/xenstored/oxenstored$
 ^xen/\.banner.*$
 ^xen/BLOG$
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/Makefile
--- a/tools/ocaml/libs/xl/Makefile      Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/Makefile      Wed Apr 13 13:35:52 2011 +0100
@@ -15,8 +15,36 @@ xl_C_OBJS = xl_stubs
 
 OCAML_LIBRARY = xl
 
+GENERATED_FILES += xl.ml xl.mli
+GENERATED_FILES += _libxl_types.ml.in _libxl_types.mli.in
+GENERATED_FILES += _libxl_types.inc
+
 all: $(INTF) $(LIBS)
 
+xl.ml: xl.ml.in _libxl_types.ml.in
+       $(Q)sed -e '1i(*\
+ * AUTO-GENERATED FILE DO NOT EDIT\
+ * Generated from xl.ml.in and _libxl_types.ml.in\
+ *)\
+' \
+           -e '/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.ml.in' \
+         < xl.ml.in > xl.ml
+
+xl.mli: xl.mli.in _libxl_types.mli.in
+       $(Q)sed -e '1i(*\
+ * AUTO-GENERATED FILE DO NOT EDIT\
+ * Generated from xl.mli.in and _libxl_types.mli.in\
+ *)\
+' \
+           -e '/^(\* @@LIBXL_TYPES@@ \*)$$/r_libxl_types.mli.in' \
+         < xl.mli.in > xl.mli
+
+_libxl_types.ml.in _libxl_types.mli.in _libxl_types.inc: 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 \
+               _libxl_types.mli.in _libxl_types.ml.in _libxl_types.inc
+
 libs: $(LIBS)
 
 .PHONY: install
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/genwrap.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ocaml/libs/xl/genwrap.py    Wed Apr 13 13:35:52 2011 +0100
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+
+import sys,os
+
+import libxltypes
+
+def autogen_header(open_comment, close_comment):
+    s = open_comment + " AUTO-GENERATED FILE DO NOT EDIT " + close_comment + 
"\n"
+    s += open_comment + " autogenerated by \n"
+    s += reduce(lambda x,y: x + " ", range(len(open_comment + " ")), "")
+    s += "%s" % " ".join(sys.argv)
+    s += "\n " + close_comment + "\n\n"
+    return s
+
+if __name__ == '__main__':
+    if len(sys.argv) < 4:
+        print >>sys.stderr, "Usage: genwrap.py <idl> <mli> <ml> <c-inc>"
+        sys.exit(1)
+
+    idl = sys.argv[1]
+    (_,types) = libxltypes.parse(idl)
+
+    
+    _ml = sys.argv[3]
+    ml = open(_ml, 'w')
+    ml.write(autogen_header("(*", "*)"))
+
+    _mli = sys.argv[2]
+    mli = open(_mli, 'w')
+    mli.write(autogen_header("(*", "*)"))
+    
+    _cinc = sys.argv[4]
+    cinc = open(_cinc, 'w')
+    cinc.write(autogen_header("/*", "*/"))
+
+    # TODO: autogenerate something
+
+    ml.write("(* END OF AUTO-GENERATED CODE *)\n")
+    ml.close()
+    mli.write("(* END OF AUTO-GENERATED CODE *)\n")
+    mli.close()
+    cinc.close()
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl.ml
--- a/tools/ocaml/libs/xl/xl.ml Wed Apr 13 13:35:52 2011 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-(*
- * Copyright (C) 2009-2011 Citrix Ltd.
- * Author Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *)
-
-exception Error of string
-
-type domid = int
-
-type console_type =
-       | CONSOLETYPE_XENCONSOLED
-       | CONSOLETYPE_IOEMU
-
-type disk_phystype =
-       | PHYSTYPE_QCOW
-       | PHYSTYPE_QCOW2
-       | PHYSTYPE_VHD
-       | PHYSTYPE_AIO
-       | PHYSTYPE_FILE
-       | PHYSTYPE_PHY
-
-type nic_type =
-       | NICTYPE_IOEMU
-       | NICTYPE_VIF
-
-type button =
-       | Button_Power
-       | Button_Sleep
-
-module Device_vfb = struct
-       type t =
-       {
-               backend_domid : domid;
-               devid : int;
-               vnc : bool;
-               vnclisten : string;
-               vncpasswd : string;
-               vncdisplay : int;
-               vncunused : bool;
-               keymap : string;
-               sdl : bool;
-               opengl : bool;
-               display : string;
-               xauthority : string;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_vfb_add"
-       external clean_shutdown : domid -> unit = 
"stub_xl_device_vfb_clean_shutdown"
-       external hard_shutdown : domid -> unit = 
"stub_xl_device_vfb_hard_shutdown"
-end
-
-module Device_vkb = struct
-       type t =
-       {
-               backend_domid : domid;
-               devid : int;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_vkb_add"
-       external clean_shutdown : domid -> unit = 
"stub_xl_device_vkb_clean_shutdown"
-       external hard_shutdown : domid -> unit = 
"stub_xl_device_vkb_hard_shutdown"
-end
-
-module Device_disk = struct
-       type t =
-       {
-               backend_domid : domid;
-               physpath : string;
-               phystype : disk_phystype;
-               virtpath : string;
-               unpluggable : bool;
-               readwrite : bool;
-               is_cdrom : bool;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_disk_add"
-       external del : t -> domid -> unit = "stub_xl_device_disk_del"
-end
-
-module Device_nic = struct
-       type t =
-       {
-               backend_domid : domid;
-               devid : int;
-               mtu : int;
-               model : string;
-               mac : int array;
-               bridge : string;
-               ifname : string;
-               script : string;
-               nictype : nic_type;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_nic_add"
-       external del : t -> domid -> unit = "stub_xl_device_nic_del"
-end
-
-module Device_pci = struct
-       type t =
-       {
-               func : int;
-               dev : int;
-               bus : int;
-               domain : int;
-               vdevfn : int;
-               msitranslate : bool;
-               power_mgmt : bool;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_pci_add"
-       external remove : t -> domid -> unit = "stub_xl_device_pci_remove"
-       external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
-end
-
-module Physinfo = struct
-       type t =
-       {
-               threads_per_core : int;
-               cores_per_socket : int;
-               max_cpu_id : int;
-               nr_cpus : int;
-               cpu_khz : int;
-               total_pages : int64;
-               free_pages : int64;
-               scrub_pages : int64;
-               nr_nodes : int;
-               hwcap : int32 array;
-               physcap : int32;
-       }
-       external get : unit -> t = "stub_xl_physinfo"
-
-end
-
-module Sched_credit = struct
-       type t =
-       {
-               weight : int;
-               cap : int;
-       }
-       external domain_get : domid -> t = "stub_xl_sched_credit_domain_get"
-       external domain_set : domid -> t -> unit = 
"stub_xl_sched_credit_domain_set"
-end
-
-module Device_build_state = struct
-       type t =
-       {
-               store_port : int;
-               store_mfn : int64;
-               console_port : int;
-               console_mfn : int64;
-       }
-end
-
-module Device_console = struct
-       type t =
-       {
-               backend_domid : domid;
-               devid : int;
-               consoletype : console_type;
-       }
-       external add : t -> Device_build_state.t -> domid -> unit = 
"stub_xl_device_console_add"
-end
-
-module Topologyinfo = struct
-       type t =
-       {
-               core : int;
-               socket : int;
-               node : int;
-       }
-       external get : unit -> t = "stub_xl_topologyinfo"
-end
-
-external button_press : domid -> button -> unit = "stub_xl_button_press"
-
-
-external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger"
-external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq"
-external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys"
-
-let _ = Callback.register_exception "xl.error" (Error "register_callback")
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl.ml.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ocaml/libs/xl/xl.ml.in      Wed Apr 13 13:35:52 2011 +0100
@@ -0,0 +1,188 @@
+(*
+ * Copyright (C) 2009-2011 Citrix Ltd.
+ * Author Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *)
+
+exception Error of string
+
+type domid = int
+
+(* @@LIBXL_TYPES@@ *)
+
+type console_type =
+       | CONSOLETYPE_XENCONSOLED
+       | CONSOLETYPE_IOEMU
+
+type disk_phystype =
+       | PHYSTYPE_QCOW
+       | PHYSTYPE_QCOW2
+       | PHYSTYPE_VHD
+       | PHYSTYPE_AIO
+       | PHYSTYPE_FILE
+       | PHYSTYPE_PHY
+
+type nic_type =
+       | NICTYPE_IOEMU
+       | NICTYPE_VIF
+
+type button =
+       | Button_Power
+       | Button_Sleep
+
+module Device_vfb = struct
+       type t =
+       {
+               backend_domid : domid;
+               devid : int;
+               vnc : bool;
+               vnclisten : string;
+               vncpasswd : string;
+               vncdisplay : int;
+               vncunused : bool;
+               keymap : string;
+               sdl : bool;
+               opengl : bool;
+               display : string;
+               xauthority : string;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_vfb_add"
+       external clean_shutdown : domid -> unit = 
"stub_xl_device_vfb_clean_shutdown"
+       external hard_shutdown : domid -> unit = 
"stub_xl_device_vfb_hard_shutdown"
+end
+
+module Device_vkb = struct
+       type t =
+       {
+               backend_domid : domid;
+               devid : int;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_vkb_add"
+       external clean_shutdown : domid -> unit = 
"stub_xl_device_vkb_clean_shutdown"
+       external hard_shutdown : domid -> unit = 
"stub_xl_device_vkb_hard_shutdown"
+end
+
+module Device_disk = struct
+       type t =
+       {
+               backend_domid : domid;
+               physpath : string;
+               phystype : disk_phystype;
+               virtpath : string;
+               unpluggable : bool;
+               readwrite : bool;
+               is_cdrom : bool;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_disk_add"
+       external del : t -> domid -> unit = "stub_xl_device_disk_del"
+end
+
+module Device_nic = struct
+       type t =
+       {
+               backend_domid : domid;
+               devid : int;
+               mtu : int;
+               model : string;
+               mac : int array;
+               bridge : string;
+               ifname : string;
+               script : string;
+               nictype : nic_type;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_nic_add"
+       external del : t -> domid -> unit = "stub_xl_device_nic_del"
+end
+
+module Device_pci = struct
+       type t =
+       {
+               func : int;
+               dev : int;
+               bus : int;
+               domain : int;
+               vdevfn : int;
+               msitranslate : bool;
+               power_mgmt : bool;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_pci_add"
+       external remove : t -> domid -> unit = "stub_xl_device_pci_remove"
+       external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
+end
+
+module Physinfo = struct
+       type t =
+       {
+               threads_per_core : int;
+               cores_per_socket : int;
+               max_cpu_id : int;
+               nr_cpus : int;
+               cpu_khz : int;
+               total_pages : int64;
+               free_pages : int64;
+               scrub_pages : int64;
+               nr_nodes : int;
+               hwcap : int32 array;
+               physcap : int32;
+       }
+       external get : unit -> t = "stub_xl_physinfo"
+
+end
+
+module Sched_credit = struct
+       type t =
+       {
+               weight : int;
+               cap : int;
+       }
+       external domain_get : domid -> t = "stub_xl_sched_credit_domain_get"
+       external domain_set : domid -> t -> unit = 
"stub_xl_sched_credit_domain_set"
+end
+
+module Device_build_state = struct
+       type t =
+       {
+               store_port : int;
+               store_mfn : int64;
+               console_port : int;
+               console_mfn : int64;
+       }
+end
+
+module Device_console = struct
+       type t =
+       {
+               backend_domid : domid;
+               devid : int;
+               consoletype : console_type;
+       }
+       external add : t -> Device_build_state.t -> domid -> unit = 
"stub_xl_device_console_add"
+end
+
+module Topologyinfo = struct
+       type t =
+       {
+               core : int;
+               socket : int;
+               node : int;
+       }
+       external get : unit -> t = "stub_xl_topologyinfo"
+end
+
+external button_press : domid -> button -> unit = "stub_xl_button_press"
+
+
+external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger"
+external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq"
+external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys"
+
+let _ = Callback.register_exception "xl.error" (Error "register_callback")
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl.mli
--- a/tools/ocaml/libs/xl/xl.mli        Wed Apr 13 13:35:52 2011 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,183 +0,0 @@
-(*
- * Copyright (C) 2009-2011 Citrix Ltd.
- * Author Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *)
-
-exception Error of string
-
-type domid = int
-
-type console_type =
-       | CONSOLETYPE_XENCONSOLED
-       | CONSOLETYPE_IOEMU
-
-type disk_phystype =
-       | PHYSTYPE_QCOW
-       | PHYSTYPE_QCOW2
-       | PHYSTYPE_VHD
-       | PHYSTYPE_AIO
-       | PHYSTYPE_FILE
-       | PHYSTYPE_PHY
-
-type nic_type =
-       | NICTYPE_IOEMU
-       | NICTYPE_VIF
-
-type button =
-       | Button_Power
-       | Button_Sleep
-
-module Device_vfb : sig
-       type t =
-       {
-               backend_domid : domid;
-               devid : int;
-               vnc : bool;
-               vnclisten : string;
-               vncpasswd : string;
-               vncdisplay : int;
-               vncunused : bool;
-               keymap : string;
-               sdl : bool;
-               opengl : bool;
-               display : string;
-               xauthority : string;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_vfb_add"
-       external clean_shutdown : domid -> unit = 
"stub_xl_device_vfb_clean_shutdown"
-       external hard_shutdown : domid -> unit = 
"stub_xl_device_vfb_hard_shutdown"
-end
-
-module Device_vkb : sig
-       type t =
-       {
-               backend_domid : domid;
-               devid : int;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_vkb_add"
-       external clean_shutdown : domid -> unit = 
"stub_xl_device_vkb_clean_shutdown"
-       external hard_shutdown : domid -> unit = 
"stub_xl_device_vkb_hard_shutdown"
-end
-
-module Device_disk : sig
-       type t =
-       {
-               backend_domid : domid;
-               physpath : string;
-               phystype : disk_phystype;
-               virtpath : string;
-               unpluggable : bool;
-               readwrite : bool;
-               is_cdrom : bool;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_disk_add"
-       external del : t -> domid -> unit = "stub_xl_device_disk_del"
-end
-
-module Device_nic : sig
-       type t =
-       {
-               backend_domid : domid;
-               devid : int;
-               mtu : int;
-               model : string;
-               mac : int array;
-               bridge : string;
-               ifname : string;
-               script : string;
-               nictype : nic_type;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_nic_add"
-       external del : t -> domid -> unit = "stub_xl_device_nic_del"
-end
-
-module Device_pci : sig
-       type t =
-       {
-               func : int;
-               dev : int;
-               bus : int;
-               domain : int;
-               vdevfn : int;
-               msitranslate : bool;
-               power_mgmt : bool;
-       }
-       external add : t -> domid -> unit = "stub_xl_device_pci_add"
-       external remove : t -> domid -> unit = "stub_xl_device_pci_remove"
-       external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
-end
-
-module Physinfo : sig
-       type t =
-       {
-               threads_per_core : int;
-               cores_per_socket : int;
-               max_cpu_id : int;
-               nr_cpus : int;
-               cpu_khz : int;
-               total_pages : int64;
-               free_pages : int64;
-               scrub_pages : int64;
-               nr_nodes : int;
-               hwcap : int32 array;
-               physcap : int32;
-       }
-       external get : unit -> t = "stub_xl_physinfo"
-end
-
-module Sched_credit : sig
-       type t =
-       {
-               weight : int;
-               cap : int;
-       }
-       external domain_get : domid -> t = "stub_xl_sched_credit_domain_get"
-       external domain_set : domid -> t -> unit = 
"stub_xl_sched_credit_domain_set"
-end
-
-module Device_build_state : sig
-       type t =
-       {
-               store_port : int;
-               store_mfn : int64;
-               console_port : int;
-               console_mfn : int64;
-       }
-end
-
-module Device_console : sig
-       type t =
-       {
-               backend_domid : domid;
-               devid : int;
-               consoletype : console_type;
-       }
-
-       external add : t -> Device_build_state.t -> domid -> unit = 
"stub_xl_device_console_add"
-end
-
-module Topologyinfo : sig
-       type t =
-       {
-               core : int;
-               socket : int;
-               node : int;
-       }
-       external get : unit -> t = "stub_xl_topologyinfo"
-end
-
-external button_press : domid -> button -> unit = "stub_xl_button_press"
-
-external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger"
-external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq"
-external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys"
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl.mli.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ocaml/libs/xl/xl.mli.in     Wed Apr 13 13:35:52 2011 +0100
@@ -0,0 +1,185 @@
+(*
+ * Copyright (C) 2009-2011 Citrix Ltd.
+ * Author Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *)
+
+exception Error of string
+
+type domid = int
+
+(* @@LIBXL_TYPES@@ *)
+
+type console_type =
+       | CONSOLETYPE_XENCONSOLED
+       | CONSOLETYPE_IOEMU
+
+type disk_phystype =
+       | PHYSTYPE_QCOW
+       | PHYSTYPE_QCOW2
+       | PHYSTYPE_VHD
+       | PHYSTYPE_AIO
+       | PHYSTYPE_FILE
+       | PHYSTYPE_PHY
+
+type nic_type =
+       | NICTYPE_IOEMU
+       | NICTYPE_VIF
+
+type button =
+       | Button_Power
+       | Button_Sleep
+
+module Device_vfb : sig
+       type t =
+       {
+               backend_domid : domid;
+               devid : int;
+               vnc : bool;
+               vnclisten : string;
+               vncpasswd : string;
+               vncdisplay : int;
+               vncunused : bool;
+               keymap : string;
+               sdl : bool;
+               opengl : bool;
+               display : string;
+               xauthority : string;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_vfb_add"
+       external clean_shutdown : domid -> unit = 
"stub_xl_device_vfb_clean_shutdown"
+       external hard_shutdown : domid -> unit = 
"stub_xl_device_vfb_hard_shutdown"
+end
+
+module Device_vkb : sig
+       type t =
+       {
+               backend_domid : domid;
+               devid : int;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_vkb_add"
+       external clean_shutdown : domid -> unit = 
"stub_xl_device_vkb_clean_shutdown"
+       external hard_shutdown : domid -> unit = 
"stub_xl_device_vkb_hard_shutdown"
+end
+
+module Device_disk : sig
+       type t =
+       {
+               backend_domid : domid;
+               physpath : string;
+               phystype : disk_phystype;
+               virtpath : string;
+               unpluggable : bool;
+               readwrite : bool;
+               is_cdrom : bool;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_disk_add"
+       external del : t -> domid -> unit = "stub_xl_device_disk_del"
+end
+
+module Device_nic : sig
+       type t =
+       {
+               backend_domid : domid;
+               devid : int;
+               mtu : int;
+               model : string;
+               mac : int array;
+               bridge : string;
+               ifname : string;
+               script : string;
+               nictype : nic_type;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_nic_add"
+       external del : t -> domid -> unit = "stub_xl_device_nic_del"
+end
+
+module Device_pci : sig
+       type t =
+       {
+               func : int;
+               dev : int;
+               bus : int;
+               domain : int;
+               vdevfn : int;
+               msitranslate : bool;
+               power_mgmt : bool;
+       }
+       external add : t -> domid -> unit = "stub_xl_device_pci_add"
+       external remove : t -> domid -> unit = "stub_xl_device_pci_remove"
+       external shutdown : domid -> unit = "stub_xl_device_pci_shutdown"
+end
+
+module Physinfo : sig
+       type t =
+       {
+               threads_per_core : int;
+               cores_per_socket : int;
+               max_cpu_id : int;
+               nr_cpus : int;
+               cpu_khz : int;
+               total_pages : int64;
+               free_pages : int64;
+               scrub_pages : int64;
+               nr_nodes : int;
+               hwcap : int32 array;
+               physcap : int32;
+       }
+       external get : unit -> t = "stub_xl_physinfo"
+end
+
+module Sched_credit : sig
+       type t =
+       {
+               weight : int;
+               cap : int;
+       }
+       external domain_get : domid -> t = "stub_xl_sched_credit_domain_get"
+       external domain_set : domid -> t -> unit = 
"stub_xl_sched_credit_domain_set"
+end
+
+module Device_build_state : sig
+       type t =
+       {
+               store_port : int;
+               store_mfn : int64;
+               console_port : int;
+               console_mfn : int64;
+       }
+end
+
+module Device_console : sig
+       type t =
+       {
+               backend_domid : domid;
+               devid : int;
+               consoletype : console_type;
+       }
+
+       external add : t -> Device_build_state.t -> domid -> unit = 
"stub_xl_device_console_add"
+end
+
+module Topologyinfo : sig
+       type t =
+       {
+               core : int;
+               socket : int;
+               node : int;
+       }
+       external get : unit -> t = "stub_xl_topologyinfo"
+end
+
+external button_press : domid -> button -> unit = "stub_xl_button_press"
+
+external send_trigger : domid -> string -> int -> unit = "stub_xl_send_trigger"
+external send_sysrq : domid -> char -> unit = "stub_xl_send_sysrq"
+external send_debug_keys : domid -> string -> unit = "stub_xl_send_debug_keys"
diff -r 3c51e7bfe289 -r 5bbea737a0dc tools/ocaml/libs/xl/xl_stubs.c
--- a/tools/ocaml/libs/xl/xl_stubs.c    Wed Apr 13 13:35:52 2011 +0100
+++ b/tools/ocaml/libs/xl/xl_stubs.c    Wed Apr 13 13:35:52 2011 +0100
@@ -26,7 +26,7 @@
 #include <stdint.h>
 #include <string.h>
 
-#include "libxl.h"
+#include <libxl.h>
 
 struct caml_logger {
        struct xentoollog_logger logger;
@@ -130,6 +130,8 @@ static int string_string_tuple_array_val
 
 #endif
 
+#include "_libxl_types.inc"
+
 static int device_disk_val(caml_gc *gc, libxl_device_disk *c_val, value v)
 {
        CAMLparam1(v);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>