Skip to content

Commit 889dfa6

Browse files
committed
CP-45016: Clean up the source VM earlier
Previously the source VM is cleaned up at the very end of the migration, after the destination VM is up and running. This has caused problems for SMAPIv3 SRs as the new VM needs to plug in the new VBD which requires a datapath activate on the VDI which is currently in use by the old VM (and the mirroring process). This window needs to be reduced since we cannot have two datapath activated at the same time. Signed-off-by: Vincent Liu <[email protected]>
1 parent 5b9e892 commit 889dfa6

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

ocaml/xenopsd/lib/xenops_server.ml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,23 @@ 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
27352752
let final_handshake () =
27362753
Handshake.send vm_fd Handshake.Success ;
27372754
debug "VM.migrate: Synchronisation point 3" ;
@@ -2772,7 +2789,10 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
27722789
the main VM migration sequence. *)
27732790
match VGPU_DB.ids id with
27742791
| [] ->
2775-
first_handshake () ; save () ; final_handshake ()
2792+
first_handshake () ;
2793+
save () ;
2794+
pause_src_vm () ;
2795+
final_handshake ()
27762796
| (_vm_id, dev_id) :: _ ->
27772797
let url =
27782798
make_url "/migrate/vgpu/"
@@ -2789,20 +2809,12 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
27892809
first_handshake () ;
27902810
save ~vgpu_fd:(FD vgpu_fd) ()
27912811
) ;
2812+
pause_src_vm () ;
27922813
final_handshake ()
27932814
) ;
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-
@ [
2815+
let cleanup_src_vm () =
2816+
let atomics =
2817+
[
28062818
VM_hook_script_stable
28072819
( id
28082820
, Xenops_hooks.VM_post_destroy
@@ -2811,8 +2823,10 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
28112823
)
28122824
; VM_remove new_src_id
28132825
]
2826+
in
2827+
perform_atomics atomics t
28142828
in
2815-
perform_atomics atomics t
2829+
cleanup_src_vm ()
28162830
| VM_receive_memory
28172831
{
28182832
vmr_id= id

0 commit comments

Comments
 (0)