Skip to content

Commit

Permalink
CP-45016: Clean up the source VM earlier
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Vincent-lau committed Dec 10, 2024
1 parent 2a57ee8 commit 4bf00f7
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions ocaml/xenopsd/lib/xenops_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2726,6 +2726,23 @@ and perform_exn ?subtask ?result (op : operation) (t : Xenops_task.task_handle)
) ;
debug "VM.migrate: Synchronisation point 1"
in
let pause_src_vm () =
debug
"VM.migrate: pause src vm before allowing destination to proceed" ;
(* cleanup tmp src VM *)
let atomics =
[
VM_hook_script_stable
( id
, Xenops_hooks.VM_pre_destroy
, Xenops_hooks.reason__suspend
, new_src_id
)
]
@ atomics_of_operation (VM_shutdown (new_src_id, None))
in
perform_atomics atomics t
in
let final_handshake () =
Handshake.send vm_fd Handshake.Success ;
debug "VM.migrate: Synchronisation point 3" ;
Expand Down Expand Up @@ -2766,7 +2783,10 @@ and perform_exn ?subtask ?result (op : operation) (t : Xenops_task.task_handle)
the main VM migration sequence. *)
match VGPU_DB.ids id with
| [] ->
first_handshake () ; save () ; final_handshake ()
first_handshake () ;
save () ;
pause_src_vm () ;
final_handshake ()
| (_vm_id, dev_id) :: _ ->
let url =
make_url "/migrate/vgpu/"
Expand All @@ -2783,20 +2803,12 @@ and perform_exn ?subtask ?result (op : operation) (t : Xenops_task.task_handle)
first_handshake () ;
save ~vgpu_fd:(FD vgpu_fd) ()
) ;
pause_src_vm () ;
final_handshake ()
) ;
(* cleanup tmp src VM *)
let atomics =
[
VM_hook_script_stable
( id
, Xenops_hooks.VM_pre_destroy
, Xenops_hooks.reason__suspend
, new_src_id
)
]
@ atomics_of_operation (VM_shutdown (new_src_id, None))
@ [
let cleanup_src_vm () =
let atomics =
[
VM_hook_script_stable
( id
, Xenops_hooks.VM_post_destroy
Expand All @@ -2805,8 +2817,10 @@ and perform_exn ?subtask ?result (op : operation) (t : Xenops_task.task_handle)
)
; VM_remove new_src_id
]
in
perform_atomics atomics t
in
perform_atomics atomics t
cleanup_src_vm ()
| VM_receive_memory
{
vmr_id= id
Expand Down

0 comments on commit 4bf00f7

Please sign in to comment.