Skip to content

Commit 7582389

Browse files
committed
maintenance: format comments with ocamlformat
This is done after adding wrap-comments=true in .ocamlformat Signed-off-by: Pau Ruiz Safont <[email protected]>
1 parent 497dfae commit 7582389

File tree

10 files changed

+109
-89
lines changed

10 files changed

+109
-89
lines changed

lib/jsonrpc_client.ml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ let timeout_read fd timeout =
4949
| Unix.Unix_error (Unix.EINTR, _, _) ->
5050
([], [], [])
5151
in
52-
(* This is not accurate the calculate time just for the select part. However, we
53-
* think the read time will be minor comparing to the scale of tens of seconds.
54-
* the current style will be much concise in code. *)
52+
(* This is not accurate the calculate time just for the select part.
53+
However, we think the read time will be minor comparing to the scale of
54+
tens of seconds. the current style will be much concise in code. *)
5555
let remain_time =
5656
let used_time = get_total_used_time () in
5757
Int64.sub timeout used_time
@@ -84,8 +84,10 @@ let timeout_read fd timeout =
8484
in
8585
inner timeout !json_rpc_max_len
8686

87-
(* Write as many bytes to a file descriptor as possible from data before a given clock time. *)
88-
(* Raises Timeout exception if the number of bytes written is less than the specified length. *)
87+
(* Write as many bytes to a file descriptor as possible from data before a given
88+
clock time. *)
89+
(* Raises Timeout exception if the number of bytes written is less than the
90+
specified length. *)
8991
(* Writes into the file descriptor at the current cursor position. *)
9092
let timeout_write filedesc total_length data response_time =
9193
let write_start = Mtime_clock.counter () in

lib/jsonrpc_client.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ val with_rpc :
3030
-> call:Rpc.call
3131
-> unit
3232
-> Rpc.response
33-
(** Do an JSON-RPC call to a server that is listening on a Unix domain
34-
* socket at the given path. *)
33+
(** Do an JSON-RPC call to a server that is listening on a Unix domain socket at
34+
the given path. *)

lib/network_config.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ let write_config config =
178178
(Printexc.get_backtrace ()) ;
179179
raise Write_error
180180

181-
(* Porting network interaface to ppx: convert ipv4_routes from (string * int * string) list to {gateway:string; netmask:int; subnet:string} *)
181+
(* Porting network interaface to ppx: convert ipv4_routes from [(string * int *
182+
string) list] to [{gateway:string; netmask:int; subnet:string}] *)
182183
let convert_configuration cfg =
183184
let open Yojson.Safe in
184185
let convert_ipv4_routes cfg =

lib/network_utils.ml

Lines changed: 61 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ module Sysfs = struct
188188
try
189189
let devpath = getpath name "device" in
190190
let driver_link = Unix.readlink (devpath ^ "/driver") in
191-
(* filter out symlinks under device/driver which look like /../../../devices/xen-backend/vif- *)
191+
(* filter out symlinks under device/driver which look like
192+
/../../../devices/xen-backend/vif- *)
192193
not
193194
(List.mem "xen-backend"
194195
(Astring.String.cuts ~empty:false ~sep:"/" driver_link))
@@ -239,8 +240,8 @@ module Sysfs = struct
239240
Result.Error
240241
(Fail_to_get_driver_name, "Failed to get driver name for: " ^ dev)
241242

242-
(** Returns the features bitmap for the driver for [dev].
243-
* The features bitmap is a set of NETIF_F_ flags supported by its driver. *)
243+
(** Returns the features bitmap for the driver for [dev]. The features bitmap
244+
is a set of NETIF_F_ flags supported by its driver. *)
244245
let get_features dev =
245246
try Some (int_of_string (read_one_line (getpath dev "features")))
246247
with _ -> None
@@ -274,9 +275,11 @@ module Sysfs = struct
274275
let ifaces = list () in
275276
List.filter (fun name -> Sys.file_exists (getpath name "bridge")) ifaces
276277

