Skip to content

Commit

Permalink
CA-220505: Destroy stale VM record on destination pool on failed SXM.
Browse files Browse the repository at this point in the history
Cancelling cross-pool SXM ends up in destroying VDIs and stale VM record
on destination Pool.
On SXM failure, If VM exists on source Pool then destroy the stale VM
record on destination Pool.

Signed-off-by: Sharad Yadav <sharad.yadav@citrix.com>
  • Loading branch information
sharady committed Sep 29, 2016
1 parent ebc14fb commit 7b06741
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ocaml/xapi/xapi_vm_migrate.ml
Expand Up @@ -958,6 +958,17 @@ let migrate_send' ~__context ~vm ~dest ~live ~vdi_map ~vif_map ~options =
Xapi_xenops.shutdown ~__context ~self:vm None;
end;
with _ -> ());

if not is_intra_pool && Db.is_valid_ref __context vm then begin
List.map (fun self -> Db.VM.get_uuid ~__context ~self) vm_and_snapshots
|> List.iter (fun self ->
try
let vm_ref = XenAPI.VM.get_by_uuid remote.rpc remote.session self in
info "Destroying stale VM uuid=%s on destination host" self;
XenAPI.VM.destroy remote.rpc remote.session vm_ref
with e -> error "Caught %s while destroying VM uuid=%s on destination host" (Printexc.to_string e) self)
end;

let task = Context.get_task_id __context in
let oc = Db.Task.get_other_config ~__context ~self:task in
if List.mem_assoc "mirror_failed" oc then begin
Expand Down

0 comments on commit 7b06741

Please sign in to comment.