Permalink
Browse files

Merge pull request #871 from robhoes/ca74343-tampa

  • Loading branch information...
xen-git
xen-git committed Oct 18, 2012
2 parents a0e1f3a + c93c595 commit 866c8c1f337bc8b72f718c25241b0c270c7ab8d1
Showing with 13 additions and 12 deletions.
  1. +13 −12 ocaml/xapi/helpers.ml
View
@@ -843,19 +843,20 @@ let get_pif_underneath_vlan ~__context vlan_pif_ref =
let vlan_rec = Db.PIF.get_VLAN_master_of ~__context ~self:vlan_pif_ref in
Db.VLAN.get_tagged_PIF ~__context ~self:vlan_rec
-(* Only returns true if the network is shared properly; it must either be fully virtual (no PIFs) or
- every host must have a currently_attached PIF *)
+(* Only returns true if the network is shared properly: all (enabled) hosts in the pool must have a PIF on
+ * the network, and none of these PIFs may be bond slaves. This ensures that a VM with a VIF on this
+ * network can run on (and be migrated to) any (enabled) host in the pool. *)
let is_network_properly_shared ~__context ~self =
- let pifs = Db.Network.get_PIFs ~__context ~self in
- let plugged_pifs = List.filter (fun pif -> Db.PIF.get_currently_attached ~__context ~self:pif) pifs in
- let plugged_hosts = List.setify (List.map (fun pif -> Db.PIF.get_host ~__context ~self:pif) plugged_pifs) in
- let all_hosts = Db.Host.get_all ~__context in
- let enabled_hosts = List.filter (fun host -> Db.Host.get_enabled ~__context ~self:host) all_hosts in
- let missing_pifs = not(subset enabled_hosts plugged_hosts) in
- if missing_pifs then warn "Network %s not shared properly: Not all hosts have currently_attached PIFs" (Ref.string_of self);
- false
- (* || pifs = [] *) (* It's NOT ok to be fully virtual: see CA-20703. Change this in sync with assert_can_boot_here *)
- || not missing_pifs
+ let pifs = Db.Network.get_PIFs ~__context ~self in
+ let non_slave_pifs = List.filter (fun pif ->
+ not (Db.is_valid_ref __context (Db.PIF.get_bond_slave_of ~__context ~self:pif))) pifs in
+ let hosts_with_pif = List.setify (List.map (fun pif -> Db.PIF.get_host ~__context ~self:pif) non_slave_pifs) in
+ let all_hosts = Db.Host.get_all ~__context in
+ let enabled_hosts = List.filter (fun host -> Db.Host.get_enabled ~__context ~self:host) all_hosts in
+ let properly_shared = subset enabled_hosts hosts_with_pif in
+ if not properly_shared then
+ warn "Network %s not shared properly: Not all hosts have PIFs" (Ref.string_of self);
+ properly_shared
let vm_assert_agile ~__context ~self =
(* All referenced VDIs should be in shared SRs *)

0 comments on commit 866c8c1

Please sign in to comment.