Skip to content

Commit 20176ec

Browse files
authored
Merge pull request #151 from lindig/CP-27898
CP-27898 port to Dune, remove warnings, fix Travis
2 parents 1e2a06b + 2b5a029 commit 20176ec

File tree

20 files changed

+177
-290
lines changed

20 files changed

+177
-290
lines changed

.travis.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
language: c
2-
services: docker
3-
install:
4-
- wget https://raw.githubusercontent.com/xenserver/xenserver-build-env/master/utils/travis-build-repo.sh
5-
script: bash travis-build-repo.sh
6-
sudo: true
2+
sudo: required
3+
service: docker
4+
install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-docker.sh
5+
script: bash -ex .travis-docker.sh
76
env:
8-
global:
9-
- REPO_PACKAGE_NAME=xcp-networkd
10-
- REPO_CONFIGURE_CMD=true
11-
- REPO_BUILD_CMD=make
12-
- REPO_TEST_CMD='make test'
7+
global:
8+
- PACKAGE="xapi-networkd"
9+
- PINS="xapi-networkd:."
10+
- BASE_REMOTE="https://github.com/xapi-project/xs-opam.git"
11+
matrix:
12+
- DISTRO="debian-9-ocaml-4.06"

COVERAGE.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

ChangeLog

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
0.39.0 (04-Dec-2018)
2+
* This file in no longer maintained. See the Git history'
3+
14
0.10.0 (14-Aug-2015):
25
* Preliminary support for FCoE
36
* Support xapi `originator`
@@ -15,7 +18,7 @@
1518
0.9.4 (3-Jun-2014):
1619
* Use oasis for building
1720
* Update to new stdext interface
18-
* Fix CA-118425/SCTX-1559: An earlier error could cause problems with VLANs
21+
* Fix CA-118425/SCTX-1559: An earlier error could cause problems with VLANs
1922
* Enable LACP bonding on linux bridge
2023
* Fix CA-116420: Bonds were getting incorrect MAC addresses on 3.x kernels
2124
* Fix CA-120846: Finding MAC addresses for bonds

INSTALL

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,6 @@
33

44
The easiest way to install is via opam:
55

6-
opam init
7-
opam remote add xen-org git://github.com/xen-org/opam-repo-dev
8-
opam install xcp-networkd
9-
10-
# Coverage Profiling
11-
12-
This code can be instrumented for coverage profiling:
13-
14-
make coverage
15-
make
16-
17-
See [COVERAGE.md](./COVERAGE.md) for details and
18-
[profiling/](./profiling/) for supporting code.
19-
6+
opam repo add xs-opam https://github.com/xapi-project/xs-opam.git
7+
opam pin add .
208

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
BINDIR ?= /usr/bin
22
SBINDIR ?= /usr/sbin
33
MANDIR ?= /usr/share/man/man1
4+
PROFILE=release
5+
46

57
.PHONY: release build install uninstall clean test doc reindent
68

79
release:
8-
dune build @install @networkd/man --profile=release
10+
dune build @install @networkd/man --profile=$(PROFILE)
911

1012
build:
1113
dune build @install @networkd/man
@@ -27,11 +29,16 @@ clean:
2729
dune clean
2830

2931
test:
30-
dune runtest --profile=release
32+
dune runtest --profile=$(PROFILE)
33+
34+
gprof:
35+
dune runtest --profile=gprof
36+
@echo "To view results, run:"
37+
@echo "gprof _build/default/test/network_test.exe _build/default/gmon.out"
3138

3239
# requires odoc
3340
doc:
34-
dune build @doc --profile=release
41+
dune build @doc --profile=$(PROFILE)
3542

