Skip to content

Commit afe8e1b

Browse files
committed
xapi_vm_migrate: Fix reservations not being cleared on halted VMs
Cross-pool migrations set scheduled_to_be_resident_on to the destination host, reserving memory and vGPUs. If the VM is still halted when migration is finished, the field is not cleared on the destination, preserving the reservations even though they're not necessarily going to be used anytime soon. Call force_state_reset_keep_current_operations in pool_migrate_complete on the destination to clear the reservations among other things at the end of the migration. This fixes an issue when VMs migrated across pools in a halted state would take up memory in xapi's view (but not in RRD's view), which is not intuitive and could prevent further migrations from claiming enough free memory on the host. Signed-off-by: Andrii Sultanov <[email protected]>
1 parent 6c16a2f commit afe8e1b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ocaml/xapi/xapi_vm_migrate.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,11 @@ let pool_migrate_complete ~__context ~vm ~host:_ =
489489
~value:`restart_device_model ;
490490
let dbg = Context.string_of_task __context in
491491
let queue_name = Xapi_xenops_queue.queue_of_vm ~__context ~self:vm in
492+
(* Reset the state, which will update allowed operations, clear reservations
493+
for halted VMs, disconnect devices *)
494+
let power_state = Db.VM.get_power_state ~__context ~self:vm in
495+
Xapi_vm_lifecycle.force_state_reset_keep_current_operations ~__context
496+
~self:vm ~value:power_state ;
492497
if Xapi_xenops.vm_exists_in_xenopsd queue_name dbg id then (
493498
remove_stale_pcis ~__context ~vm ;
494499
Xapi_xenops.set_resident_on ~__context ~self:vm ;

0 commit comments

Comments
 (0)