Skip to content

Commit 8e48cb2

Browse files
authored
CA-407033: Call receive_finalize2 synchronously (#6312)
`Remote.receive_finalize2` is called at the end of SXM to clean things up and compose the base and leaf images together. The compose operation should only be called while the VDI is deactivated. Currently a thread is created to call `receive_finalize2`, which could caused problems where the VM itself gets started while the `receive_finalize2`/`VDI.compose` is still in progress. This is not a safe operation to do. The fix here is simply to wait for the thread to finish.
2 parents 56ae24f + 76f1d65 commit 8e48cb2

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

ocaml/xapi/storage_migrate.ml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,22 +1338,14 @@ let post_deactivate_hook ~sr ~vdi ~dp:_ =
13381338
Storage_utils.rpc ~srcstr:"smapiv2" ~dststr:"dst_smapiv2"
13391339
remote_url
13401340
end)) in
1341-
let t =
1342-
Thread.create
1343-
(fun () ->
1344-
debug "Calling receive_finalize2" ;
1345-
log_and_ignore_exn (fun () ->
1346-
Remote.DATA.MIRROR.receive_finalize2 "Mirror-cleanup" id
1347-
) ;
1348-
debug "Finished calling receive_finalize2" ;
1349-
State.remove_local_mirror id ;
1350-
debug "Removed active local mirror: %s" id
1351-
)
1352-
()
1353-
in
1354-
Option.iter (fun id -> Scheduler.cancel scheduler id) r.watchdog ;
1355-
debug "Created thread %d to call receive finalize and dp destroy"
1356-
(Thread.id t)
1341+
debug "Calling receive_finalize2" ;
1342+
log_and_ignore_exn (fun () ->
1343+
Remote.DATA.MIRROR.receive_finalize2 "Mirror-cleanup" id
1344+
) ;
1345+
debug "Finished calling receive_finalize2" ;
1346+
State.remove_local_mirror id ;
1347+
debug "Removed active local mirror: %s" id ;
1348+
Option.iter (fun id -> Scheduler.cancel scheduler id) r.watchdog
13571349
)
13581350

13591351
let nbd_handler req s ?(vm = "0") sr vdi dp =

0 commit comments

Comments
 (0)