diff --git a/dune-project b/dune-project index eba1984ca9a..ac02a1c296d 100644 --- a/dune-project +++ b/dune-project @@ -1,4 +1,4 @@ -(lang dune 2.0) +(lang dune 3.0) (formatting (enabled_for ocaml)) (generate_opam_files true) @@ -68,8 +68,8 @@ re uri (uuid :with-test) - (xapi-log :version) - (xapi-stdext-threads :version) + (xapi-log (= :version)) + (xapi-stdext-threads (= :version)) ) (synopsis "Allows to instrument code to generate tracing information") (description "This library provides modules to allow gathering runtime traces.") @@ -83,12 +83,13 @@ dune cohttp rpclib - (xapi-log :version) - (xapi-open-uri :version) - (xapi-stdext-threads :version) - (xapi-stdext-unix :version) - (xapi-tracing :version) - (zstd :version) + ppx_deriving_rpc + (xapi-log (= :version)) + (xapi-open-uri (= :version)) + (xapi-stdext-threads (= :version)) + (xapi-stdext-unix (= :version)) + (xapi-tracing (= :version)) + (zstd (= :version)) ) (synopsis "Export traces in multiple protocols and formats") (description "This library export traces is able to push traces to http endpoints or generate compressed tarballs in the filesystem.") @@ -122,12 +123,13 @@ ocaml astring rpclib - (xapi-forkexecd :version) - (xapi-stdext-pervasives :version) - (xapi-stdext-std :version) - (xapi-stdext-threads :version) - (xapi-stdext-unix :version) - (xapi-idl :version) + (rrd-transport (= :version)) + (xapi-forkexecd (= :version)) + (xapi-stdext-pervasives (= :version)) + (xapi-stdext-std (= :version)) + (xapi-stdext-threads (= :version)) + (xapi-stdext-unix (= :version)) + (xapi-idl (= :version)) xenstore_transport ) ) @@ -140,20 +142,21 @@ (ocaml (>= "4.02.0")) dune-build-info astring - (gzip :version) - (http-lib :version) + (gzip (= :version)) + (http-lib (= :version)) inotify io-page mtime ppx_deriving_rpc rpclib systemd - (ezxenstore :version) - (uuid :version) - (xapi-backtrace :version) - (xapi-idl :version) - (xapi-rrd :version) - (xapi-stdext-threads :version) + (ezxenstore (= :version)) + (uuid (= :version)) + xapi-backtrace + (xapi-idl (= :version)) + (xapi-rrd (= :version)) + (xapi-stdext-threads (= :version)) + (xapi-stdext-unix (= :version)) ) ) @@ -165,6 +168,9 @@ (depends ocaml cmdliner + (rrd-transport (= :version)) + (xapi-idl (= :version)) + (xapi-rrd (= :version)) ) ) @@ -286,6 +292,19 @@ (package (name message-switch-core) + (synopsis "A simple store-and-forward message switch") + (description "The switch stores messages in queues with well-known names. Clients use a simple HTTP protocol to enqueue and dequeue messages.") + (depends + astring + (cohttp (>= "0.21.1")) + ppx_deriving_rpc + ppx_sexp_conv + rpclib + sexplib + (xapi-log (= :version)) + (xapi-stdext-threads (= :version)) + (odoc :with-doc) + ) ) (package diff --git a/message-switch-core.opam b/message-switch-core.opam index 44e2983cc5b..2d671053b9b 100644 --- a/message-switch-core.opam +++ b/message-switch-core.opam @@ -1,33 +1,37 @@ # This file is generated by dune, edit dune-project instead -license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" opam-version: "2.0" -name: "message-switch-core" -maintainer: "xen-api@lists.xen.org" -authors: [ "xen-api@lists.xen.org" ] -homepage: "https://github.com/xapi-project/xen-api" +synopsis: "A simple store-and-forward message switch" +description: + "The switch stores messages in queues with well-known names. Clients use a simple HTTP protocol to enqueue and dequeue messages." +maintainer: ["Xapi project maintainers"] +authors: ["xen-api@lists.xen.org"] +license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" +homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" -dev-repo: "git+https://github.com/xapi-project/xen-api.git" -tags: [ "org:xapi-project" ] -build: [ - ["./configure" "--prefix" "%{prefix}%"] - [ "dune" "build" "-p" name "-j" jobs ] -] depends: [ - "ocaml" - "dune" {build & >= "1.4"} - "odoc" {with-doc} + "dune" {>= "3.0"} "astring" "cohttp" {>= "0.21.1"} "ppx_deriving_rpc" "ppx_sexp_conv" "rpclib" "sexplib" - "xapi-log" + "xapi-log" {= version} + "xapi-stdext-threads" {= version} + "odoc" {with-doc} ] -synopsis: "A simple store-and-forward message switch" -description: """ -The switch stores messages in queues with well-known names. Clients use -a simple HTTP protocol to enqueue and dequeue messages.""" -url { - src: "https://github.com/xapi-project/xen-api/archive/master.tar.gz" -} +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/xapi-project/xen-api.git" diff --git a/message-switch-core.opam.template b/message-switch-core.opam.template deleted file mode 100644 index 7f65fa07598..00000000000 --- a/message-switch-core.opam.template +++ /dev/null @@ -1,31 +0,0 @@ -opam-version: "2.0" -name: "message-switch-core" -maintainer: "xen-api@lists.xen.org" -authors: [ "xen-api@lists.xen.org" ] -homepage: "https://github.com/xapi-project/xen-api" -bug-reports: "https://github.com/xapi-project/xen-api/issues" -dev-repo: "git+https://github.com/xapi-project/xen-api.git" -tags: [ "org:xapi-project" ] -build: [ - ["./configure" "--prefix" "%{prefix}%"] - [ "dune" "build" "-p" name "-j" jobs ] -] -depends: [ - "ocaml" - "dune" {build & >= "1.4"} - "odoc" {with-doc} - "astring" - "cohttp" {>= "0.21.1"} - "ppx_deriving_rpc" - "ppx_sexp_conv" - "rpclib" - "sexplib" - "xapi-log" -] -synopsis: "A simple store-and-forward message switch" -description: """ -The switch stores messages in queues with well-known names. Clients use -a simple HTTP protocol to enqueue and dequeue messages.""" -url { - src: "https://github.com/xapi-project/xen-api/archive/master.tar.gz" -} diff --git a/ocaml/database/unit_test_marshall.ml b/ocaml/database/unit_test_marshall.ml index a9a77a11560..46b8990c24f 100644 --- a/ocaml/database/unit_test_marshall.ml +++ b/ocaml/database/unit_test_marshall.ml @@ -197,6 +197,7 @@ let tests = ; (test_ivr_response, "test_ivr_response") ; (test_rr_args, "test_rr_args") ; (test_rr_response, "test_rr_response") + ; (test_rfw_args, "test_rfw_args") ; (test_cra_args, "test_cra_args") ; (test_cra_response, "test_cra_response") ; (test_dr_args, "test_dr_args") diff --git a/ocaml/database/unit_test_sql.ml b/ocaml/database/unit_test_sql.ml index 7fdf2823112..850333ae17d 100644 --- a/ocaml/database/unit_test_sql.ml +++ b/ocaml/database/unit_test_sql.ml @@ -17,8 +17,6 @@ let str = Xml.to_string_fmt xml let parse () = ignore (Xml.parse_string str) -let to_string () = ignore (Xml.to_string_fmt xml) - let rec repeat f i () = if i = 0 then () diff --git a/ocaml/db_process/xapi_db_process.ml b/ocaml/db_process/xapi_db_process.ml index fe5e509645e..7c3e1eef13f 100644 --- a/ocaml/db_process/xapi_db_process.ml +++ b/ocaml/db_process/xapi_db_process.ml @@ -74,9 +74,6 @@ let write_out_databases () = (Db_conn_store.read_db_connections ()) (Db_ref.get_database (Db_backend.make ())) -(* should never be thrown due to checking argument at start *) -exception UnknownFormat - let write_out_database filename = print_string ("Dumping database to: " ^ filename ^ "\n") ; Db_cache_impl.sync diff --git a/ocaml/gencert/test_lib.ml b/ocaml/gencert/test_lib.ml index 8ab4abf3ebd..fddee2ad41c 100644 --- a/ocaml/gencert/test_lib.ml +++ b/ocaml/gencert/test_lib.ml @@ -123,8 +123,6 @@ let corrupt_chain_certificates = ) ] -let server_error err reason = Server_error (err, reason) - let test_valid_key key_name () = match validate_private_key (load_test_data key_name) with | Ok _ -> diff --git a/ocaml/libs/vhd/vhd_format_lwt_test/parse_test.ml b/ocaml/libs/vhd/vhd_format_lwt_test/parse_test.ml index ee68ad8a3ee..9f94653f466 100644 --- a/ocaml/libs/vhd/vhd_format_lwt_test/parse_test.ml +++ b/ocaml/libs/vhd/vhd_format_lwt_test/parse_test.ml @@ -25,10 +25,6 @@ let create () = let _ = Create_vhd.disk in () -let diff () = - let _ = Diff_vhd.disk in - () - let tmp_file_dir = Filename.get_temp_dir_name () let disk_name_stem = tmp_file_dir ^ "/parse_test." @@ -174,8 +170,6 @@ let absolute_sector_of vhd {block; sector} = (of_int relative_sector) ) -let cstruct_to_string c = String.escaped (Cstruct.to_string c) - type state = { to_close: fd Vhd.t list ; to_unlink: string list diff --git a/ocaml/libs/xapi-rrd/lib_test/crowbar_tests.ml b/ocaml/libs/xapi-rrd/lib_test/crowbar_tests.ml index 2aecd81d030..d3f01762d29 100644 --- a/ocaml/libs/xapi-rrd/lib_test/crowbar_tests.ml +++ b/ocaml/libs/xapi-rrd/lib_test/crowbar_tests.ml @@ -37,18 +37,6 @@ let test_ranges rrd = let in_range_rra dss rra = Array.iter2 in_range_fring dss rra.rra_data in Array.iter (in_range_rra rrd.rrd_dss) rrd.rrd_rras -let same_input_type vf vf' = - let open Rrd in - match vf vf' with - | VT_Unknown, VT_Unknown -> - true - | VT_Int64 _, VT_Int64 _ -> - true - | VT_Float _, VT_Float _ -> - true - | _ -> - false - let cf = Cb.choose [ diff --git a/ocaml/libs/xapi-rrd/lib_test/unit_tests.ml b/ocaml/libs/xapi-rrd/lib_test/unit_tests.ml index d1938b68a42..b48ebf17688 100644 --- a/ocaml/libs/xapi-rrd/lib_test/unit_tests.ml +++ b/ocaml/libs/xapi-rrd/lib_test/unit_tests.ml @@ -106,31 +106,6 @@ let test_marshall_unmarshall rrd () = let rrd' = Rrd.from_xml xml in assert_rrds_equal rrd rrd' -let test_export rrd () = - let check_same_as_rras (updates : Rrd_updates.row array) (rras : Rrd.rra array) - = - let cf_count = Array.length rras in - for i = 0 to cf_count - 1 do - (* consolidation functions *) - for j = 0 to Array.length rras.(0).Rrd.rra_data - 1 do - (* datasources *) - for k = 0 to Rrd_fring.length rras.(0).Rrd.rra_data.(0) - 1 do - (* time datapoints *) - let update_value = - updates.(k).Rrd_updates.row_data.(i + (j * cf_count)) - in - let rra_value = Rrd_fring.peek rras.(i).Rrd.rra_data.(j) k in - compare_float - (Printf.sprintf "CF: %d Datasource: %d datapoint: %d " i j k) - update_value rra_value - done - done - done - in - - let updates = Rrd_updates.(of_string @@ export [("", rrd)] 0L 5L None) in - check_same_as_rras updates.Rrd_updates.data rrd.rrd_rras - let test_length_invariants rrd () = let check_length_of_fring dss (frings : Rrd_fring.t array) = Alcotest.(check int) @@ -172,9 +147,9 @@ let of_file filename = let input = Xmlm.make_input (`String (0, body)) in Rrd.from_xml input -(* Used to generate flip_flop.xml for test_ca_325844, - * then gets edited manually to set min to 0 *) -let deserialize_verify_rrd = +(* Used to generate flip_flop.xml for test_ca_325844, then gets edited manually + to set min to 0 *) +let _deserialize_verify_rrd = let init_time = 0. in let rra1 = rra_create CF_Average 100 1 0.5 in diff --git a/ocaml/libs/xapi-stdext/lib/xapi-stdext-date/test.ml b/ocaml/libs/xapi-stdext/lib/xapi-stdext-date/test.ml index 66ec59696da..c839722d81f 100644 --- a/ocaml/libs/xapi-stdext/lib/xapi-stdext-date/test.ml +++ b/ocaml/libs/xapi-stdext/lib/xapi-stdext-date/test.ml @@ -2,8 +2,6 @@ open Xapi_stdext_date.Date let check_float = Alcotest.(check @@ float 1e-2) -let check_float_neq = Alcotest.(check @@ neg @@ float 1e-2) - let check_string = Alcotest.(check string) let check_true str = Alcotest.(check bool) str true diff --git a/ocaml/libs/xapi-stdext/lib/xapi-stdext-encodings/test.ml b/ocaml/libs/xapi-stdext/lib/xapi-stdext-encodings/test.ml index e94825accae..9cc75b297d0 100644 --- a/ocaml/libs/xapi-stdext/lib/xapi-stdext-encodings/test.ml +++ b/ocaml/libs/xapi-stdext/lib/xapi-stdext-encodings/test.ml @@ -21,13 +21,6 @@ let ( --- ), ( +++ ), ( <<< ) = (Int.sub, Int.add, Int.shift_left) (** Simulates a decoding error. *) exception Decode_error -(* === Mock types ===========================================================*) - -(** Generates mock character widths, in bytes. *) -module type WIDTH_GENERATOR = sig - val next : unit -> int -end - (* === Mock UCS validators ================================================= *) (** A validator that always succeeds. *) @@ -59,8 +52,6 @@ let assert_true = Alcotest.(check bool) "true" true let assert_false = Alcotest.(check bool) "false" false -let check_indices = Alcotest.(check (list int)) "indices" - let assert_raises_match exception_match fn = try fn () ; @@ -429,71 +420,6 @@ module UTF8_codec = struct ) valid_ucs_value_widths - (** A list of valid header byte decodings, represented by - tuples of the form (b, (v, w)), where: - b = a valid header byte; - v = the (partial) value contained within the byte; and - w = the total width of the encoded character, in bytes. *) - let valid_header_byte_decodings = - [ - (0b00000000, (0b00000000, 1)) - ; (0b00000001, (0b00000001, 1)) - ; (0b01111111, (0b01111111, 1)) - ; (0b11000000, (0b00000000, 2)) - ; (0b11000001, (0b00000001, 2)) - ; (0b11011111, (0b00011111, 2)) - ; (0b11100000, (0b00000000, 3)) - ; (0b11100001, (0b00000001, 3)) - ; (0b11101111, (0b00001111, 3)) - ; (0b11110000, (0b00000000, 4)) - ; (0b11110001, (0b00000001, 4)) - ; (0b11110111, (0b00000111, 4)) - ] - - (** A list of invalid header bytes that should not be decodable. *) - let invalid_header_bytes = - [ - 0b10000000 - ; 0b10111111 - ; 0b11111000 - ; 0b11111011 - ; 0b11111100 - ; 0b11111101 - ; 0b11111110 - ; 0b11111111 - ] - - (** A list of valid continuation byte decodings, represented - by tuples of the form (b, v), where: - b = a valid continuation byte; and - v = the partial value contained within the byte. *) - let valid_continuation_byte_decodings = - [ - (0b10000000, 0b00000000) - ; (0b10000001, 0b00000001) - ; (0b10111110, 0b00111110) - ; (0b10111111, 0b00111111) - ] - - (** A list of invalid continuation bytes that should not be decodable. *) - let invalid_continuation_bytes = - [ - 0b00000000 - ; 0b01111111 - ; 0b11000000 - ; 0b11011111 - ; 0b11100000 - ; 0b11101111 - ; 0b11110000 - ; 0b11110111 - ; 0b11111000 - ; 0b11111011 - ; 0b11111100 - ; 0b11111101 - ; 0b11111111 - ; 0b11111110 - ] - (** A list of valid character decodings represented by tuples of the form (s, (v, w)), where: diff --git a/ocaml/message-switch/cli/main.ml b/ocaml/message-switch/cli/main.ml index 19324a5a25f..524c96c7dbe 100644 --- a/ocaml/message-switch/cli/main.ml +++ b/ocaml/message-switch/cli/main.ml @@ -36,8 +36,6 @@ module Common = struct type t = {verbose: bool; debug: bool; path: string} [@@deriving rpc] let make verbose debug path = {verbose; debug; path} - - let to_string x = Jsonrpc.to_string (rpc_of_t x) end let _common_options = "COMMON OPTIONS" diff --git a/ocaml/rrd2csv/src/rrd2csv.ml b/ocaml/rrd2csv/src/rrd2csv.ml index d910b495bd3..bc6022584bd 100644 --- a/ocaml/rrd2csv/src/rrd2csv.ml +++ b/ocaml/rrd2csv/src/rrd2csv.ml @@ -146,18 +146,6 @@ module Ds_selector = struct let empty = {cf= None; owner= None; uuid= ""; metric= ""; enabled= true} - let make ?cf ?owner ?(uuid = "") ?(enabled = true) metric = - {cf; owner; uuid; metric; enabled} - - let of_datasource ?(uuid = "") ?owner (ds : Data_source.t) = - { - empty with - owner - ; uuid - ; metric= ds.Data_source.name - ; enabled= ds.Data_source.enabled - } - let of_string str = let open Rrd in let splitted = Xstringext.String.split ':' str in @@ -284,9 +272,6 @@ module Ds_selector = struct in if escaped then escape_metric string_repr else string_repr - let to_metric ?(escaped = false) ds_s = - if escaped then escape_metric ds_s.metric else ds_s.metric - (* Returns true if d "passes" the filter f, i.e. if fields of d match the non-null fields of f *) let filter11 f d = @@ -493,23 +478,6 @@ module Xport = struct let filter_sources filter (update : t) = Ds_selector.filter filter update.header.entries - (* CSV converting operations *) - - let to_csv_headers (update : t) = - String.concat ", " (List.map Ds_selector.to_string update.header.entries) - - let to_csv (update : t) = - let last_update = List.hd update.data in - Xstringext.String.sub_to_end - (Array.fold_left - (fun acc v -> - let strv = Stdout.string_of_float v in - acc ^ ", " ^ strv - ) - "" last_update.values - ) - 2 - (* Association list operations *) module Assoc_list = struct diff --git a/ocaml/squeezed/src/squeezed.ml b/ocaml/squeezed/src/squeezed.ml index d224a8eb8e0..35a6039341a 100644 --- a/ocaml/squeezed/src/squeezed.ml +++ b/ocaml/squeezed/src/squeezed.ml @@ -17,8 +17,6 @@ module D = Debug.Make (struct let name = Memory_interface.service_name end) open D -let name = "squeezed" - let balance_check_interval = ref 10. let options = diff --git a/ocaml/tests/test_pusb.ml b/ocaml/tests/test_pusb.ml index 2973a51ed9f..52df66a9fb5 100644 --- a/ocaml/tests/test_pusb.ml +++ b/ocaml/tests/test_pusb.ml @@ -12,11 +12,6 @@ * GNU Lesser General Public License for more details. *) -let create_base_environment () = - let __context = Test_common.make_test_database () in - let pusb = Test_common.make_sr ~__context () in - (__context, pusb) - let start_thread ~__context info = let usbs = Xapi_pusb_helpers.get_usbs info in let f () = Xapi_pusb.scan_start ~__context usbs in diff --git a/ocaml/tests/test_updateinfo.ml b/ocaml/tests/test_updateinfo.ml index def4fe0f65e..2adb7c9d2db 100644 --- a/ocaml/tests/test_updateinfo.ml +++ b/ocaml/tests/test_updateinfo.ml @@ -13,19 +13,8 @@ *) open Test_highlevel -open Rpm open Updateinfo -let fields_of_pkg = - Fmt.Dump. - [ - field "name" (fun (r : Pkg.t) -> r.name) string - ; field "epoch" (fun (r : Pkg.t) -> Epoch.to_string r.epoch) string - ; field "version" (fun (r : Pkg.t) -> r.version) string - ; field "release" (fun (r : Pkg.t) -> r.release) string - ; field "arch" (fun (r : Pkg.t) -> r.arch) string - ] - module ApplicabilityEval = Generic.MakeStateless (struct module Io = struct (* ( (installed_epoch, installed_version, installed_release) * diff --git a/ocaml/vhd-tool/cli/sparse_dd.ml b/ocaml/vhd-tool/cli/sparse_dd.ml index c7e034ef7b4..7502a541e37 100644 --- a/ocaml/vhd-tool/cli/sparse_dd.ml +++ b/ocaml/vhd-tool/cli/sparse_dd.ml @@ -5,8 +5,6 @@ module D = Debug.Make (struct let name = "sparse_dd" end) open D -let config_file = "/etc/sparse_dd.conf" - let vhd_search_path = "/dev/mapper" let ionice_cmd = "/usr/bin/ionice" @@ -55,8 +53,6 @@ let size = ref (-1L) let prezeroed = ref false -let set_machine_logging = ref false - let experimental_reads_bypass_tapdisk = ref false let experimental_writes_bypass_tapdisk = ref false @@ -164,33 +160,12 @@ let options = ) ] -let ( +* ) = Int64.add - -let ( -* ) = Int64.sub - -let ( ** ) = Int64.mul - -let kib = 1024L - -let mib = kib ** kib - let startswith prefix x = let prefix' = String.length prefix and x' = String.length x in prefix' <= x' && String.sub x 0 prefix' = prefix module Opt = struct let default d = function None -> d | Some x -> x end -module Mutex = struct - include Mutex - - let execute m f = - Mutex.lock m ; - try - let result = f () in - Mutex.unlock m ; result - with e -> Mutex.unlock m ; raise e -end - module Progress = struct let header = Cstruct.create Chunked.sizeof @@ -265,17 +240,6 @@ let with_paused_tapdisk path f = | _, _, _ -> failwith (Printf.sprintf "Failed to pause tapdisk for %s" path) -let deref_symlinks path = - let rec inner seen_already path = - if List.mem path seen_already then failwith "Circular symlink" ; - let stats = Unix.LargeFile.lstat path in - if stats.Unix.LargeFile.st_kind = Unix.S_LNK then - inner (path :: seen_already) (Unix.readlink path) - else - path - in - inner [] path - (* Record when the binary started for performance measuring *) let start = Unix.gettimeofday () diff --git a/ocaml/xapi-idl/misc/channel_helper.ml b/ocaml/xapi-idl/misc/channel_helper.ml index ee9c164f688..1485e6a5ead 100644 --- a/ocaml/xapi-idl/misc/channel_helper.ml +++ b/ocaml/xapi-idl/misc/channel_helper.ml @@ -8,8 +8,6 @@ exception Short_write of int * int exception End_of_file -exception No_useful_protocol - let copy_all src dst = let buffer = Bytes.make 16384 '\000' in let rec loop () = @@ -47,8 +45,6 @@ module Common = struct type t = {verbose: bool; debug: bool; port: int} [@@deriving rpc] let make verbose debug port = {verbose; debug; port} - - let to_string x = Jsonrpc.to_string (rpc_of_t x) end let _common_options = "COMMON OPTIONS" diff --git a/ocaml/xapi-storage-cli/main.ml b/ocaml/xapi-storage-cli/main.ml index 48c4531ea0c..9355cd5b4c3 100644 --- a/ocaml/xapi-storage-cli/main.ml +++ b/ocaml/xapi-storage-cli/main.ml @@ -18,8 +18,6 @@ open Storage_client let dbg = "sm-cli" -let s_of_sr = Storage_interface.Sr.string_of - let s_of_vdi = Storage_interface.Vdi.string_of let string_of_mirror id {Mirror.source_vdi; dest_vdi; state; failed} = @@ -56,8 +54,6 @@ module Common = struct Xcp_client.use_switch := true ) ; {verbose; debug; socket} - - let to_string x = Jsonrpc.to_string (rpc_of_t x) end let _common_options = "COMMON OPTIONS" diff --git a/ocaml/xe-cli/newcli.ml b/ocaml/xe-cli/newcli.ml index d197b849a94..fcb5c4272f8 100644 --- a/ocaml/xe-cli/newcli.ml +++ b/ocaml/xe-cli/newcli.ml @@ -381,16 +381,12 @@ let copy_with_heartbeat ?(block = 65536) in_ch out_ch heartbeat_fun = ) done -exception Http_failure - exception Connect_failure exception Protocol_version_mismatch of string exception ClientSideError of string -exception Stunnel_exit of int * Unix.process_status - exception Unexpected_msg of message exception Server_internal_error @@ -842,16 +838,6 @@ let main () = error "Unexpected message from server: %s" (string_of_message m) | Server_internal_error -> error "Server internal error.\n" - | Stunnel_exit (i, e) -> - error "Stunnel process %d %s.\n" i - ( match e with - | Unix.WEXITED c -> - "existed with exit code " ^ string_of_int c - | Unix.WSIGNALED c -> - "killed by signal " ^ Xapi_stdext_unix.Unixext.string_of_signal c - | Unix.WSTOPPED c -> - "stopped by signal " ^ string_of_int c - ) | Filename_not_permitted e -> error "File not permitted: %s.\n" e | ClientSideError e -> diff --git a/ocaml/xen-api-client/async_examples/event_test.ml b/ocaml/xen-api-client/async_examples/event_test.ml index 7489fd7ac7e..18b6c5a319d 100644 --- a/ocaml/xen-api-client/async_examples/event_test.ml +++ b/ocaml/xen-api-client/async_examples/event_test.ml @@ -36,12 +36,6 @@ let error fmt = Printf.ksprintf (fun txt -> eprintf "Error: %s\n%!" txt) fmt let info fmt = Printf.ksprintf (fun txt -> eprintf "%s\n%!" txt) fmt -let exn_to_string = function - | Api_errors.Server_error (code, params) -> - Printf.sprintf "%s %s" code (String.concat ~sep:" " params) - | e -> - failwith (Printf.sprintf "Unexpected error: %s" (Exn.to_string e)) - let watch_events rpc session_id = let open Event_types in let module StringMap = Map.Make (String) in diff --git a/ocaml/xen-api-client/async_examples/list_vms.ml b/ocaml/xen-api-client/async_examples/list_vms.ml index 47a692e33f9..6aac0feb527 100644 --- a/ocaml/xen-api-client/async_examples/list_vms.ml +++ b/ocaml/xen-api-client/async_examples/list_vms.ml @@ -22,12 +22,6 @@ let username = ref "root" let password = ref "password" -let exn_to_string = function - | Api_errors.Server_error (code, params) -> - Printf.sprintf "%s %s" code (String.concat ~sep:" " params) - | e -> - failwith (Printf.sprintf "Unhandled exception: %s" (Exn.to_string e)) - let main () = let rpc = make !uri in Session.login_with_password ~rpc ~uname:!username ~pwd:!password diff --git a/ocaml/xen-api-client/lib_test/xen_api_test.ml b/ocaml/xen-api-client/lib_test/xen_api_test.ml index 16d4c36128e..0e7a8a9d753 100644 --- a/ocaml/xen-api-client/lib_test/xen_api_test.ml +++ b/ocaml/xen-api-client/lib_test/xen_api_test.ml @@ -13,11 +13,6 @@ *) open OUnit - -let ( |> ) a b = b a - -let id x = x - open Xen_api module Fake_IO = struct @@ -27,14 +22,6 @@ module Fake_IO = struct let ( >>= ) t f = match t with T x -> f x - let ( >> ) m n = m >>= fun _ -> n - - let rec iter f = function - | [] -> - return () - | x :: xs -> - f x >>= fun () -> iter f xs - type ic = string Queue.t type oc = string Queue.t @@ -56,24 +43,6 @@ module Fake_IO = struct assert (String.length chunk <= n) ; return chunk - let read_exactly ic buf off len = - return - ( if Queue.is_empty ic then - false - else - let chunk = Queue.pop ic in - String.blit chunk 0 buf off len ; - true - ) - - let read_exactly ic len = - let buf = Bytes.create len in - read_exactly ic buf 0 len >>= function - | true -> - return (Some buf) - | false -> - return None - let write oc string = Queue.push string oc ; return () let flush _oc = return () diff --git a/ocaml/xen-api-client/lwt_examples/list_vms.ml b/ocaml/xen-api-client/lwt_examples/list_vms.ml index 1e5bb7e83a6..ad2118b336f 100644 --- a/ocaml/xen-api-client/lwt_examples/list_vms.ml +++ b/ocaml/xen-api-client/lwt_examples/list_vms.ml @@ -21,14 +21,6 @@ let username = ref "root" let password = ref "password" -let json = ref false - -let exn_to_string = function - | Api_errors.Server_error (code, params) -> - Printf.sprintf "%s %s" code (String.concat " " params) - | e -> - Printexc.to_string e - let main () = Lwt_switch.with_switch @@ fun switch -> let t = diff --git a/ocaml/xen-api-client/lwt_examples/upload_disk.ml b/ocaml/xen-api-client/lwt_examples/upload_disk.ml index 2ccb62d8eef..bc03834131f 100644 --- a/ocaml/xen-api-client/lwt_examples/upload_disk.ml +++ b/ocaml/xen-api-client/lwt_examples/upload_disk.ml @@ -24,12 +24,6 @@ let username = ref "root" let password = ref "password" -let exn_to_string = function - | Api_errors.Server_error (code, params) -> - Printf.sprintf "%s %s" code (String.concat " " params) - | e -> - Printexc.to_string e - let main filename = Lwt_unix.LargeFile.stat filename >>= fun stats -> let virtual_size = stats.Lwt_unix.LargeFile.st_size in diff --git a/ocaml/xen-api-client/lwt_examples/watch_metrics.ml b/ocaml/xen-api-client/lwt_examples/watch_metrics.ml index 11e5dea3b48..5f11aa415e0 100644 --- a/ocaml/xen-api-client/lwt_examples/watch_metrics.ml +++ b/ocaml/xen-api-client/lwt_examples/watch_metrics.ml @@ -25,12 +25,6 @@ let start = ref 0 let interval = ref 5 -let exn_to_string = function - | Api_errors.Server_error (code, params) -> - Printf.sprintf "%s %s" code (String.concat " " params) - | e -> - Printexc.to_string e - let main () = Lwt_switch.with_switch @@ fun switch -> let t = diff --git a/ocaml/xenopsd/dbgring/dbgring.ml b/ocaml/xenopsd/dbgring/dbgring.ml index 327463e3933..0891fbed308 100644 --- a/ocaml/xenopsd/dbgring/dbgring.ml +++ b/ocaml/xenopsd/dbgring/dbgring.ml @@ -13,8 +13,6 @@ *) open Xenops_utils -let xenstored_proc_port = "/proc/xen/xsd_port" - let xenstored_proc_kva = "/proc/xen/xsd_kva" let open_ring0 () = diff --git a/ocaml/xenopsd/test/test.ml b/ocaml/xenopsd/test/test.ml index 3fd5d661998..5714d897903 100644 --- a/ocaml/xenopsd/test/test.ml +++ b/ocaml/xenopsd/test/test.ml @@ -13,8 +13,6 @@ *) (** @group Storage *) -let default_path = "/var/xapi/xenopsd" - open Xenops_interface open Xenops_utils @@ -22,11 +20,6 @@ module Client = Xenops_interface.XenopsAPI (Idl.Exn.GenClient (struct let rpc = Xenopsd.rpc_fn end)) -let usage_and_exit () = - Printf.fprintf stderr "Usage:\n" ; - Printf.fprintf stderr " %s" Sys.argv.(0) ; - exit 1 - let dbg = "test" let finally = Xapi_stdext_pervasives.Pervasiveext.finally @@ -45,9 +38,6 @@ let fail_running f = (function Bad_power_state (Running, Halted) -> true | _ -> false) f -let fail_not_built f = - expect_exception (function Domain_not_built -> true | _ -> false) f - let fail_connected f = expect_exception (function Device_is_connected -> true | _ -> false) f @@ -509,10 +499,7 @@ let vm_test_start_shutdown _ = ) let vm_test_parallel_start_shutdown _ = - let rec ints start finish = - if start > finish then [] else start :: ints (start + 1) finish - in - let ints = ints 0 1000 |> List.map string_of_int in + let ints = List.init (1000 + 1) string_of_int in let t = Unix.gettimeofday () in let ids = List.map @@ -527,14 +514,7 @@ let vm_test_parallel_start_shutdown _ = flush stderr ) ; let t = Unix.gettimeofday () in - let tasks = - List.map - (fun id -> - let id = Client.VM.start dbg id false in - (* Printf.fprintf stderr "%s\n" id; flush stderr; *) id - ) - ids - in + let tasks = List.map (fun id -> Client.VM.start dbg id false) ids in wait_for_tasks tasks ; if !verbose_timings then ( Printf.fprintf stderr "Cleaning up tasks\n" ; @@ -1005,10 +985,11 @@ let _ = ; ("vm_test_add_list_remove", `Quick, vm_test_add_list_remove) ; ("vm_remove_running", `Quick, vm_remove_running) ; ("vm_test_start_shutdown", `Quick, vm_test_start_shutdown) - ; (* This unit test seems to be non-deterministic, sometimes fails to find tasks - * "vm_test_parallel_start_shutdown" , `Quick, vm_test_parallel_start_shutdown; - * *) - ("vm_test_consoles", `Quick, vm_test_consoles) + ; ( "vm_test_parallel_start_shutdown" + , `Slow + , vm_test_parallel_start_shutdown + ) + ; ("vm_test_consoles", `Quick, vm_test_consoles) ; ("vm_test_reboot", `Quick, vm_test_reboot) ; ("vm_test_halt", `Quick, vm_test_halt) ; ("vbd_test_add_remove", `Quick, VbdDeviceTests.add_remove) diff --git a/ocaml/xenopsd/xc/memory_breakdown.ml b/ocaml/xenopsd/xc/memory_breakdown.ml index f13d76d41c8..52428518dab 100644 --- a/ocaml/xenopsd/xc/memory_breakdown.ml +++ b/ocaml/xenopsd/xc/memory_breakdown.ml @@ -47,10 +47,6 @@ let cli_arguments_named = let cli_arguments_extra x = Printf.fprintf stderr "Ignoring argument: %s" x -(** {2 Helper functions} *) - -let flip f x y = f y x - (** Merges two sorted lists into a single sorted list that contains the union of all elements found in both lists. *) let merge xs ys = diff --git a/quality-gate.sh b/quality-gate.sh index ed71cb794da..c723676d1a5 100755 --- a/quality-gate.sh +++ b/quality-gate.sh @@ -3,7 +3,7 @@ set -e list-hd () { - N=314 + N=313 LIST_HD=$(git grep -r --count 'List.hd' -- **/*.ml | cut -d ':' -f 2 | paste -sd+ - | bc) if [ "$LIST_HD" -eq "$N" ]; then echo "OK counted $LIST_HD List.hd usages" diff --git a/rrdd-plugin.opam b/rrdd-plugin.opam index 0c1c31907bb..6bab281c970 100644 --- a/rrdd-plugin.opam +++ b/rrdd-plugin.opam @@ -9,20 +9,22 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" "astring" "rpclib" - "xapi-forkexecd" {version} - "xapi-stdext-pervasives" {version} - "xapi-stdext-std" {version} - "xapi-stdext-threads" {version} - "xapi-stdext-unix" {version} - "xapi-idl" {version} + "rrd-transport" {= version} + "xapi-forkexecd" {= version} + "xapi-stdext-pervasives" {= version} + "xapi-stdext-std" {= version} + "xapi-stdext-threads" {= version} + "xapi-stdext-unix" {= version} + "xapi-idl" {= version} "xenstore_transport" + "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-rrd-transport-utils.opam b/xapi-rrd-transport-utils.opam index 1f4083d7195..261da91a4e3 100644 --- a/xapi-rrd-transport-utils.opam +++ b/xapi-rrd-transport-utils.opam @@ -9,12 +9,16 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" "cmdliner" + "rrd-transport" {= version} + "xapi-idl" {= version} + "xapi-rrd" {= version} + "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-rrdd-plugin.opam b/xapi-rrdd-plugin.opam index 68a9ed509c5..b01d85a6da5 100644 --- a/xapi-rrdd-plugin.opam +++ b/xapi-rrdd-plugin.opam @@ -1,7 +1,7 @@ # This file is generated by dune, edit dune-project instead license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-rrdd.opam b/xapi-rrdd.opam index 4a798154dfa..824e9d725be 100644 --- a/xapi-rrdd.opam +++ b/xapi-rrdd.opam @@ -9,27 +9,29 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" {>= "4.02.0"} "dune-build-info" "astring" - "gzip" {version} - "http-lib" {version} + "gzip" {= version} + "http-lib" {= version} "inotify" "io-page" "mtime" "ppx_deriving_rpc" "rpclib" "systemd" - "ezxenstore" {version} - "uuid" {version} - "xapi-backtrace" {version} - "xapi-idl" {version} - "xapi-rrd" {version} - "xapi-stdext-threads" {version} + "ezxenstore" {= version} + "uuid" {= version} + "xapi-backtrace" + "xapi-idl" {= version} + "xapi-rrd" {= version} + "xapi-stdext-threads" {= version} + "xapi-stdext-unix" {= version} + "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-stdext-date.opam b/xapi-stdext-date.opam index a7f4951d856..10658f8b54e 100644 --- a/xapi-stdext-date.opam +++ b/xapi-stdext-date.opam @@ -7,7 +7,7 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" {>= "4.12"} "alcotest" {with-test} "astring" @@ -16,7 +16,7 @@ depends: [ "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-stdext-encodings.opam b/xapi-stdext-encodings.opam index c3538116761..51ef29fe35f 100644 --- a/xapi-stdext-encodings.opam +++ b/xapi-stdext-encodings.opam @@ -7,7 +7,7 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" {>= "4.13.0"} "alcotest" {>= "0.6.0" & with-test} "odoc" {with-doc} @@ -16,7 +16,7 @@ depends: [ "notty" {with-test} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-stdext-pervasives.opam b/xapi-stdext-pervasives.opam index 53fd4b34939..3dc2d169718 100644 --- a/xapi-stdext-pervasives.opam +++ b/xapi-stdext-pervasives.opam @@ -7,14 +7,14 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" {>= "4.08"} "logs" "odoc" {with-doc} "xapi-backtrace" ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-stdext-std.opam b/xapi-stdext-std.opam index 95b61c73e3e..4cee75aac36 100644 --- a/xapi-stdext-std.opam +++ b/xapi-stdext-std.opam @@ -7,13 +7,13 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" {>= "4.08.0"} "alcotest" {with-test} "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-stdext-threads.opam b/xapi-stdext-threads.opam index 9dcc9ff090c..714a2e01575 100644 --- a/xapi-stdext-threads.opam +++ b/xapi-stdext-threads.opam @@ -7,7 +7,7 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" "base-threads" "base-unix" @@ -15,7 +15,7 @@ depends: [ "xapi-stdext-pervasives" {= version} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-stdext-unix.opam b/xapi-stdext-unix.opam index f8e709afe7f..1d46f3ad75c 100644 --- a/xapi-stdext-unix.opam +++ b/xapi-stdext-unix.opam @@ -7,7 +7,7 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" {>= "4.12.0"} "base-unix" "fd-send-recv" {>= "2.0.0"} @@ -16,7 +16,7 @@ depends: [ "xapi-stdext-pervasives" {= version} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-stdext-zerocheck.opam b/xapi-stdext-zerocheck.opam index 30861bf3dc1..8f070a416f3 100644 --- a/xapi-stdext-zerocheck.opam +++ b/xapi-stdext-zerocheck.opam @@ -7,12 +7,12 @@ license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ - "dune" {>= "2.0"} + "dune" {>= "3.0"} "ocaml" "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-tracing-export.opam b/xapi-tracing-export.opam index 811f174eee9..4ec270f6328 100644 --- a/xapi-tracing-export.opam +++ b/xapi-tracing-export.opam @@ -11,18 +11,20 @@ bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ "ocaml" "cohttp-posix" - "dune" + "dune" {>= "3.0"} "cohttp" "rpclib" - "xapi-log" {version} - "xapi-open-uri" {version} - "xapi-stdext-threads" {version} - "xapi-stdext-unix" {version} - "xapi-tracing" {version} - "zstd" {version} + "ppx_deriving_rpc" + "xapi-log" {= version} + "xapi-open-uri" {= version} + "xapi-stdext-threads" {= version} + "xapi-stdext-unix" {= version} + "xapi-tracing" {= version} + "zstd" {= version} + "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/xapi-tracing.opam b/xapi-tracing.opam index 389b4ed3089..f2dbbd2b132 100644 --- a/xapi-tracing.opam +++ b/xapi-tracing.opam @@ -10,16 +10,17 @@ homepage: "https://xapi-project.github.io/" bug-reports: "https://github.com/xapi-project/xen-api/issues" depends: [ "ocaml" - "dune" + "dune" {>= "3.0"} "alcotest" {with-test} "re" "uri" "uuid" {with-test} - "xapi-log" {version} - "xapi-stdext-threads" {version} + "xapi-log" {= version} + "xapi-stdext-threads" {= version} + "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build"