Skip to content

Commit

Permalink
[CP-18781] Use the correct vif device id in set_MTU or fail (#2760)
Browse files Browse the repository at this point in the history
When updating the MTU of a `VIF` it can happen that the VM `domid` is still out of sync and consequently the computed device id is wrong.
We can use the correct device value passing it via `xenopsd` as a field in `VIF.stat`.

Signed-off-by: Marcello Seri <[email protected]>
  • Loading branch information
Marcello Seri authored and robhoes committed Sep 13, 2016
1 parent ab7504c commit fe3dacf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ocaml/xapi/xapi_xenops.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1639,10 +1639,12 @@ let update_vif ~__context id =
if state.plugged then begin
(* sync MTU *)
(try
let device = "vif" ^ (Int64.to_string (Db.VM.get_domid ~__context ~self:vm)) ^ "." ^ (snd id) in
let dbg = Context.string_of_task __context in
let mtu = Net.Interface.get_mtu dbg ~name:device in
Db.VIF.set_MTU ~__context ~self:vif ~value:(Int64.of_int mtu)
match state.device with
| None -> failwith (Printf.sprintf "could not determine device id for VIF %s.%s" (fst id) (snd id))
| Some device ->
let dbg = Context.string_of_task __context in
let mtu = Net.Interface.get_mtu dbg ~name:device in
Db.VIF.set_MTU ~__context ~self:vif ~value:(Int64.of_int mtu)
with _ ->
debug "could not update MTU field on VIF %s.%s" (fst id) (snd id));

Expand Down

0 comments on commit fe3dacf

Please sign in to comment.