]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blob - xen/patches/52-upstream-23938:fa04fbd56521-rework.patch
Merge remote-tracking branch 'arne_f/autoconf'
[people/arne_f/ipfire-3.x.git] / xen / patches / 52-upstream-23938:fa04fbd56521-rework.patch
1 # HG changeset patch
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
7
8 This patch has the same effect as xen-unstable.hg c/s
9 23938:fa04fbd56521
10
11 The library was only minimally used, and was really rather redundant.
12
13 Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
14 Acked-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
15
16 --- a/tools/ocaml/libs/Makefile
17 +++ b/tools/ocaml/libs/Makefile
18 @@ -2,7 +2,7 @@
19 include $(XEN_ROOT)/tools/Rules.mk
20
21 SUBDIRS= \
22 - uuid mmap \
23 + mmap \
24 log xc eventchn \
25 xb xs xl
26
27 --- a/tools/ocaml/libs/uuid/META.in
28 +++ /dev/null
29 @@ -1,4 +0,0 @@
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
35 +++ /dev/null
36 @@ -1,100 +0,0 @@
37 -(*
38 - * Copyright (C) 2006-2010 Citrix Systems Inc.
39 - * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
40 - *
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.
45 - *
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.
50 - *)
51 -
52 -(* Internally, a UUID is simply a string. *)
53 -type 'a t = string
54 -
55 -type cookie = string
56 -
57 -let of_string s = s
58 -let to_string s = s
59 -
60 -let null = ""
61 -
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
65 -
66 -let string_of_cookie s = s
67 -
68 -let cookie_of_string s = s
69 -
70 -let dev_random = "/dev/random"
71 -let dev_urandom = "/dev/urandom"
72 -
73 -let rnd_array n =
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
78 - | 0 -> acc
79 - | 1 ->
80 - let b = fstbyte (Random.bits ()) in
81 - b :: acc
82 - | 2 ->
83 - let r = Random.bits () in
84 - let b1 = fstbyte r in
85 - let b2 = sndbyte r in
86 - b1 :: b2 :: acc
87 - | n ->
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)
93 - in
94 - Array.of_list (rnd_list n [])
95 -
96 -let read_array dev n =
97 - let ic = open_in_bin dev in
98 - try
99 - let result = Array.init n (fun _ -> input_byte ic) in
100 - close_in ic;
101 - result
102 - with e ->
103 - close_in ic;
104 - raise e
105 -
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)
111 -
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
116 -
117 -let make_cookie() =
118 - let bytes = Array.to_list (read_array dev_urandom 64) in
119 - String.concat "" (List.map (Printf.sprintf "%1x") bytes)
120 -
121 -let int_array_of_uuid s =
122 - try
123 - let l = ref [] in
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; ]);
128 - Array.of_list !l
129 - with _ -> invalid_arg "Uuid.int_array_of_uuid"
130 -
131 -let is_uuid str =
132 - try
133 - Scanf.sscanf str
134 - "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
135 - (fun _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -> true)
136 - with _ -> false
137 --- a/tools/ocaml/libs/uuid/uuid.mli
138 +++ /dev/null
139 @@ -1,67 +0,0 @@
140 -(*
141 - * Copyright (C) 2006-2010 Citrix Systems Inc.
142 - * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
143 - *
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.
148 - *
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.
153 - *)
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
158 -
159 - There is the additional constraint that current Xen tools use
160 - a particular format of UUID (the 16 byte variety generated by fresh ())
161 -
162 - Also, cookies aren't UUIDs and should be put somewhere else.
163 -*)
164 -
165 -(** A 128-bit UUID. Using phantom types ('a) to achieve the requires type-safety. *)
166 -type 'a t
167 -
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
173 -
174 -(** Create a UUID from a string. *)
175 -val of_string : string -> 'a t
176 -
177 -(** Marshal a UUID to a string. *)
178 -val to_string : 'a t -> string
179 -
180 -(** A null UUID, as if such a thing actually existed. It turns out to be
181 - * useful though. *)
182 -val null : 'a t
183 -
184 -(** Deprecated alias for {! Uuid.of_string} *)
185 -val uuid_of_string : string -> 'a t
186 -
187 -(** Deprecated alias for {! Uuid.to_string} *)
188 -val string_of_uuid : 'a t -> string
189 -
190 -(** Convert an array to a UUID. *)
191 -val uuid_of_int_array : int array -> 'a t
192 -
193 -(** Convert a UUID to an array. *)
194 -val int_array_of_uuid : 'a t -> int array
195 -
196 -(** Check whether a string is a UUID. *)
197 -val is_uuid : string -> bool
198 -
199 -(** A 512-bit cookie. *)
200 -type cookie
201 -
202 -val make_cookie : unit -> cookie
203 -
204 -val cookie_of_string : string -> cookie
205 -
206 -val string_of_cookie : cookie -> string
207 --- a/tools/ocaml/libs/xc/META.in
208 +++ b/tools/ocaml/libs/xc/META.in
209 @@ -1,5 +1,5 @@
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
218 @@ -3,7 +3,7 @@
219 include $(TOPLEVEL)/common.make
220
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
224
225 OBJS = xenctrl
226 INTF = xenctrl.cmi
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"
232
233 +let int_array_of_uuid_string s =
234 + try
235 + Scanf.sscanf 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)
241 +
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)
245
246 external _domain_sethandle: handle -> domid -> int array -> unit
247 = "stub_xc_domain_sethandle"
248
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)
252
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
257 @@ -74,12 +74,8 @@
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
274 @@ -5,7 +5,6 @@
275 OCAMLINCLUDE += \
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
282 @@ -34,7 +33,6 @@
283 INTF = symbol.cmi trie.cmi
284 XENSTOREDLIBS = \
285 unix.cmxa \
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
291 +++ /dev/null
292 @@ -1,29 +0,0 @@
293 -TOPLEVEL=$(CURDIR)/../..
294 -XEN_ROOT=$(TOPLEVEL)/../..
295 -include $(TOPLEVEL)/common.make
296 -
297 -OBJS = uuid
298 -INTF = $(foreach obj, $(OBJS),$(obj).cmi)
299 -LIBS = uuid.cma uuid.cmxa
300 -
301 -all: $(INTF) $(LIBS) $(PROGRAMS)
302 -
303 -bins: $(PROGRAMS)
304 -
305 -libs: $(LIBS)
306 -
307 -uuid_OBJS = $(OBJS)
308 -OCAML_NOC_LIBRARY = uuid
309 -
310 -.PHONY: install
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
315 -
316 -.PHONY: uninstall
317 -uninstall:
318 - ocamlfind remove -destdir $(OCAMLDESTDIR) uuid
319 -
320 -include $(TOPLEVEL)/Makefile.rules
321 -