Skip to content

Commit afc0a17

Browse files
committed
Merge pull request #26 from robhoes/ea1254
add config file for network.conf to select the backend type
2 parents 0bbf2b1 + 4cefb43 commit afc0a17

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

networkd/network_server.ml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ open D
2424

2525
type context = unit
2626

27+
let network_conf = ref "/etc/xcp/network.conf"
2728
let config : config_t ref = ref empty_config
2829

2930
let legacy_management_interface_start () =
@@ -396,15 +397,17 @@ module Bridge = struct
396397
config := {!config with bridge_config = update_config !config.bridge_config name data}
397398

398399
let determine_backend () =
399-
let backend = String.strip String.isspace
400-
(Unixext.string_of_file ("/etc/xcp/network.conf")) in
401-
match backend with
402-
| "openvswitch" | "vswitch" -> kind := Openvswitch
403-
| "bridge" -> kind := Bridge
404-
| backend ->
405-
let error = Printf.sprintf "ERROR: network backend unknown (%s)" backend in
406-
debug "%s" error;
407-
failwith error
400+
try
401+
let backend = String.strip String.isspace (Unixext.string_of_file !network_conf) in
402+
match backend with
403+
| "openvswitch" | "vswitch" -> kind := Openvswitch
404+
| "bridge" -> kind := Bridge
405+
| backend ->
406+
warn "Network backend unknown (%s). Falling back to Open vSwitch." backend;
407+
kind := Openvswitch
408+
with _ ->
409+
warn "Network-conf file not found. Falling back to Open vSwitch.";
410+
kind := Openvswitch
408411

409412
let get_bond_links_up _ dbg ~name =
410413
Debug.with_thread_associated dbg (fun () ->

networkd/networkd.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ open D
2222
module Server = Network_interface.Server(Network_server)
2323

2424
let resources = [
25+
{ Xcp_service.name = "network-conf";
26+
description = "used to select the network backend";
27+
essential = true;
28+
path = Network_server.network_conf;
29+
perms = [ Unix.R_OK ];
30+
};
2531
{ Xcp_service.name = "brctl";
2632
description = "used to set up bridges";
2733
essential = true;

0 commit comments

Comments
 (0)