Skip to content

Commit 01547ec

Browse files
committed
CP-311102: Make migration timeouts configurable
Also improve the logging a little (e.g. log "suspend" rather than "shutdown" when suspending). Signed-off-by: Rob Hoes <[email protected]>
1 parent 2a05f49 commit 01547ec

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

ocaml/xenopsd/lib/xenopsd.ml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ let vm_guest_agent_xenstore_quota = ref 128
7777

7878
let vm_guest_agent_xenstore_quota_warn_interval = ref 3600
7979

80+
let vm_suspend_timeout = ref 1200.
81+
82+
let vm_suspend_ack_timeout = ref 30.
83+
8084
let oxenstored_conf = ref "/etc/xen/oxenstored.conf"
8185

8286
let for_each_line path f =
@@ -320,6 +324,17 @@ let options =
320324
, (fun () -> string_of_bool !Xenops_server.xenopsd_vbd_plug_unplug_legacy)
321325
, "False if we want to split the plug atomic into attach/activate"
322326
)
327+
; ( "vm-suspend-timeout"
328+
, Arg.Set_float vm_suspend_timeout
329+
, (fun () -> string_of_float !vm_suspend_timeout)
330+
, "Time in seconds within a VM is expected to suspend after acknowledging \
331+
the suspend request"
332+
)
333+
; ( "vm-suspend-ack-timeout"
334+
, Arg.Set_float vm_suspend_ack_timeout
335+
, (fun () -> string_of_float !vm_suspend_ack_timeout)
336+
, "Time in seconds within a VM is expected to acknowledge a suspend request"
337+
)
323338
]
324339

325340
let path () = Filename.concat !sockets_path "xenopsd"

ocaml/xenopsd/xc/domain.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,11 @@ let shutdown_wait_for_ack (t : Xenops_task.task_handle) ~timeout ~xc ~xs domid
778778
Xenctrl.domain_shutdown xc domid (shutdown_to_xc_shutdown req)
779779
) else (
780780
debug
781-
"VM = %s; domid = %d; Waiting for domain to acknowledge shutdown request"
782-
uuid domid ;
781+
"VM = %s; domid = %d; Waiting for domain to acknowledge %s request \
782+
(timeout = %.0fs)"
783+
uuid domid
784+
(string_of_shutdown_reason req)
785+
timeout ;
783786
let path = control_shutdown ~xs domid in
784787
let cancel = Domain domid in
785788
if
@@ -788,8 +791,8 @@ let shutdown_wait_for_ack (t : Xenops_task.task_handle) ~timeout ~xc ~xs domid
788791
[Watch.key_to_disappear path]
789792
t ~xs ~timeout ()
790793
then
791-
info "VM = %s; domid = %d; Domain acknowledged shutdown request" uuid
792-
domid
794+
info "VM = %s; domid = %d; Domain acknowledged %s request" uuid domid
795+
(string_of_shutdown_reason req)
793796
else
794797
debug "VM = %s; domid = %d; Domain disappeared" uuid domid
795798
)

ocaml/xenopsd/xc/xenops_server_xen.ml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,7 +2712,7 @@ module VM = struct
27122712
with Watch.Timeout _ -> false
27132713
)
27142714

2715-
let wait_shutdown task vm _reason timeout =
2715+
let wait_shutdown task vm reason timeout =
27162716
let is_vm_event = function
27172717
| Dynamic.Vm id when id = vm.Vm.id ->
27182718
debug "EVENT on our VM: %s" id ;
@@ -2859,7 +2859,9 @@ module VM = struct
28592859
not
28602860
( with_tracing ~task
28612861
~name:"VM_save_domain_suspend_callback_request_shutdown"
2862-
@@ fun () -> request_shutdown task vm Suspend 30.
2862+
@@ fun () ->
2863+
request_shutdown task vm Suspend
2864+
!Xenopsd.vm_suspend_ack_timeout
28632865
)
28642866
then
28652867
raise (Xenopsd_error Failed_to_acknowledge_suspend_request) ;
@@ -2870,14 +2872,25 @@ module VM = struct
28702872
| _ ->
28712873
()
28722874
) ;
2875+
let suspend_timeout = !Xenopsd.vm_suspend_timeout in
28732876
if
28742877
not
28752878
( with_tracing ~task
28762879
~name:"VM_save_domain_suspend_callback_wait_shutdown"
2877-
@@ fun () -> wait_shutdown task vm Suspend 1200.
2880+
@@ fun () ->
2881+
debug
2882+
"VM = %s; domid = %d; Waiting for domain to suspend \
2883+
(timeout = %.0fs)"
2884+
vm.Vm.id domid suspend_timeout ;
2885+
wait_shutdown task vm Suspend suspend_timeout
28782886
)
28792887
then
2880-
raise (Xenopsd_error (Failed_to_suspend (vm.Vm.id, 1200.)))
2888+
raise
2889+
(Xenopsd_error
2890+
(Failed_to_suspend (vm.Vm.id, suspend_timeout))
2891+
)
2892+
else
2893+
debug "VM = %s; domid = %d; Domain suspended" vm.Vm.id domid
28812894
) ;
28822895
(* Record the final memory usage of the domain so we know how much
28832896
to allocate for the resume *)

0 commit comments

Comments
 (0)