Skip to content

Commit 88ce554

Browse files
authored
message_forwarding: Don't block cross-pool migrations for unbootable VMs (#7062)
`forward_to_suitable_host` picks a host that can boot up the VM, erroring out with `NO_HOSTS_AVAILABLE` otherwise. In case of a non-live VM that can't boot anywhere in the source pool (because it requires a larger amount of memory, for example), this would block its migration to a suitable pool altogether. Catch the error and launch the migration from any host that can see the VM's SRs instead of blocking it.
2 parents 660bdb6 + 1971042 commit 88ce554

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

ocaml/xapi/message_forwarding.ml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,13 +2672,14 @@ functor
26722672
Client.VM.migrate_send ~vm ~dest ~live ~vdi_map ~vif_map ~options
26732673
~vgpu_map
26742674
in
2675+
let host = List.assoc Xapi_vm_migrate._host dest |> Ref.of_string in
2676+
let cross_pool = not (Db.is_valid_ref __context host) in
26752677
let migration_type =
26762678
if Xapi_vm_lifecycle_helpers.is_live ~__context ~self:vm then
2677-
let host = List.assoc Xapi_vm_migrate._host dest |> Ref.of_string in
2678-
if Db.is_valid_ref __context host then
2679-
`Live_intrapool host
2680-
else
2679+
if cross_pool then
26812680
`Live_interpool
2681+
else
2682+
`Live_intrapool host
26822683
else
26832684
`Non_live
26842685
in
@@ -2700,12 +2701,22 @@ functor
27002701
| `Live_interpool ->
27012702
forward_internal_async ()
27022703
(* resources on the destination will be reserved separately *)
2703-
| `Non_live ->
2704+
| `Non_live -> (
27042705
let snapshot = Db.VM.get_record ~__context ~self:vm in
2705-
fst
2706-
(forward_to_suitable_host ~local_fn ~__context ~vm ~snapshot
2707-
~host_op:`vm_migrate ~remote_fn ()
2708-
)
2706+
try
2707+
fst
2708+
(forward_to_suitable_host ~local_fn ~__context ~vm ~snapshot
2709+
~host_op:`vm_migrate ~remote_fn ()
2710+
)
2711+
with
2712+
| Api_errors.Server_error (code, _)
2713+
when code = Api_errors.no_hosts_available && cross_pool
2714+
->
2715+
(* If non-live VM can't start anywhere in the pool, allow
2716+
cross-pool migrations, with any host that can see its
2717+
SRs acting as the sender *)
2718+
forward_to_access_srs ~local_fn ~__context ~vm ~remote_fn
2719+
)
27092720
| `Live_intrapool host ->
27102721
(* reserve resources on the destination host, then forward the call to the source. *)
27112722
let snapshot = Db.VM.get_record ~__context ~self:vm in

0 commit comments

Comments
 (0)