Skip to content

Commit 4ea5d43

Browse files
authored
Revert VM migration shutdown order change + change post_detach to post_deactivate (#6260)
There are two parts to this PR: 1. Reverts the VM migration ordering change, which was previously thought to be necessary as I did not see `VM_save` would actually deactivate the source VM datapath. Thanks @edwintorok for pointing that out. 2. Change `post_detach_hook` to `post_deactivate_hook`, as this should have been called as soon as the datapath is deactivated, at which point all r/w using that datapath will be stopped. More details in the commit message.
2 parents 08f8647 + 764ec0d commit 4ea5d43

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

ocaml/xapi/storage_migrate.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ let pre_deactivate_hook ~dbg:_ ~dp:_ ~sr ~vdi =
13201320
s.failed <- true
13211321
)
13221322

1323-
let post_detach_hook ~sr ~vdi ~dp:_ =
1323+
let post_deactivate_hook ~sr ~vdi ~dp:_ =
13241324
let open State.Send_state in
13251325
let id = State.mirror_id_of (sr, vdi) in
13261326
State.find_active_local_mirror id

ocaml/xapi/storage_smapiv1_wrapper.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,10 @@ functor
422422
| Vdi_automaton.Deactivate ->
423423
Storage_migrate.pre_deactivate_hook ~dbg ~dp ~sr ~vdi ;
424424
Impl.VDI.deactivate context ~dbg ~dp ~sr ~vdi ~vm ;
425+
Storage_migrate.post_deactivate_hook ~sr ~vdi ~dp ;
425426
vdi_t
426427
| Vdi_automaton.Detach ->
427428
Impl.VDI.detach context ~dbg ~dp ~sr ~vdi ~vm ;
428-
Storage_migrate.post_detach_hook ~sr ~vdi ~dp ;
429429
vdi_t
430430
in
431431
Sr.add_or_replace vdi new_vdi_t sr_t ;

ocaml/xenopsd/lib/xenops_server.ml

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,23 +2732,6 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
27322732
) ;
27332733
debug "VM.migrate: Synchronisation point 1"
27342734
in
2735-
let pause_src_vm () =
2736-
debug
2737-
"VM.migrate: pause src vm before allowing destination to proceed" ;
2738-
(* cleanup tmp src VM *)
2739-
let atomics =
2740-
[
2741-
VM_hook_script_stable
2742-
( id
2743-
, Xenops_hooks.VM_pre_destroy
2744-
, Xenops_hooks.reason__suspend
2745-
, new_src_id
2746-
)
2747-
]
2748-
@ atomics_of_operation (VM_shutdown (new_src_id, None))
2749-
in
2750-
perform_atomics atomics t
2751-
in
27522735
let final_handshake () =
27532736
Handshake.send vm_fd Handshake.Success ;
27542737
debug "VM.migrate: Synchronisation point 3" ;
@@ -2789,10 +2772,7 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
27892772
the main VM migration sequence. *)
27902773
match VGPU_DB.ids id with
27912774
| [] ->
2792-
first_handshake () ;
2793-
save () ;
2794-
pause_src_vm () ;
2795-
final_handshake ()
2775+
first_handshake () ; save () ; final_handshake ()
27962776
| (_vm_id, dev_id) :: _ ->
27972777
let url =
27982778
make_url "/migrate/vgpu/"
@@ -2809,12 +2789,20 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
28092789
first_handshake () ;
28102790
save ~vgpu_fd:(FD vgpu_fd) ()
28112791
) ;
2812-
pause_src_vm () ;
28132792
final_handshake ()
28142793
) ;
2815-
let cleanup_src_vm () =
2816-
let atomics =
2817-
[
2794+
(* cleanup tmp src VM *)
2795+
let atomics =
2796+
[
2797+
VM_hook_script_stable
2798+
( id
2799+
, Xenops_hooks.VM_pre_destroy
2800+
, Xenops_hooks.reason__suspend
2801+
, new_src_id
2802+
)
2803+
]
2804+
@ atomics_of_operation (VM_shutdown (new_src_id, None))
2805+
@ [
28182806
VM_hook_script_stable
28192807
( id
28202808
, Xenops_hooks.VM_post_destroy
@@ -2823,10 +2811,8 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
28232811
)
28242812
; VM_remove new_src_id
28252813
]
2826-
in
2827-
perform_atomics atomics t
28282814
in
2829-
cleanup_src_vm ()
2815+
perform_atomics atomics t
28302816
| VM_receive_memory
28312817
{
28322818
vmr_id= id

0 commit comments

Comments
 (0)