1(* 2 * Copyright (C) 2009-2011 Citrix Ltd. 3 * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License as published 7 * by the Free Software Foundation; version 2.1 only. with the special 8 * exception on linking described in file LICENSE. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 *) 15 16type ctx 17type domid = int 18type devid = int 19 20(* @@LIBXL_TYPES@@ *) 21 22exception Error of (error * string) 23 24val register_exceptions: unit -> unit 25 26external ctx_alloc: Xentoollog.handle -> ctx = "stub_libxl_ctx_alloc" 27 28external test_raise_exception: unit -> unit = "stub_raise_exception" 29 30type event = 31 | POLLIN (* There is data to read *) 32 | POLLPRI (* There is urgent data to read *) 33 | POLLOUT (* Writing now will not block *) 34 | POLLERR (* Error condition (revents only) *) 35 | POLLHUP (* Device has been disconnected (revents only) *) 36 | POLLNVAL (* Invalid request: fd not open (revents only). *) 37 38module Domain : sig 39 external create_new : ctx -> Domain_config.t -> ?async:'a -> unit -> domid = "stub_libxl_domain_create_new" 40 external create_restore : ctx -> Domain_config.t -> (Unix.file_descr * Domain_restore_params.t) -> 41 ?async:'a -> unit -> domid = "stub_libxl_domain_create_restore" 42 external shutdown : ctx -> domid -> ?async:'a -> unit -> unit = "stub_libxl_domain_shutdown" 43 external reboot : ctx -> domid -> ?async:'a -> unit -> unit = "stub_libxl_domain_reboot" 44 external destroy : ctx -> domid -> ?async:'a -> unit -> unit = "stub_libxl_domain_destroy" 45 external suspend : ctx -> domid -> Unix.file_descr -> ?async:'a -> unit -> unit = "stub_libxl_domain_suspend" 46 external pause : ctx -> domid -> ?async:'a -> unit = "stub_libxl_domain_pause" 47 external unpause : ctx -> domid -> ?async:'a -> unit = "stub_libxl_domain_unpause" 48 49 external send_trigger : ctx -> domid -> trigger -> int -> ?async:'a -> unit = "stub_xl_send_trigger" 50 external send_sysrq : ctx -> domid -> char -> unit = "stub_xl_send_sysrq" 51end 52 53module Host : sig 54 type console_reader 55 exception End_of_file 56 57 external xen_console_read_start : ctx -> int -> console_reader = "stub_libxl_xen_console_read_start" 58 external xen_console_read_line : ctx -> console_reader -> string = "stub_libxl_xen_console_read_line" 59 external xen_console_read_finish : ctx -> console_reader -> unit = "stub_libxl_xen_console_read_finish" 60 61 external send_debug_keys : ctx -> string -> unit = "stub_xl_send_debug_keys" 62end 63 64module Async : sig 65 type for_libxl 66 type event_hooks 67 type osevent_hooks 68 69 val osevent_register_hooks : ctx -> 70 user:'a -> 71 fd_register:('a -> Unix.file_descr -> event list -> for_libxl -> 'b) -> 72 fd_modify:('a -> Unix.file_descr -> 'b -> event list -> 'b) -> 73 fd_deregister:('a -> Unix.file_descr -> 'b -> unit) -> 74 timeout_register:('a -> int64 -> int64 -> for_libxl -> 'c) -> 75 timeout_fire_now:('a -> 'c -> 'c) -> 76 osevent_hooks 77 78 external osevent_occurred_fd : ctx -> for_libxl -> Unix.file_descr -> event list -> event list -> unit = "stub_libxl_osevent_occurred_fd" 79 external osevent_occurred_timeout : ctx -> for_libxl -> unit = "stub_libxl_osevent_occurred_timeout" 80 81 val async_register_callback : 82 async_callback:(result:error option -> user:'a -> unit) -> 83 unit 84 85 external evenable_domain_death : ctx -> domid -> int -> unit = "stub_libxl_evenable_domain_death" 86 87 val event_register_callbacks : ctx -> 88 user:'a -> 89 event_occurs_callback:('a -> Event.t -> unit) -> 90 event_disaster_callback:('a -> event_type -> string -> int -> unit) -> 91 event_hooks 92end 93 94