From: David Scott Date: Wed, 26 Jan 2011 17:39:04 +0000 (+0000) Subject: SCTX-525: only write the names of interfaces ("current interfaces") into the inventor... X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=538635062dc44c1820c6dffe5b982cb072410064;p=xcp%2Fxen-api.git SCTX-525: only write the names of interfaces ("current interfaces") into the inventory file and cause them to be ifup'ed on system boot if they actually have an IP address configuration in dom0. This avoids initialising bridges for bonds and VLANs which are only for guests and which can be initialised on demand. Stats: * 5 host pool * 300 VLANs, none used Pool reboot time drops from 45 mins to 8 mins Signed-off-by: David Scott --- diff --git a/ocaml/xapi/nm.ml b/ocaml/xapi/nm.ml index 76f67a3e..cf75fc63 100644 --- a/ocaml/xapi/nm.ml +++ b/ocaml/xapi/nm.ml @@ -23,14 +23,24 @@ let with_local_lock f = Mutex.execute local_m f let interface_reconfigure_script = "/opt/xensource/libexec/interface-reconfigure" +(* A "dom0 interface" is an IP-enabled interface on _dom0_ which might be + being used (via some route in the routing table) for access to storage + which we need to be able to see on startup before xapi has initialised *) +let is_dom0_interface pif_r = pif_r.API.pIF_ip_configuration_mode <> `None + (* Make sure inventory file has all current interfaces on the local host, so * they will all be brought up again at start up. *) let update_inventory ~__context = - let pifs = List.filter (fun pif -> Db.PIF.get_currently_attached ~__context ~self:pif && - Db.PIF.get_host ~__context ~self:pif = Helpers.get_localhost ~__context) (Db.PIF.get_all ~__context) in - let get_netw pif = Db.PIF.get_network ~__context ~self:pif in - let bridges = List.map (fun pif -> Db.Network.get_bridge ~__context ~self:(get_netw pif)) pifs in - Xapi_inventory.update Xapi_inventory._current_interfaces (String.concat " " bridges) + let localhost = Helpers.get_localhost ~__context in + let pifs = List.filter + (fun (pif, pif_r) -> + true && + pif_r.API.pIF_host = localhost && + is_dom0_interface pif_r && + pif_r.API.pIF_currently_attached) + (Db.PIF.get_all_records ~__context) in + let bridges = List.map (fun (_, pif_r) -> Db.Network.get_bridge ~__context ~self:pif_r.API.pIF_network) pifs in + Xapi_inventory.update Xapi_inventory._current_interfaces (String.concat " " bridges) (* Call the interface reconfigure script. For development ignore the exn if it doesn't exist *) let reconfigure_pif ~__context (pif: API.ref_PIF) args = diff --git a/ocaml/xapi/nm.mli b/ocaml/xapi/nm.mli index f4ca67c8..63ed3d2c 100644 --- a/ocaml/xapi/nm.mli +++ b/ocaml/xapi/nm.mli @@ -27,3 +27,7 @@ val bring_pif_down : __context:Context.t -> API.ref_PIF -> unit (** Execute a given function under the control of a mutex *) val with_local_lock : (unit -> 'a) -> 'a + +(** [is_dom0_interface pif_r] returns true if pif_r is a network interface + which has a dom0 endpoint *) +val is_dom0_interface : API.pIF_t -> bool diff --git a/ocaml/xapi/xapi_pif.ml b/ocaml/xapi/xapi_pif.ml index 2bf0ea44..b306ed6b 100644 --- a/ocaml/xapi/xapi_pif.ml +++ b/ocaml/xapi/xapi_pif.ml @@ -494,10 +494,12 @@ let rec plug ~__context ~self = Xapi_network.attach ~__context ~network ~host let calculate_pifs_required_at_start_of_day ~__context = - List.filter (fun (_,pifr) -> - true - && (pifr.API.pIF_host = !Xapi_globs.localhost_ref) (* this host only *) - && not (Db.is_valid_ref pifr.API.pIF_bond_slave_of) (* not enslaved by a bond *) + let localhost = Helpers.get_localhost ~__context in + List.filter (fun (_,pifr) -> + true && + pifr.API.pIF_host = localhost && (* this host only *) + Nm.is_dom0_interface pifr && + not (Db.is_valid_ref pifr.API.pIF_bond_slave_of) (* not enslaved by a bond *) ) (Db.PIF.get_all_records ~__context)