277-
(** Returns (speed, duplex) for a given network interface: int megabits/s, Duplex.
278-
* The units of speed are specified in pif_record in xen-api/xapi/records.ml.
279-
* Note: these data are present in sysfs from kernel 2.6.33. *)
278+
(** Returns (speed, duplex) for a given network interface: int megabits/s,
279+
Duplex. The units of speed are specified in pif_record in
280+
xen-api/xapi/records.ml.
281+
282+
Note: these data are present in sysfs from kernel 2.6.33. *)
280283
let get_status name =
281284
let speed =
282285
getpath name "speed" |> fun p ->
@@ -653,7 +656,8 @@ module Ip = struct
653656
with _ ->
654657
Result.Error (Fail_to_set_vf_vlan, "Failed to set VF VLAN for: " ^ dev)
655658

656-
(* We know some NICs do not support config VF Rate, so will explicitly tell XAPI this error*)
659+
(* We know some NICs do not support config VF Rate, so will explicitly tell
660+
XAPI this error*)
657661
let set_vf_rate dev index rate =
658662
try
659663
debug "Setting VF rate for dev: %s, index: %d, rate: %d" dev index rate ;
@@ -670,9 +674,10 @@ module Linux_bonding = struct
670674
debug "Loading bonding driver" ;
671675
try
672676
ignore (call_script modprobe ["bonding"]) ;
673-
(* is_bond_device() uses the contents of sysfs_bonding_masters to work out which devices
674-
* have already been created. Unfortunately the driver creates "bond0" automatically at
675-
* modprobe init. Get rid of this now or our accounting will go wrong. *)
677+
(* is_bond_device() uses the contents of sysfs_bonding_masters to work out
678+
which devices have already been created. Unfortunately the driver
679+
creates "bond0" automatically at modprobe init. Get rid of this now or
680+
our accounting will go wrong. *)
676681
Sysfs.write_one_line bonding_masters "-bond0"
677682
with _ -> error "Failed to load bonding driver"
678683

