Skip to content

Commit

Permalink
CA-286874: Redundant checks for SR-IOV when implementing VDI migration (
Browse files Browse the repository at this point in the history
#3547)

* CA-286874: Redundant checks for SR-IOV when implementing VDI migration

This fix along with CA-282684 aim to fix scenario when VM implementing VDI
migration VGPUs/Network SR-IOV (if have) will reserve resources first
then again check the remaining capacity. It means when there are not
double resources than request, the check will fail.

Signed-off-by: Min Li <min.li1@citrix.com>
  • Loading branch information
minli1 authored and lindig committed Apr 12, 2018
1 parent d31f506 commit 5e47860
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions ocaml/xapi/xapi_vm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -410,18 +410,24 @@ let assert_usbs_available ~__context ~self ~host =
]))
)

(* Get SR-IOV Vifs by return a list of [(network1,(required_num1,PCI1));(network2,(required_num2,PCI2))....]
(* 1.To avoid redundant checks,for each VF if it was reserved, then it's no need to check remaining capacity again.
2.Get SR-IOV Vifs by return a list of [(network1,(required_num1,PCI1));(network2,(required_num2,PCI2))....]
Raise exn immediately when found Idle VF nums < required_num *)
let assert_netsriov_available ~__context ~self ~host =
let sriov_networks = List.fold_left (fun acc vif ->
let network = Db.VIF.get_network ~__context ~self:vif in
try
let required, pif = List.assoc network acc in
(network,(required + 1,pif)) :: (List.remove_assoc network acc)
with Not_found ->
match Xapi_network_sriov_helpers.get_local_underlying_pif ~__context ~network ~host with
| Some pif -> (network,(1,pif)) :: acc
| None -> acc
let reserved_pci = Db.VIF.get_reserved_pci ~__context ~self:vif in
if Db.is_valid_ref __context reserved_pci
then acc
else begin
let network = Db.VIF.get_network ~__context ~self:vif in
try
let required, pif = List.assoc network acc in
(network,(required + 1,pif)) :: (List.remove_assoc network acc)
with Not_found ->
match Xapi_network_sriov_helpers.get_local_underlying_pif ~__context ~network ~host with
| Some pif -> (network,(1,pif)) :: acc
| None -> acc
end
) [] (Db.VM.get_VIFs ~__context ~self)
in
List.iter (fun (network, (required,pif)) ->
Expand Down

0 comments on commit 5e47860

Please sign in to comment.