3643
reindent:
3744
ocp-indent --inplace **/*.ml*

dune

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(env
2+
(gprof
3+
(ocamlopt_flags
4+
(:standard -g -p)
5+
)
6+
(flags (:standard))
7+
)
8+
(dev
9+
(flags (:standard))
10+
)
11+
(release
12+
(flags (:standard))
13+
)
14+
)

lib/dune

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
(library
2-
(name networklibs)
3-
(flags (:standard :standard -bin-annot -safe-string))
4-
(libraries
5-
astring
6-
forkexec
7-
mtime
8-
mtime.clock.os
9-
rpclib
10-
systemd
11-
threads
12-
re.perl
13-
xapi-stdext-unix
14-
xapi-inventory
15-
xapi-idl.network
16-
)
17-
(wrapped false)
2+
(name networklibs)
3+
(libraries
4+
astring
5+
forkexec
6+
mtime
7+
mtime.clock.os
8+
rpclib
9+
systemd
10+
threads
11+
re.perl
12+
xapi-stdext-unix
13+
xapi-inventory
14+
xapi-idl.network)
15+
(wrapped false)
1816
)

lib/jsonrpc_client.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ val json_rpc_read_timeout : int64 ref
2020
val json_rpc_write_timeout : int64 ref
2121

2222
val timeout_read : Unix.file_descr -> int64 -> string
23+
2324
(** Do an JSON-RPC call to a server that is listening on a Unix domain
2425
* socket at the given path. *)
2526
val with_rpc : ?version:Jsonrpc.version -> path:string -> call:Rpc.call -> unit -> Rpc.response

lib/network_config.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let read_management_conf () =
6565
bridge
6666
in
6767
let mac = Network_utils.Ip.get_mac device in
68-
let ipv4_conf, ipv4_gateway, dns =
68+
let ipv4_conf, ipv4_gateway, _dns =
6969
match List.assoc "MODE" args with
7070
| "static" ->
7171
let ip = List.assoc "IP" args |> Unix.inet_addr_of_string in

lib/network_utils.ml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
open Xapi_stdext_pervasives
1616
open Xapi_stdext_unix
17-
open Xapi_stdext_std
1817
open Network_interface
1918

2019
module D = Debug.Make(struct let name = "network_utils" end)
@@ -93,7 +92,7 @@ let check_n_run ?(on_error=default_error_handler) ?(log=true) run_func script ar
9392

9493
let call_script ?(timeout=Some 60.0) ?on_error ?log script args =
9594
let call_script_internal env script args =
96-
let (out,err) = Forkhelpers.execute_command_get_output ~env ?timeout script args in
95+
let (out,_err) = Forkhelpers.execute_command_get_output ~env ?timeout script args in
9796
out
9897
in
9998
check_n_run ?on_error ?log call_script_internal script args
@@ -155,7 +154,7 @@ module Sysfs = struct
155154
try
156155
output_string outchan (l ^ "\n");
157156
close_out outchan
158-
with exn -> close_out outchan; raise (Network_error (Write_error file))
157+
with _ -> close_out outchan; raise (Network_error (Write_error file))
159158

160159
let is_physical name =
161160
try
@@ -175,7 +174,7 @@ module Sysfs = struct
175174
try
176175
let devpath = Unix.readlink (getpath name "device") in
177176
List.hd (List.rev (Astring.String.cuts ~empty:false ~sep:"/" devpath))
178-
with exn -> "N/A"
177+
with _ -> "N/A"
179178

180179
let get_pci_ids name =
181180
let read_id_from path =
@@ -193,7 +192,7 @@ module Sysfs = struct
193192
try
194193
let driver_path = Unix.readlink (getpath dev "device/driver") in
195194
match Astring.String.cut ~sep:"/" ~rev:true driver_path with
196-
| Some (prefix, suffix) -> Some suffix
195+
| Some (_prefix, suffix) -> Some suffix
197196
| None ->
198197
debug "get %s driver name: %s does not contain slash" dev driver_path;
199198
None
@@ -417,11 +416,6 @@ module Ip = struct
417416
let get_mtu dev =
418417
int_of_string (List.hd (link dev "mtu"))
419418

420-
let get_state dev =
421-
match addr dev "state" with
422-
| "UP" :: _ -> true
423-
| _ -> false
424-
425419
let get_mac dev =
426420
List.hd (link dev "link/ether")
427421

@@ -748,7 +742,7 @@ module Dhclient = struct
748742
let ipv6' = if ipv6 then "6" else "" in
749743
Filename.concat "/var/lib/xcp" (Printf.sprintf "dhclient%s-%s.conf" ipv6' interface)
750744

751-
let generate_conf ?(ipv6=false) interface options =
745+
let[@warning "-27"] generate_conf ?(ipv6=false) interface options =
752746
let minimal = ["subnet-mask"; "broadcast-address"; "time-offset"; "host-name"; "nis-domain";
753747
"nis-servers"; "ntp-servers"; "interface-mtu"] in
754748
let set_gateway =
@@ -874,7 +868,7 @@ module Proc = struct
874868
loop None [] lines
875869
in
876870
check_lines lines
877-
with e ->
871+
with _ ->
878872
error "Error: could not read %s." (bonding_dir ^ name);
879873
[]
880874

@@ -894,14 +888,10 @@ module Proc = struct
894888
with _ ->
895889
vlans
896890
) [] "/proc/net/vlan/config"
897-
with e ->
891+
with _ ->
898892
error "Error: could not read /proc/net/vlan/config";
899893
[]
900894

901-
let get_bond_links_up name =
902-
let statusses = get_bond_slave_info name "MII Status" in
903-
List.fold_left (fun x (_, y) -> x + (if y = "up" then 1 else 0)) 0 statusses
904-
905895
let get_ipv6_disabled () =
906896
try
907897
Unixext.string_of_file "/proc/sys/net/ipv6/conf/all/disable_ipv6"
@@ -1002,7 +992,7 @@ module Ovs = struct
1002992

1003993
let get_real_bridge name =
1004994
match bridge_to_vlan name with
1005-
| Some (parent, vlan) -> parent
995+
| Some (parent, _vlan) -> parent
1006996
| None -> name
1007997

1008998
let get_bond_link_status name =
@@ -1026,11 +1016,6 @@ module Ovs = struct
10261016
) ([], None) lines
10271017
with _ -> [], None
10281018

1029-
let get_bond_links_up name =
1030-
let slaves, _ = get_bond_link_status name in
1031-
let links_up = List.filter snd slaves in
1032-
List.length (links_up)
1033-
10341019
let get_bond_mode name =
10351020
try
10361021
let output = String.trim (vsctl ~log:false ["get"; "port"; name; "bond_mode"]) in
@@ -1119,7 +1104,7 @@ module Ovs = struct
11191104

11201105
let inject_igmp_query ~name =
11211106
try
1122-
let vvifs = get_bridge_vlan_vifs name in
1107+
let vvifs = get_bridge_vlan_vifs ~name in
11231108
let bvifs = bridge_to_interfaces name in
11241109
let bvifs' = List.filter (fun vif -> Astring.String.is_prefix ~affix:"vif" vif) bvifs in
11251110
(* 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 *)
@@ -1210,9 +1195,6 @@ module Ovs = struct
12101195
let destroy_port name =
12111196
vsctl ["--"; "--with-iface"; "--if-exists"; "del-port"; name]
12121197

1213-
let port_to_bridge name =
1214-
vsctl ~log:false ["port-to-br"; name]
1215-
12161198
let make_bond_properties name properties =
12171199
let known_props = ["mode"; "hashing-algorithm"; "updelay"; "downdelay";
12181200
"miimon"; "use_carrier"; "rebalance-interval";
@@ -1422,7 +1404,7 @@ module Modprobe = struct
14221404
let get_config_from_comments driver =
14231405
try
14241406
let open Xapi_stdext_std.Listext in
1425-
Unixext.read_lines (getpath driver)
1407+
Unixext.read_lines ~path:(getpath driver)
14261408
|> List.filter_map (fun x ->
14271409
let line = String.trim x in
14281410
if not (Astring.String.is_prefix ~affix:("# ") line)
@@ -1501,7 +1483,7 @@ module Modprobe = struct
15011483
else
15021484
trimed_s
15031485
in
1504-
let lines = try Unixext.read_lines (getpath driver) with _ -> [] in
1486+
let lines = try Unixext.read_lines ~path:(getpath driver) with _ -> [] in
15051487
let new_conf = List.map parse_single_line lines in
15061488
match !has_probe_conf, !need_rebuild_initrd with
15071489
| true, true ->

0 commit comments

Comments
 (0)