From 9a305cac25091db9d9d1e5bb2eb134a02e7a56fd Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Thu, 8 Jul 2010 14:35:13 +0100 Subject: [PATCH] vswitch: pass network uuid to vswitch when creating an internal network For external networks this is taken care of by interface-reconfigure but in the internal network case there is currently no callout so simply pass the network uuid when creating calling out to create the bridge. Signed-off-by: Ian Campbell --- ocaml/netdev/netdev.ml | 10 +++++++--- ocaml/netdev/netdev.mli | 2 +- ocaml/xapi/xapi_network.ml | 9 +++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ocaml/netdev/netdev.ml b/ocaml/netdev/netdev.ml index d31d8dc6..768dd3b8 100644 --- a/ocaml/netdev/netdev.ml +++ b/ocaml/netdev/netdev.ml @@ -18,7 +18,7 @@ type kind = Bridge | Vswitch type network_ops = { kind: kind; - add: string -> unit; + add: string -> ?uuid:string -> unit; del: string -> unit; list: unit -> string list; @@ -99,7 +99,7 @@ module Bridge = struct external _add : Unix.file_descr -> string -> unit = "stub_bridge_add" external _del : Unix.file_descr -> string -> unit = "stub_bridge_del" -let add name = +let add name ?uuid = Internal.with_fd (fun fd -> _add fd name) let del name = @@ -224,7 +224,11 @@ let vsctl args = | "" -> [] | s -> Stringext.String.split '\n' s -let add name = ignore(vsctl ["add-br" ; name]) +let add name ?uuid = + let extra = match uuid with + | Some uuid' -> ["--"; "br-set-external-id"; name; "network-uuids"; uuid'] + | None -> ["--"; "foo"] in + ignore(vsctl (["add-br" ; name] @ extra)) let del name = ignore(vsctl ["del-br" ; name]) let list () = vsctl [ "list-br" ] diff --git a/ocaml/netdev/netdev.mli b/ocaml/netdev/netdev.mli index aaa19c57..07ce7198 100644 --- a/ocaml/netdev/netdev.mli +++ b/ocaml/netdev/netdev.mli @@ -21,7 +21,7 @@ type kind = (** Possible operations on each network backend type. *) type network_ops = { kind : kind; (** The type of network backend. *) - add : string -> unit; (** Add a bridge. *) + add : string -> ?uuid:string -> unit; (** Add a bridge. *) del : string -> unit; (** Remove a bridge. *) list : unit -> string list; (** List all bridges. *) exists : string -> bool; (** Query the existance of a bridge. *) diff --git a/ocaml/xapi/xapi_network.ml b/ocaml/xapi/xapi_network.ml index 79de059f..d1b63776 100644 --- a/ocaml/xapi/xapi_network.ml +++ b/ocaml/xapi/xapi_network.ml @@ -24,10 +24,10 @@ open Db_filter let get_allowed_messages ~__context ~self = [] *) -let create_internal_bridge ~bridge = - debug "Creating internal bridge %s" bridge; +let create_internal_bridge ~bridge ~uuid = + debug "Creating internal bridge %s (uuid:%s)" bridge uuid; let current = Netdev.network.Netdev.list () in - if not(List.mem bridge current) then Netdev.network.Netdev.add bridge; + if not(List.mem bridge current) then Netdev.network.Netdev.add bridge ?uuid:(Some uuid); if not(Netdev.Link.is_up bridge) then Netdev.Link.up bridge let attach_internal ?(management_interface=false) ~__context ~self () = @@ -36,10 +36,11 @@ let attach_internal ?(management_interface=false) ~__context ~self () = Xapi_network_attach_helpers.assert_can_attach_network_on_host ~__context ~self ~host ~overide_management_if_check:management_interface in let bridge = Db.Network.get_bridge ~__context ~self in + let uuid = Db.Network.get_uuid ~__context ~self in (* Ensure internal bridge exists and is up. external bridges will be brought up by call to interface-reconfigure. *) - if List.length(local_pifs) = 0 then create_internal_bridge ~bridge; + if List.length(local_pifs) = 0 then create_internal_bridge ~bridge ~uuid; (* Check if we're a guest-installer network: *) let other_config = Db.Network.get_other_config ~__context ~self in -- 2.39.5