@@ -822,8 +827,8 @@ module Linux_bonding = struct
822827
debug "Current bond properties: %s"
823828
(String.concat ", "
824829
(List.map (fun (k, v) -> k ^ "=" ^ v) current_props)) ;
825-
(* Find out which properties are known, but different from the current state,
826-
* and only continue if there is at least one of those. *)
830+
(* Find out which properties are known, but different from the current
831+
state, and only continue if there is at least one of those. *)
827832
let props_to_update =
828833
List.filter
829834
(fun (prop, value) ->
@@ -986,7 +991,8 @@ end = struct
986991
(* dhclient is not running, so we need to start it. *)
987992
ignore (start ~ipv6 interface options)
988993
else
989-
(* dhclient is running - if the config has changed, update the config file and restart. *)
994+
(* dhclient is running - if the config has changed, update the config file
995+
and restart. *)
990996
let current_conf = read_conf_file ~ipv6 interface in
991997
let new_conf = generate_conf ~ipv6 interface options in
992998
if current_conf <> Some new_conf then (
@@ -1251,13 +1257,13 @@ module Ovs = struct
12511257
with _ -> warn "Failed to set max-idle=%d on OVS" t
12521258

12531259
let handle_vlan_bug_workaround override bridge =
1254-
(* This is a list of drivers that do support VLAN tx or rx acceleration, but
1255-
* to which the VLAN bug workaround should not be applied. This could be
1256-
* because these are known-good drivers (that is, they do not have any of
1257-
* the bugs that the workaround avoids) or because the VLAN bug workaround
1258-
* will not work for them and may cause other problems.
1259-
*
1260-
* This is a very short list because few drivers have been tested. *)
1260+
(* This is a list of drivers that do support VLAN tx or rx acceleration,
1261+
but to which the VLAN bug workaround should not be applied. This could
1262+
be because these are known-good drivers (that is, they do not have any
1263+
of the bugs that the workaround avoids) or because the VLAN bug
1264+
workaround will not work for them and may cause other problems.
1265+
1266+
This is a very short list because few drivers have been tested. *)
12611267
let no_vlan_workaround_drivers = ["bonding"] in
12621268
let phy_interfaces =
12631269
try
@@ -1357,7 +1363,9 @@ module Ovs = struct
13571363
(fun vif -> Astring.String.is_prefix ~affix:"vif" vif)
13581364
bvifs
13591365
in
1360-
(* The vifs may be large. However considering current XS limit of 1000VM*7NIC/VM + 800VLANs, the buffer of CLI should be sufficient for lots of vifxxxx.xx *)
1366+
(* The vifs may be large. However considering current XS limit of
1367+
1000VM*7NIC/VM + 800VLANs, the buffer of CLI should be sufficient for
1368+
lots of vifxxxx.xx *)
13611369
fork_script !inject_igmp_query_script
13621370
([
13631371
"--no-check-snooping-toggle"
@@ -1493,14 +1501,16 @@ module Ovs = struct
14931501
let del_old_arg =
14941502
let real_bridge_exists () =
14951503
try
1496-
(* `ovs-vsctl br-to-parent <name>` returns <name> if <name> is a current "real" bridge *)
1504+
(* `ovs-vsctl br-to-parent <name>` returns <name> if <name> is a
1505+
current "real" bridge *)
14971506
vsctl ~log:false ["br-to-parent"; name] |> String.trim = name
14981507
with _ -> false
14991508
in
15001509
if vlan <> None && real_bridge_exists () then
1501-
(* This is to handle the case that a "real" bridge (not a "fake" VLAN bridge)
1502-
already exists, while we need to create a VLAN bridge with the same name.
1503-
The bridge will be destroyed and recreated, and the interfaces on it are put back. *)
1510+
(* This is to handle the case that a "real" bridge (not a "fake" VLAN
1511+
bridge) already exists, while we need to create a VLAN bridge with
1512+
the same name. The bridge will be destroyed and recreated, and the
1513+
interfaces on it are put back. *)
15041514
["--"; "--if-exists"; "del-br"; name]
15051515
else
15061516
[]
@@ -1882,19 +1892,19 @@ module Modprobe = struct
18821892
( Fail_to_write_modprobe_cfg
18831893
, "Failed to write modprobe configuration file for: " ^ driver )
18841894

1885-
(*
1886-
For a igb driver, the module config file will be at path `/etc/modprobe.d/igb.conf`
1887-
The module config file is like:
1888-
# VFs-param: max_vfs
1889-
# VFs-maxvfs-by-default: 7
1890-
# VFs-maxvfs-by-user:
1891-
options igb max_vfs=7,7
1892-
1893-
Example of calls:
1894-
"igb" -> "VFs-param" -> Some "max_vfs"
1895-
"igb" -> "VFs-maxvfs-by-default" -> Some "7"
1896-
"igb" -> "VFs-maxvfs-by-user" -> None
1897-
"igb" -> "Not existed comments" -> None
1895+
(* For a igb driver, the module config file will be at path
1896+
`/etc/modprobe.d/igb.conf`
1897+
1898+
The module config file is like:
1899+
# VFs-param: max_vfs
1900+
# VFs-maxvfs-by-default: 7
1901+
# VFs-maxvfs-by-user: options igb max_vfs=7,7
1902+
1903+
Example of calls:
1904+
"igb" -> "VFs-param" -> Some "max_vfs"
1905+
"igb" -> "VFs-maxvfs-by-default" -> Some "7"
1906+
"igb" -> "VFs-maxvfs-by-user" -> None
1907+
"igb" -> "Not existed comments" -> None
18981908
*)
18991909
let get_config_from_comments driver =
19001910
try
@@ -1917,11 +1927,12 @@ module Modprobe = struct
19171927
Some (String.trim k, String.trim v))
19181928
with _ -> []
19191929

1920-
(* this function not returning None means that the driver doesn't suppport sysfs.
1921-
If a driver doesn't support sysfs, then we add VF_param into its driver modprobe
1922-
configuration. Therefore, from XAPI's perspective, if Modprobe.get_vf_param is
1923-
not None, the driver definitely should use modprobe other than sysfs,
1924-
and if Modprobe.get_vf_param is None, we just simple try sysfs. *)
1930+
(* this function not returning None means that the driver doesn't suppport
1931+
sysfs. If a driver doesn't support sysfs, then we add VF_param into its
1932+
driver modprobe configuration. Therefore, from XAPI's perspective, if
1933+
Modprobe.get_vf_param is not None, the driver definitely should use
1934+
modprobe other than sysfs, and if Modprobe.get_vf_param is None, we just
1935+
simple try sysfs. *)
19251936
let get_vf_param config =
19261937
try Some (List.assoc "VFs-param" config) with _ -> None
19271938

@@ -1946,11 +1957,11 @@ module Modprobe = struct
19461957
let config_sriov driver vf_param maxvfs =
19471958
let open Rresult.R.Infix in
19481959
Modinfo.is_param_array driver vf_param >>= fun is_array ->
1949-
(* To enable SR-IOV via modprobe configuration, we first determine if the driver requires
1950-
in the configuration an array like `options igb max_vfs=7,7,7,7` or a single value
1951-
like `options igb max_vfs=7`. If an array is required, this repeat times equals to
1952-
the number of devices with the same driver.
1953-
*)
1960+
(* To enable SR-IOV via modprobe configuration, we first determine if the
1961+
driver requires in the configuration an array like `options igb
1962+
max_vfs=7,7,7,7` or a single value like `options igb max_vfs=7`. If an
1963+
array is required, this repeat times equals to the number of devices with
1964+
the same driver. *)
19541965
let repeat =
19551966
if is_array then Sysfs.get_dev_nums_with_same_driver driver else 1
19561967
in
@@ -1969,7 +1980,8 @@ module Modprobe = struct
19691980
let parse_single_line s =
19701981
let parse_driver_options s =
19711982
match Astring.String.cut ~sep:"=" s with
1972-
(* has SR-IOV configuration but the max_vfs is exactly what we want to set, so no changes and return s *)
1983+
(* has SR-IOV configuration but the max_vfs is exactly what we want to
1984+
set, so no changes and return s *)
19731985
| Some (k, v) when k = vf_param && v = option ->
19741986
has_probe_conf := true ;
19751987
s

networkd/network_monitor_thread.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ let get_link_stats () =
128128
in
129129
List.map (fun link -> (standardise_name (Link.get_name link), link)) links
130130
|> (* Only keep interfaces with prefixes on the whitelist, and exclude VLAN
131-
devices (ethx.y). *)
131+
devices (ethx.y). *)
132132
List.filter (fun (name, _) -> is_whitelisted name && not (is_vlan name))
133133
in
134134
let devs =
@@ -382,7 +382,7 @@ let rec ip_watcher () =
382382
&& not (Astring.String.is_infix ~affix:"inet6 fe80" line)
383383
then (
384384
(* Ignore changes for the next second, since they usually come in bursts,
385-
* and signal only once. *)
385+
* and signal only once. *)
386386
Thread.delay 1. ;
387387
clear_input readme ;
388388
signal_networking_change ()

networkd/network_server.ml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ module Sriov = struct
127127
debug "%s SR-IOV on a device: %s via modprobe" op dev ;
128128
(if enable then Modprobe.get_maxvfs driver config else Ok 0)
129129
>>= fun numvfs ->
130-
(* CA-287340: Even if the current numvfs equals to the target numvfs,
131-
it is still needed to update SR-IOV modprobe config file, as the
132-
SR-IOV enabing takes effect after reboot. For example, a user
133-
enables SR-IOV and disables it immediately without a reboot.*)
130+
(* CA-287340: Even if the current numvfs equals to the target numvfs, it
131+
is still needed to update SR-IOV modprobe config file, as the SR-IOV
132+
enabing takes effect after reboot. For example, a user enables SR-IOV
133+
and disables it immediately without a reboot.*)
134134
Modprobe.config_sriov driver vf_param numvfs >>= fun _ ->
135135
if numvfs = Sysfs.get_sriov_numvfs dev then
136136
Ok Modprobe_successful
@@ -184,9 +184,11 @@ module Sriov = struct
184184
(fun () -> Result.Ok ())
185185
mac
186186
>>= fun () ->
187-
(* In order to ensure the Networkd to be idempotent, configuring VF with no VLAN and rate
188-
have to reset vlan and rate, since the VF might have previous configuration. Refering to
189-
http://gittup.org/cgi-bin/man/man2html?ip-link+8, set VLAN and rate to 0 means to reset them *)
187+
(* In order to ensure the Networkd to be idempotent, configuring VF with no
188+
VLAN and rate have to reset vlan and rate, since the VF might have
189+
previous configuration. Refering to
190+
http://gittup.org/cgi-bin/man/man2html?ip-link+8, set VLAN and rate to 0
191+
means to reset them *)
190192
config_or_otherwise_reset (Ip.set_vf_vlan dev index)
191193
(fun () -> Ip.set_vf_vlan dev index 0)
192194
vlan
@@ -285,8 +287,8 @@ module Interface = struct
285287
ignore (Dhclient.stop name) ;
286288
Ip.flush_ip_addr name
287289
) ;
288-
(* the function is meant to be idempotent and we
289-
* want to avoid CA-239919 *)
290+
(* the function is meant to be idempotent and we want to avoid
291+
CA-239919 *)
290292
let cur_addrs = Ip.get_ipv4 name in
291293
let rm_addrs =
292294
Xapi_stdext_std.Listext.List.set_difference cur_addrs addrs
@@ -372,7 +374,8 @@ module Interface = struct
372374
Ip.flush_ip_addr ~ipv6:true name ;
373375
Ip.set_ipv6_link_local_addr name ;
374376
Sysctl.set_ipv6_autoconf name true
375-
(* Cannot link set down/up due to CA-89882 - IPv4 default route cleared *)
377+
(* Cannot link set down/up due to CA-89882 - IPv4 default route
378+
cleared *)
376379
| Static6 addrs ->
377380
if Dhclient.is_running ~ipv6:true name then
378381
ignore (Dhclient.stop ~ipv6:true name) ;
@@ -636,9 +639,11 @@ module Interface = struct
636639
) ) ->
637640
update_config name c ;
638641
exec (fun () ->
639-
(* We only apply the DNS settings when in static IPv4 mode to avoid conflicts with DHCP mode.
640-
* The `dns` field should really be an option type so that we don't have to derive the intention
641-
* of the caller by looking at other fields. *)
642+
(* We only apply the DNS settings when in static IPv4 mode
643+
to avoid conflicts with DHCP mode. * The `dns` field
644+
should really be an option type so that we don't have to
645+
derive the intention * of the caller by looking at other
646+
fields. *)
642647
match ipv4_conf with
643648
| Static4 _ ->
644649
set_dns () dbg ~name ~nameservers ~domains
@@ -899,8 +904,9 @@ module Bridge = struct
899904
(* Check if the VLAN is already in use by something else *)
900905
List.iter
901906
(fun (device, vlan', parent') ->
902-
(* A device for the same VLAN (parent + tag), but with a different
903-
* device name or not on the requested bridge is bad. *)
907+
(* A device for the same VLAN (parent + tag), but with a
908+
different * device name or not on the requested bridge is
909+
bad. *)
904910
if
905911
parent' = parent
906912
&& vlan' = vlan
@@ -910,7 +916,8 @@ module Bridge = struct
910916
then
911917
raise (Network_error (Vlan_in_use (parent, vlan))))
912918
(Proc.get_vlans ()) ;
913-
(* Robustness enhancement: ensure there are no other VLANs in the bridge *)
919+
(* Robustness enhancement: ensure there are no other VLANs in
920+
the bridge *)
914921
let current_interfaces =
915922
List.filter
916923
(fun n ->
@@ -1378,8 +1385,8 @@ let on_startup () =
13781385
(fun () ->
13791386
Bridge.determine_backend () ;
13801387
let remove_centos_config () =
1381-
(* Remove DNSDEV and GATEWAYDEV from Centos networking file, because the interfere
1382-
* with this daemon. *)
1388+
(* Remove DNSDEV and GATEWAYDEV from Centos networking file, because the
1389+
interfere * with this daemon. *)
13831390
try
13841391
let file =
13851392
String.trim

profiling/coverage.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
(** This module sets up the env variable for bisect_ppx which describes
2-
* where log files are written.
3-
*)
1+
(** This module sets up the env variable for bisect_ppx which describes where
2+
log files are written. *)
43

5-
(** [init name] sets up coverage profiling for binary [name]. You could
6-
* use [Sys.argv.(0)] for [name].
7-
*)
4+
(** [init name] sets up coverage profiling for binary [name]. You could use
5+
[Sys.argv.(0)] for [name]. *)
86

97
let init name =
108
let ( // ) = Filename.concat in

profiling/coverage.mli

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
(** [init name] sets up coverage profiling for binary [name]. You could
2-
* use [Sys.argv.(0) for name
3-
*)
1+
(** [init name] sets up coverage profiling for binary [name]. You could use
2+
[Sys.argv.(0) for name *)
43

54
val init : string -> unit

0 commit comments

Comments
 (0)