Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide actual network interface name (regression in #1455) #1480

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 12 additions & 9 deletions lib/mirage/impl/mirage_impl_network.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ type network = NETWORK

let network = Type.v NETWORK
let all_networks = ref []
let add_new_network name = all_networks := name :: !all_networks

let add_new_network () =
let device = Fmt.str "net%d" (List.length !all_networks) in
all_networks := device :: !all_networks

let network_conf (intf : string runtime_key) =
let runtime_keys = [ Runtime_key.v intf ] in
let network_conf ?(intf : string runtime_key option) name =
let runtime_keys = Option.to_list (Option.map Runtime_key.v intf) in
let packages_v =
Key.match_ Key.(value target) @@ function
| `Unix -> [ package ~min:"3.0.0" ~max:"4.0.0" "mirage-net-unix" ]
Expand All @@ -27,15 +24,21 @@ let network_conf (intf : string runtime_key) =
[ package ~min:"0.8.0" ~max:"0.9.0" "mirage-net-solo5" ]
in
let connect _ modname _ =
Fmt.str "%s.connect %a" modname Runtime_key.call intf
let name =
Option.value ~default:(Printf.sprintf "%S" name)
(Option.map (Fmt.to_to_string Runtime_key.call) intf)
in
Fmt.str "%s.connect %s" modname name
in
let configure _ =
add_new_network ();
add_new_network name;
Action.ok ()
in
impl ~runtime_keys ~packages_v ~connect ~configure "Netif" network

let netif ?group dev = network_conf @@ Runtime_key.interface ?group dev
let netif ?group dev =
if_impl Key.is_solo5 (network_conf dev)
(network_conf ~intf:(Runtime_key.interface ?group dev) dev)

let default_network =
match_impl
Expand Down
238 changes: 139 additions & 99 deletions test/mirage/describe/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,56 @@ Describe before configure (no eval)
9 [label="mirage_crypto_rng_mirage_make__9\nMirage_crypto_rng_mirage.Make\n", shape="box"];
10 [label="netif__10\nNetif\n", shape="box"];
11 [label="netif__11\nNetif\n", shape="box"];
12 [label="netif__12\nNetif\n", shape="box"];
12 [label="If\ntarget"];
13 [label="netif__13\nNetif\n", shape="box"];
14 [label="netif__14\nNetif\n", shape="box"];
15 [label="netif__15\nNetif\n", shape="box"];
15 [label="If\ntarget"];
16 [label="netif__16\nNetif\n", shape="box"];
17 [label="netif__17\nNetif\n", shape="box"];
18 [label="If\ntarget"];
19 [label="ethernet_make__19\nEthernet.Make\n", shape="box"];
20 [label="ipv6_make__20\nIpv6.Make\n", shape="box"];
21 [label="arp_make__21\nArp.Make\n", shape="box"];
22 [label="qubes_db__22\nQubes.DB\n", shape="box"];
23 [label="qubesdb_ipv4_make__23\nQubesdb_ipv4.Make\n", shape="box"];
24 [label="dhcp_ipv4_make__24\nDhcp_ipv4.Make\n", shape="box"];
25 [label="static_ipv4_make__25\nStatic_ipv4.Make\n", shape="box"];
26 [label="If\ndhcp, net,\ntarget"];
27 [label="tcpip_stack_direct_ipv4v6__27\nTcpip_stack_direct.IPV4V6\n", shape="box"];
28 [label="tcp_flow_make__28\nTcp.Flow.Make\n", shape="box"];
29 [label="udp_make__29\nUdp.Make\n", shape="box"];
30 [label="icmpv4_make__30\nIcmpv4.Make\n", shape="box"];
31 [label="tcpip_stack_direct_makev4v6__31\nTcpip_stack_direct.MakeV4V6\n", shape="box"];
32 [label="If\ndhcp, net,\ntarget"];
33 [label="app__33\nApp\n", shape="box"];
34 [label="pclock__34\nPclock\n", shape="box"];
35 [label="mirage_logs_make__35\nMirage_logs.Make\n", shape="box"];
36 [label="mirage_runtime__36\nMirage_runtime\n", shape="box"];
37 [label="gc__37\nGc\n", shape="box"];
38 [label="hashtbl__38\nHashtbl\n", shape="box"];
39 [label="printexc__39\nPrintexc\n", shape="box"];
40 [label="bootvar__40\nBootvar\n", shape="box"];
41 [label="bootvar__41\nBootvar\n", shape="box"];
42 [label="bootvar__42\nBootvar\n", shape="box"];
43 [label="If\ntarget"];
44 [label="key_gen__44\nKey_gen\n", shape="box"];
45 [label="mirage_runtime__45\nMirage_runtime\ntarget", shape="box"];
19 [label="netif__19\nNetif\n", shape="box"];
20 [label="netif__20\nNetif\n", shape="box"];
21 [label="If\ntarget"];
22 [label="netif__22\nNetif\n", shape="box"];
23 [label="netif__23\nNetif\n", shape="box"];
24 [label="If\ntarget"];
25 [label="netif__25\nNetif\n", shape="box"];
26 [label="netif__26\nNetif\n", shape="box"];
27 [label="If\ntarget"];
28 [label="netif__28\nNetif\n", shape="box"];
29 [label="netif__29\nNetif\n", shape="box"];
30 [label="If\ntarget"];
31 [label="netif__31\nNetif\n", shape="box"];
32 [label="netif__32\nNetif\n", shape="box"];
33 [label="If\ntarget"];
34 [label="If\ntarget"];
35 [label="ethernet_make__35\nEthernet.Make\n", shape="box"];
36 [label="ipv6_make__36\nIpv6.Make\n", shape="box"];
37 [label="arp_make__37\nArp.Make\n", shape="box"];
38 [label="qubes_db__38\nQubes.DB\n", shape="box"];
39 [label="qubesdb_ipv4_make__39\nQubesdb_ipv4.Make\n", shape="box"];
40 [label="dhcp_ipv4_make__40\nDhcp_ipv4.Make\n", shape="box"];
41 [label="static_ipv4_make__41\nStatic_ipv4.Make\n", shape="box"];
42 [label="If\ndhcp, net,\ntarget"];
43 [label="tcpip_stack_direct_ipv4v6__43\nTcpip_stack_direct.IPV4V6\n", shape="box"];
44 [label="tcp_flow_make__44\nTcp.Flow.Make\n", shape="box"];
45 [label="udp_make__45\nUdp.Make\n", shape="box"];
46 [label="icmpv4_make__46\nIcmpv4.Make\n", shape="box"];
47 [label="tcpip_stack_direct_makev4v6__47\nTcpip_stack_direct.MakeV4V6\n", shape="box"];
48 [label="If\ndhcp, net,\ntarget"];
49 [label="app__49\nApp\n", shape="box"];
50 [label="pclock__50\nPclock\n", shape="box"];
51 [label="mirage_logs_make__51\nMirage_logs.Make\n", shape="box"];
52 [label="mirage_runtime__52\nMirage_runtime\n", shape="box"];
53 [label="gc__53\nGc\n", shape="box"];
54 [label="hashtbl__54\nHashtbl\n", shape="box"];
55 [label="printexc__55\nPrintexc\n", shape="box"];
56 [label="bootvar__56\nBootvar\n", shape="box"];
57 [label="bootvar__57\nBootvar\n", shape="box"];
58 [label="bootvar__58\nBootvar\n", shape="box"];
59 [label="If\ntarget"];
60 [label="key_gen__60\nKey_gen\n", shape="box"];
61 [label="mirage_runtime__61\nMirage_runtime\ntarget", shape="box"];

3 -> 2 [style="dashed"];
3 -> 1 [style="dashed"];
Expand All @@ -75,78 +91,102 @@ Describe before configure (no eval)
8 -> 5 [style="bold", style="dotted", headport="n"];
9 -> 8 [];
9 -> 4 [];
18 -> 10 [style="dotted", headport="n"];
18 -> 11 [style="dotted", headport="n"];
18 -> 12 [style="dotted", headport="n"];
18 -> 13 [style="dotted", headport="n"];
18 -> 14 [style="dotted", headport="n"];
18 -> 15 [style="dotted", headport="n"];
12 -> 10 [style="dotted", headport="n"];
12 -> 11 [style="dotted", headport="n"];
12 -> 10 [style="bold", style="dotted", headport="n"];
15 -> 13 [style="dotted", headport="n"];
15 -> 14 [style="dotted", headport="n"];
15 -> 13 [style="bold", style="dotted", headport="n"];
18 -> 16 [style="dotted", headport="n"];
18 -> 17 [style="bold", style="dotted", headport="n"];
19 -> 18 [];
20 -> 18 [];
20 -> 19 [];
20 -> 9 [];
20 -> 8 [];
20 -> 4 [];
21 -> 19 [];
21 -> 8 [];
23 -> 22 [];
23 -> 9 [];
23 -> 4 [];
23 -> 19 [];
23 -> 21 [];
24 -> 9 [];
24 -> 4 [];
24 -> 8 [];
24 -> 18 [];
24 -> 19 [];
24 -> 21 [];
25 -> 9 [];
25 -> 4 [];
25 -> 19 [];
25 -> 21 [];
26 -> 23 [style="dotted", headport="n"];
26 -> 24 [style="dotted", headport="n"];
26 -> 25 [style="bold", style="dotted", headport="n"];
27 -> 26 [];
27 -> 20 [];
28 -> 27 [];
28 -> 8 [];
28 -> 4 [];
28 -> 9 [];
29 -> 27 [];
29 -> 9 [];
30 -> 26 [];
31 -> 8 [];
31 -> 9 [];
31 -> 18 [];
31 -> 19 [];
31 -> 21 [];
31 -> 27 [];
31 -> 30 [];
31 -> 29 [];
31 -> 28 [];
32 -> 3 [style="dotted", headport="n"];
32 -> 31 [style="bold", style="dotted", headport="n"];
33 -> 32 [];
18 -> 17 [style="dotted", headport="n"];
18 -> 16 [style="bold", style="dotted", headport="n"];
21 -> 19 [style="dotted", headport="n"];
21 -> 20 [style="dotted", headport="n"];
21 -> 19 [style="bold", style="dotted", headport="n"];
24 -> 22 [style="dotted", headport="n"];
24 -> 23 [style="dotted", headport="n"];
24 -> 22 [style="bold", style="dotted", headport="n"];
27 -> 25 [style="dotted", headport="n"];
27 -> 26 [style="dotted", headport="n"];
27 -> 25 [style="bold", style="dotted", headport="n"];
30 -> 28 [style="dotted", headport="n"];
30 -> 29 [style="dotted", headport="n"];
30 -> 28 [style="bold", style="dotted", headport="n"];
33 -> 31 [style="dotted", headport="n"];
33 -> 32 [style="dotted", headport="n"];
33 -> 31 [style="bold", style="dotted", headport="n"];
34 -> 12 [style="dotted", headport="n"];
34 -> 15 [style="dotted", headport="n"];
34 -> 18 [style="dotted", headport="n"];
34 -> 21 [style="dotted", headport="n"];
34 -> 24 [style="dotted", headport="n"];
34 -> 27 [style="dotted", headport="n"];
34 -> 30 [style="dotted", headport="n"];
34 -> 33 [style="bold", style="dotted", headport="n"];
35 -> 34 [];
43 -> 40 [style="dotted", headport="n"];
43 -> 40 [style="dotted", headport="n"];
43 -> 41 [style="dotted", headport="n"];
43 -> 41 [style="dotted", headport="n"];
43 -> 41 [style="dotted", headport="n"];
43 -> 41 [style="dotted", headport="n"];
43 -> 41 [style="dotted", headport="n"];
43 -> 42 [style="bold", style="dotted", headport="n"];
44 -> 43 [style="dashed"];
45 -> 44 [style="dashed"];
45 -> 39 [style="dashed"];
45 -> 38 [style="dashed"];
45 -> 37 [style="dashed"];
45 -> 36 [style="dashed"];
45 -> 35 [style="dashed"];
45 -> 33 [style="dashed"];
36 -> 34 [];
36 -> 35 [];
36 -> 9 [];
36 -> 8 [];
36 -> 4 [];
37 -> 35 [];
37 -> 8 [];
39 -> 38 [];
39 -> 9 [];
39 -> 4 [];
39 -> 35 [];
39 -> 37 [];
40 -> 9 [];
40 -> 4 [];
40 -> 8 [];
40 -> 34 [];
40 -> 35 [];
40 -> 37 [];
41 -> 9 [];
41 -> 4 [];
41 -> 35 [];
41 -> 37 [];
42 -> 39 [style="dotted", headport="n"];
42 -> 40 [style="dotted", headport="n"];
42 -> 41 [style="bold", style="dotted", headport="n"];
43 -> 42 [];
43 -> 36 [];
44 -> 43 [];
44 -> 8 [];
44 -> 4 [];
44 -> 9 [];
45 -> 43 [];
45 -> 9 [];
46 -> 42 [];
47 -> 8 [];
47 -> 9 [];
47 -> 34 [];
47 -> 35 [];
47 -> 37 [];
47 -> 43 [];
47 -> 46 [];
47 -> 45 [];
47 -> 44 [];
48 -> 3 [style="dotted", headport="n"];
48 -> 47 [style="bold", style="dotted", headport="n"];
49 -> 48 [];
51 -> 50 [];
59 -> 56 [style="dotted", headport="n"];
59 -> 56 [style="dotted", headport="n"];
59 -> 57 [style="dotted", headport="n"];
59 -> 57 [style="dotted", headport="n"];
59 -> 57 [style="dotted", headport="n"];
59 -> 57 [style="dotted", headport="n"];
59 -> 57 [style="dotted", headport="n"];
59 -> 58 [style="bold", style="dotted", headport="n"];
60 -> 59 [style="dashed"];
61 -> 60 [style="dashed"];
61 -> 55 [style="dashed"];
61 -> 54 [style="dashed"];
61 -> 53 [style="dashed"];
61 -> 52 [style="dashed"];
61 -> 51 [style="dashed"];
61 -> 49 [style="dashed"];
}

Describe after configure
Expand Down