# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
CP-1591: Synchronise VIF.MTU and PIF.MTU on plug
The VIF.MTU and PIF.MTU fields are now read-only, and will reflect the current
state of the network. When you change the Network.MTU, VIFs and PIFs will have
to be replugged to have their MTU changed by the networking subsystem. So when
Network.MTU and PIF.MTU are not equal, this is a reminder to replug the PIF
(same for VIFs).
Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>
diff -r a448c3528b84 ocaml/xapi/dbsync_slave.ml
--- a/ocaml/xapi/dbsync_slave.ml
+++ b/ocaml/xapi/dbsync_slave.ml
@@ -420,7 +420,7 @@
* interface (defined by what is brought up before xapi starts) as attached
too.
* For example, this will prevent needless glitches in storage interfaces.
*)
-let resynchronise_pif_currently_attached ~__context =
+let resynchronise_pif_params ~__context =
let localhost = Helpers.get_localhost () in
(* See which PIFs were brought up at start of day, according to the
inventory file *)
let pifs_brought_up =
@@ -443,7 +443,15 @@
(Mtc.is_pif_attached_to_mtc_vms_and_should_not_be_offline ~__context ~self) in
Db.PIF.set_currently_attached ~__context ~self ~value:mark_as_attached;
Db.PIF.set_management ~__context ~self ~value:is_management_pif;
- debug "Marking PIF device %s as %s" (Db.PIF.get_device ~__context
~self) (if mark_as_attached then "attached" else "offline")
+ debug "Marking PIF device %s as %s" (Db.PIF.get_device ~__context
~self) (if mark_as_attached then "attached" else "offline");
+
+ (* sync MTU *)
+ try
+ let device = Db.PIF.get_device ~__context ~self in
+ let mtu = Int64.of_string (Netdev.get_mtu device) in
+ Db.PIF.set_MTU ~__context ~self ~value:mtu;
+ with _ ->
+ debug "could not update MTU field on PIF %s" (Db.PIF.get_uuid
~__context ~self)
)
(Db.Host.get_PIFs ~__context ~self:localhost)
@@ -520,9 +528,9 @@
update_physical_networks ~__context;
*)
- switched_sync Xapi_globs.sync_resynchronise_pif_currently_attached (fun () ->
- debug "resynchronising PIF.currently_attached";
- resynchronise_pif_currently_attached ~__context;
+ switched_sync Xapi_globs.sync_pif_params (fun () ->
+ debug "resynchronising PIF params";
+ resynchronise_pif_params ~__context;
);
switched_sync Xapi_globs.sync_patch_update_db (fun () ->
diff -r a448c3528b84 ocaml/xapi/nm.ml
--- a/ocaml/xapi/nm.ml
+++ b/ocaml/xapi/nm.ml
@@ -72,6 +72,15 @@
Xapi_mgmt_iface.rebind ()
end;
+ (* sync MTU *)
+ (try
+ let device = Db.PIF.get_device ~__context ~self:pif in
+ let mtu = Int64.of_string (Netdev.get_mtu device) in
+ Db.PIF.set_MTU ~__context ~self:pif ~value:mtu
+ with _ ->
+ debug "could not update MTU field on PIF %s" uuid
+ );
+
Xapi_mgmt_iface.on_dom0_networking_change ~__context;
update_inventory ~__context
diff -r a448c3528b84 ocaml/xapi/vmops.ml
--- a/ocaml/xapi/vmops.ml
+++ b/ocaml/xapi/vmops.ml
@@ -82,8 +82,9 @@
let add_vif ~__context ~xs vif_device =
if vif_device.Vm_config.bridge = "" then failwith "Don't know how to connect
a VIF to this type of Network";
+ let vif_uuid = Db.VIF.get_uuid ~__context ~self:vif_device.Vm_config.vif_ref
in
let extra_private_keys = ["ref", Ref.string_of vif_device.Vm_config.vif_ref;
- "vif-uuid", Db.VIF.get_uuid ~__context
~self:vif_device.Vm_config.vif_ref;
+ "vif-uuid", vif_uuid;
"network-uuid", Db.Network.get_uuid ~__context
~self:vif_device.Vm_config.network_ref] in
Xapi_network.attach_internal ~__context
~self:vif_device.Vm_config.network_ref ();
Xapi_udhcpd.maybe_add_lease ~__context vif_device.Vm_config.vif_ref;
@@ -97,7 +98,15 @@
vif_device.Vm_config.domid in
()
);
- Db.VIF.set_currently_attached ~__context ~self:vif_device.Vm_config.vif_ref
~value:true
+ Db.VIF.set_currently_attached ~__context ~self:vif_device.Vm_config.vif_ref
~value:true;
+ (* sync MTU *)
+ try
+ let device = "vif" ^ (string_of_int vif_device.Vm_config.domid) ^ "." ^
(string_of_int vif_device.Vm_config.devid) in
+ let mtu = Int64.of_string (Netdev.get_mtu device) in
+ Db.VIF.set_MTU ~__context ~self:vif_device.Vm_config.vif_ref ~value:mtu
+ with _ ->
+ debug "could not update MTU field on VIF %s" vif_uuid
+
(* take a list of vif devices and attach them to the domid *)
let create_vifs ~__context ~xs vifs =
diff -r a448c3528b84 ocaml/xapi/xapi_globs.ml
--- a/ocaml/xapi/xapi_globs.ml
+++ b/ocaml/xapi/xapi_globs.ml
@@ -342,7 +342,7 @@
let sync_crashdump_resynchronise = "sync_crashdump_resynchronise"
let sync_update_vms = "sync_update_vms"
let sync_remove_leaked_vbds = "sync_remove_leaked_vbds"
-let sync_resynchronise_pif_currently_attached =
"sync_resynchronise_pif_currently_attached"
+let sync_pif_params = "sync_pif_params"
let sync_patch_update_db = "sync_patch_update_db"
let sync_pbd_reset = "sync_pbd_reset"
let sync_bios_strings = "sync_bios_strings"
sync-mtu
Description: Text document
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
|