2 # User Jon Ludlam <jonathan.ludlam@eu.citrix.com>
3 # Date 1317295879 -3600
4 # Node ID 6c87e9dc5331096e8bfbad60a4f560cae05c4034
5 # Parent c5df5f625ee2a0339b2a6785f99a5a0f9727f836
6 [OCAML] Remove the uuid library
8 This patch has the same effect as xen-unstable.hg c/s
11 The library was only minimally used, and was really rather redundant.
13 Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
14 Acked-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
16 --- a/tools/ocaml/libs/Makefile
17 +++ b/tools/ocaml/libs/Makefile
19 include $(XEN_ROOT)/tools/Rules.mk
27 --- a/tools/ocaml/libs/uuid/META.in
30 -version = "@VERSION@"
31 -description = "Uuid - universal identifer"
32 -archive(byte) = "uuid.cma"
33 -archive(native) = "uuid.cmxa"
34 --- a/tools/ocaml/libs/uuid/uuid.ml
38 - * Copyright (C) 2006-2010 Citrix Systems Inc.
39 - * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
41 - * This program is free software; you can redistribute it and/or modify
42 - * it under the terms of the GNU Lesser General Public License as published
43 - * by the Free Software Foundation; version 2.1 only. with the special
44 - * exception on linking described in file LICENSE.
46 - * This program is distributed in the hope that it will be useful,
47 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
48 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 - * GNU Lesser General Public License for more details.
52 -(* Internally, a UUID is simply a string. *)
62 -(* deprecated: we don't need to duplicate the uuid prefix/suffix *)
63 -let uuid_of_string = of_string
64 -let string_of_uuid = to_string
66 -let string_of_cookie s = s
68 -let cookie_of_string s = s
70 -let dev_random = "/dev/random"
71 -let dev_urandom = "/dev/urandom"
74 - let fstbyte i = 0xff land i in
75 - let sndbyte i = fstbyte (i lsr 8) in
76 - let thdbyte i = sndbyte (i lsr 8) in
77 - let rec rnd_list n acc = match n with
80 - let b = fstbyte (Random.bits ()) in
83 - let r = Random.bits () in
84 - let b1 = fstbyte r in
85 - let b2 = sndbyte r in
88 - let r = Random.bits () in
89 - let b1 = fstbyte r in
90 - let b2 = sndbyte r in
91 - let b3 = thdbyte r in
92 - rnd_list (n - 3) (b1 :: b2 :: b3 :: acc)
94 - Array.of_list (rnd_list n [])
96 -let read_array dev n =
97 - let ic = open_in_bin dev in
99 - let result = Array.init n (fun _ -> input_byte ic) in
106 -let uuid_of_int_array uuid =
107 - Printf.sprintf "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
108 - uuid.(0) uuid.(1) uuid.(2) uuid.(3) uuid.(4) uuid.(5)
109 - uuid.(6) uuid.(7) uuid.(8) uuid.(9) uuid.(10) uuid.(11)
110 - uuid.(12) uuid.(13) uuid.(14) uuid.(15)
112 -let make_uuid_prng () = uuid_of_int_array (rnd_array 16)
113 -let make_uuid_urnd () = uuid_of_int_array (read_array dev_urandom 16)
114 -let make_uuid_rnd () = uuid_of_int_array (read_array dev_random 16)
115 -let make_uuid = make_uuid_urnd
118 - let bytes = Array.to_list (read_array dev_urandom 64) in
119 - String.concat "" (List.map (Printf.sprintf "%1x") bytes)
121 -let int_array_of_uuid s =
124 - Scanf.sscanf s "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
125 - (fun a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 ->
126 - l := [ a0; a1; a2; a3; a4; a5; a6; a7; a8; a9;
127 - a10; a11; a12; a13; a14; a15; ]);
129 - with _ -> invalid_arg "Uuid.int_array_of_uuid"
134 - "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
135 - (fun _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -> true)
137 --- a/tools/ocaml/libs/uuid/uuid.mli
141 - * Copyright (C) 2006-2010 Citrix Systems Inc.
142 - * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
144 - * This program is free software; you can redistribute it and/or modify
145 - * it under the terms of the GNU Lesser General Public License as published
146 - * by the Free Software Foundation; version 2.1 only. with the special
147 - * exception on linking described in file LICENSE.
149 - * This program is distributed in the hope that it will be useful,
150 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
151 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
152 - * GNU Lesser General Public License for more details.
154 -(** Type-safe UUIDs.
155 - Probably need to refactor this; UUIDs are used in two places:
156 - + to uniquely name things across the cluster
157 - + as secure session IDs
159 - There is the additional constraint that current Xen tools use
160 - a particular format of UUID (the 16 byte variety generated by fresh ())
162 - Also, cookies aren't UUIDs and should be put somewhere else.
165 -(** A 128-bit UUID. Using phantom types ('a) to achieve the requires type-safety. *)
168 -(** Create a fresh UUID *)
169 -val make_uuid : unit -> 'a t
170 -val make_uuid_prng : unit -> 'a t
171 -val make_uuid_urnd : unit -> 'a t
172 -val make_uuid_rnd : unit -> 'a t
174 -(** Create a UUID from a string. *)
175 -val of_string : string -> 'a t
177 -(** Marshal a UUID to a string. *)
178 -val to_string : 'a t -> string
180 -(** A null UUID, as if such a thing actually existed. It turns out to be
181 - * useful though. *)
184 -(** Deprecated alias for {! Uuid.of_string} *)
185 -val uuid_of_string : string -> 'a t
187 -(** Deprecated alias for {! Uuid.to_string} *)
188 -val string_of_uuid : 'a t -> string
190 -(** Convert an array to a UUID. *)
191 -val uuid_of_int_array : int array -> 'a t
193 -(** Convert a UUID to an array. *)
194 -val int_array_of_uuid : 'a t -> int array
196 -(** Check whether a string is a UUID. *)
197 -val is_uuid : string -> bool
199 -(** A 512-bit cookie. *)
202 -val make_cookie : unit -> cookie
204 -val cookie_of_string : string -> cookie
206 -val string_of_cookie : cookie -> string
207 --- a/tools/ocaml/libs/xc/META.in
208 +++ b/tools/ocaml/libs/xc/META.in
210 version = "@VERSION@"
211 description = "Xen Control Interface"
212 -requires = "unix,xenmmap,uuid"
213 +requires = "unix,xenmmap"
214 archive(byte) = "xenctrl.cma"
215 archive(native) = "xenctrl.cmxa"
216 --- a/tools/ocaml/libs/xc/Makefile
217 +++ b/tools/ocaml/libs/xc/Makefile
219 include $(TOPLEVEL)/common.make
221 CFLAGS += -I../mmap -I./ -I$(XEN_ROOT)/tools/libxc
222 -OCAMLINCLUDE += -I ../mmap -I ../uuid -I $(XEN_ROOT)/tools/libxc
223 +OCAMLINCLUDE += -I ../mmap -I $(XEN_ROOT)/tools/libxc
227 --- a/tools/ocaml/libs/xc/xenctrl.ml
228 +++ b/tools/ocaml/libs/xc/xenctrl.ml
229 @@ -118,14 +118,23 @@
230 external _domain_create: handle -> int32 -> domain_create_flag list -> int array -> domid
231 = "stub_xc_domain_create"
233 +let int_array_of_uuid_string s =
236 + "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
237 + (fun a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 ->
238 + [| a0; a1; a2; a3; a4; a5; a6; a7;
239 + a8; a9; a10; a11; a12; a13; a14; a15 |])
240 + with _ -> invalid_arg ("Xc.int_array_of_uuid_string: " ^ s)
242 let domain_create handle n flags uuid =
243 - _domain_create handle n flags (Uuid.int_array_of_uuid uuid)
244 + _domain_create handle n flags (int_array_of_uuid_string uuid)
246 external _domain_sethandle: handle -> domid -> int array -> unit
247 = "stub_xc_domain_sethandle"
249 let domain_sethandle handle n uuid =
250 - _domain_sethandle handle n (Uuid.int_array_of_uuid uuid)
251 + _domain_sethandle handle n (int_array_of_uuid_string uuid)
253 external domain_max_vcpus: handle -> domid -> int -> unit
254 = "stub_xc_domain_max_vcpus"
255 --- a/tools/ocaml/libs/xc/xenctrl.mli
256 +++ b/tools/ocaml/libs/xc/xenctrl.mli
258 external is_fake : unit -> bool = "stub_xc_interface_is_fake"
259 external interface_close : handle -> unit = "stub_xc_interface_close"
260 val with_intf : (handle -> 'a) -> 'a
261 -external _domain_create : handle -> int32 -> domain_create_flag list -> int array -> domid
262 - = "stub_xc_domain_create"
263 -val domain_create : handle -> int32 -> domain_create_flag list -> 'a Uuid.t -> domid
264 -external _domain_sethandle : handle -> domid -> int array -> unit
265 - = "stub_xc_domain_sethandle"
266 -val domain_sethandle : handle -> domid -> 'a Uuid.t -> unit
267 +val domain_create : handle -> int32 -> domain_create_flag list -> string -> domid
268 +val domain_sethandle : handle -> domid -> string -> unit
269 external domain_max_vcpus : handle -> domid -> int -> unit
270 = "stub_xc_domain_max_vcpus"
271 external domain_pause : handle -> domid -> unit = "stub_xc_domain_pause"
272 --- a/tools/ocaml/xenstored/Makefile
273 +++ b/tools/ocaml/xenstored/Makefile
276 -I $(OCAML_TOPLEVEL)/libs/log \
277 -I $(OCAML_TOPLEVEL)/libs/xb \
278 - -I $(OCAML_TOPLEVEL)/libs/uuid \
279 -I $(OCAML_TOPLEVEL)/libs/mmap \
280 -I $(OCAML_TOPLEVEL)/libs/xc \
281 -I $(OCAML_TOPLEVEL)/libs/eventchn
283 INTF = symbol.cmi trie.cmi
286 - $(OCAML_TOPLEVEL)/libs/uuid/uuid.cmxa \
287 -ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/mmap $(OCAML_TOPLEVEL)/libs/mmap/xenmmap.cmxa \
288 -ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/log $(OCAML_TOPLEVEL)/libs/log/log.cmxa \
289 -ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
290 --- a/tools/ocaml/libs/uuid/Makefile
293 -TOPLEVEL=$(CURDIR)/../..
294 -XEN_ROOT=$(TOPLEVEL)/../..
295 -include $(TOPLEVEL)/common.make
298 -INTF = $(foreach obj, $(OBJS),$(obj).cmi)
299 -LIBS = uuid.cma uuid.cmxa
301 -all: $(INTF) $(LIBS) $(PROGRAMS)
308 -OCAML_NOC_LIBRARY = uuid
311 -install: $(LIBS) META
312 - mkdir -p $(OCAMLDESTDIR)
313 - ocamlfind remove -destdir $(OCAMLDESTDIR) uuid
314 - ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore uuid META $(INTF) $(LIBS) *.a *.cmx
318 - ocamlfind remove -destdir $(OCAMLDESTDIR) uuid
320 -include $(TOPLEVEL)/Makefile.rules