From fb388e3254af40d6c580f487418874596a4d673f Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Wed, 11 Oct 2023 12:34:08 +0100 Subject: [PATCH] maintenance: apply ocamlformat Signed-off-by: Pau Ruiz Safont --- lib/bootloader.ml | 2 +- lib/open_uri_https.ml | 35 ++++++++++++++++------------------- lib/xcp_client_https.ml | 22 +++++++++++++++------- xc/xenops_server_xen.ml | 4 ++-- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/lib/bootloader.ml b/lib/bootloader.ml index db87d6cea..8e4012a90 100644 --- a/lib/bootloader.ml +++ b/lib/bootloader.ml @@ -222,7 +222,7 @@ let sanity_check_path p = (** Extract the default kernel using the -q option *) let extract (task : Xenops_task.task_handle) ~bootloader ~disk ?(legacy_args = "") ?(extra_args = "") ?(pv_bootloader_args = "") - ~vm:vm_uuid ~domid:domid () = + ~vm:vm_uuid ~domid () = (* Without this path, pygrub will fail: *) Unixext.mkdir_rec "/var/run/xend/boot" 0o0755 ; let bootloader_path, cmdline = diff --git a/lib/open_uri_https.ml b/lib/open_uri_https.ml index 9662c6add..4903adb36 100644 --- a/lib/open_uri_https.ml +++ b/lib/open_uri_https.ml @@ -1,4 +1,3 @@ - (* This code is usually in xcp-idl but we introduced a local copy here to support https, which has a dependency on stunnel and would create a circular dependency. *) @@ -21,22 +20,22 @@ let with_open_uri uri f = ) ) | Some "https" -> ( - let process (s : Stunnel.t) = - finally - (fun () -> f Safe_resources.Unixfd.(!(s.Stunnel.fd))) - (fun () -> Stunnel.disconnect s) - in - match (Uri.host uri, Uri.port uri) with - | Some host, Some port -> - Stunnel.with_connect host port process - | Some host, None -> - Stunnel.with_connect host https_port process - | _, _ -> - failwith - (Printf.sprintf "Failed to parse host and port from URI: %s" - (Uri.to_string uri) - ) - ) + let process (s : Stunnel.t) = + finally + (fun () -> f Safe_resources.Unixfd.(!(s.Stunnel.fd))) + (fun () -> Stunnel.disconnect s) + in + match (Uri.host uri, Uri.port uri) with + | Some host, Some port -> + Stunnel.with_connect host port process + | Some host, None -> + Stunnel.with_connect host https_port process + | _, _ -> + failwith + (Printf.sprintf "Failed to parse host and port from URI: %s" + (Uri.to_string uri) + ) + ) | Some "file" -> let filename = Uri.path_and_query uri in let sockaddr = Unix.ADDR_UNIX filename in @@ -48,5 +47,3 @@ let with_open_uri uri f = failwith (Printf.sprintf "Unsupported URI scheme: %s" x) | None -> failwith (Printf.sprintf "Failed to parse URI: %s" (Uri.to_string uri)) - - diff --git a/lib/xcp_client_https.ml b/lib/xcp_client_https.ml index dadacd431..5e88c741c 100644 --- a/lib/xcp_client_https.ml +++ b/lib/xcp_client_https.ml @@ -42,7 +42,9 @@ let switch_rpc ?timeout queue_name string_of_call response_of_string = response_of_string (get_ok (Message_switch_unix.Protocol_unix.Client.rpc ~t ?timeout - ~queue:queue_name ~body:(string_of_call call) ())) + ~queue:queue_name ~body:(string_of_call call) () + ) + ) let split_colon str = try @@ -94,7 +96,8 @@ let http_rpc string_of_call response_of_string ?(srcstr = "unset") | `Invalid x -> failwith (Printf.sprintf "Failed to read HTTP response from: %s (got '%s')" - (url ()) x) + (url ()) x + ) | `Ok response -> ( let body = Buffer.create 16 in let reader = Response.make_body_reader response ic in @@ -115,8 +118,10 @@ let http_rpc string_of_call response_of_string ?(srcstr = "unset") | bad -> failwith (Printf.sprintf "Unexpected HTTP response code: %s" - (Cohttp.Code.string_of_status bad)) - )) + (Cohttp.Code.string_of_status bad) + ) + ) + ) let xml_http_rpc = http_rpc Xmlrpc.string_of_call Xmlrpc.response_of_string @@ -129,9 +134,11 @@ let () = | Xmlm.Error ((line, col), error) -> Some (Printf.sprintf "Xmlm.Error(%d:%d, \"%s\")" line col - (Xmlm.error_message error)) + (Xmlm.error_message error) + ) | _ -> - None) + None + ) (* Use a binary 16-byte length to frame RPC messages *) let binary_rpc string_of_call response_of_string ?(srcstr = "unset") @@ -153,7 +160,8 @@ let binary_rpc string_of_call response_of_string ?(srcstr = "unset") let (response : Rpc.response) = response_of_string (Bytes.unsafe_to_string msg_buf) in - response) + response + ) let json_binary_rpc = binary_rpc Jsonrpc.string_of_call Jsonrpc.response_of_string diff --git a/xc/xenops_server_xen.ml b/xc/xenops_server_xen.ml index faf8d78a6..991a6aed6 100644 --- a/xc/xenops_server_xen.ml +++ b/xc/xenops_server_xen.ml @@ -2106,7 +2106,7 @@ module VM = struct Bootloader.extract task ~bootloader:i.bootloader ~legacy_args:i.legacy_args ~extra_args:i.extra_args ~pv_bootloader_args:i.bootloader_args ~disk:dev - ~vm:vm.Vm.id ~domid:domid () + ~vm:vm.Vm.id ~domid () in kernel_to_cleanup := Some b ; let builder_spec_info = @@ -2150,7 +2150,7 @@ module VM = struct Bootloader.extract task ~bootloader:i.bootloader ~legacy_args:i.legacy_args ~extra_args:i.extra_args ~pv_bootloader_args:i.bootloader_args ~disk:dev - ~vm:vm.Vm.id ~domid:domid () + ~vm:vm.Vm.id ~domid () in kernel_to_cleanup := Some b ; let builder_spec_info =