[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH 1 of 2] CP-1591: Propagate Network.MTU field to xenstore for use in VIF hotplug script



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1267008538 0
# Node ID 219104a041786d7274b15800de5c3efccf0c4f42
# Parent  005747c941859b3a18bf085b5674b40ecf5cbbc6
CP-1591: Propagate Network.MTU field to xenstore for use in VIF hotplug script.

Allow VIF.other-config:mtu to override the network-wide setting.

Update quicktest to understand that Network.MTU is the default MTU for
a VIF with VIF.other-config:mtu as an override.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 005747c94185 -r 219104a04178 ocaml/xapi/quicktest.ml
--- a/ocaml/xapi/quicktest.ml   Wed Feb 24 10:48:58 2010 +0000
+++ b/ocaml/xapi/quicktest.ml   Wed Feb 24 10:48:58 2010 +0000
@@ -339,6 +339,7 @@
        let bridge = Client.Network.get_bridge !rpc session_id network in
        let device = Printf.sprintf "vif%Ld.%s" (Client.VM.get_domid !rpc 
session_id vm) (Client.VIF.get_device !rpc session_id vif) in
        let devices = Netdev.network.Netdev.intf_list bridge in
+       let other_config = Client.VIF.get_other_config !rpc session_id vif in
        if not(List.mem device devices) 
        then failed test (Printf.sprintf "Failed to find device %s on bridge %s 
(found [ %s ])" device bridge (String.concat ", " devices))
        else debug test (Printf.sprintf "Device %s is on bridge %s" device 
bridge);
@@ -347,7 +348,6 @@
        let sysfs_promisc = Printf.sprintf "/sys/class/net/%s/brport/promisc" 
device in
        if Sys.file_exists sysfs_promisc
        then begin
-         let other_config = Client.VIF.get_other_config !rpc session_id vif in
          let promisc = List.mem_assoc "promiscuous" other_config && (let x = 
List.assoc "promiscuous" other_config in x = "true" || x = "on") in
          let promisc' = read_sys sysfs_promisc = "1" in
          if promisc <> promisc' 
@@ -357,12 +357,13 @@
          debug test (Printf.sprintf "%s not found. assuming unsupported" 
sysfs_promisc);
 
        (* Check the MTU *)
-       let mtu = Client.VIF.get_MTU !rpc session_id vif in
-       let mtu' = if mtu = 0L then 1500L else mtu in
+       let mtu = Client.Network.get_MTU !rpc session_id network in
+       let mtu' = if List.mem_assoc "mtu" other_config
+         then Int64.of_string(List.assoc "mtu" other_config) else mtu in
        let mtu'' = Int64.of_string (read_sys (Printf.sprintf 
"/sys/class/net/%s/mtu" device)) in
        if mtu' <> mtu'' 
-       then failed test (Printf.sprintf "VIF.MTU is %Ld but /sys says %Ld" mtu 
mtu'')
-       else debug test (Printf.sprintf "VIF.MTU is %Ld and /sys says %Ld" mtu 
mtu'');
+       then failed test (Printf.sprintf "VIF.MTU is %Ld but /sys says %Ld" 
mtu' mtu'')
+       else debug test (Printf.sprintf "VIF.MTU is %Ld and /sys says %Ld" mtu' 
mtu'');
     ) vifs
 
 let rec wait_for_task_complete session_id task = 
@@ -600,7 +601,7 @@
     | _ -> failwith "Expecting 1 new disk!"
 
 let make_vif ~session_id ~vM ~network ~device = 
-  Client.VIF.create ~rpc:!rpc ~session_id ~vM ~network ~mTU:1400L ~mAC:"" 
~device ~other_config:["promiscuous", "on"] ~qos_algorithm_type:"" 
~qos_algorithm_params:[] 
+  Client.VIF.create ~rpc:!rpc ~session_id ~vM ~network ~mTU:0L ~mAC:"" ~device 
~other_config:["promiscuous", "on"; "mtu", "1400"] ~qos_algorithm_type:"" 
~qos_algorithm_params:[] 
 
 let with_debian s f = 
   try
diff -r 005747c94185 -r 219104a04178 ocaml/xapi/vm_config.ml
--- a/ocaml/xapi/vm_config.ml   Wed Feb 24 10:48:58 2010 +0000
+++ b/ocaml/xapi/vm_config.ml   Wed Feb 24 10:48:58 2010 +0000
@@ -43,8 +43,9 @@
     warn "vif QoS failed: %s (vm=%s,vif=%s)" reason vm_r.API.vM_uuid 
vif_r.API.vIF_uuid in
   
   let mac = vif_r.API.vIF_MAC in
-  let mtu = Int64.to_int vif_r.API.vIF_MTU in
-  
+  let vif_mtu = if (List.mem_assoc "mtu" vif_r.API.vIF_other_config) then
+    Some (int_of_string (List.assoc "mtu" vif_r.API.vIF_other_config)) else 
None in
+
   let qos_type = vif_r.API.vIF_qos_algorithm_type in
   let qos_params = vif_r.API.vIF_qos_algorithm_params in
   let rate = match qos_type with
@@ -71,6 +72,9 @@
   try
     let network_ref = vif_r.API.vIF_network in
     let bridge = Db.Network.get_bridge ~__context ~self:network_ref in
+    let mtu = match vif_mtu with
+      | Some mtu -> mtu
+      | None -> Int64.to_int (Db.Network.get_MTU ~__context ~self:network_ref) 
in
     Some {
       domid = domid;
       vif_ref = vif;
diff -r 005747c94185 -r 219104a04178 ocaml/xapi/xapi_network.ml
--- a/ocaml/xapi/xapi_network.ml        Wed Feb 24 10:48:58 2010 +0000
+++ b/ocaml/xapi/xapi_network.ml        Wed Feb 24 10:48:58 2010 +0000
@@ -25,6 +25,7 @@
 *)
 
 let create_internal_bridge ~bridge =
+  debug "Creating internal bridge %s" bridge;
   let current = Netdev.network.Netdev.list () in
   if not(List.mem bridge current) then Netdev.network.Netdev.add bridge;
   if not(Netdev.Link.is_up bridge) then Netdev.Link.up bridge

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.