Skip to content

Commit dd16f0b

Browse files
author
jeromemaloberti
committed
Merge pull request xapi-project#981 from jeromemaloberti/CA-94829-tampa-lcm
CA-94829: Set the TCP timeout properties on the migration fd
2 parents 3f9e87d + 68e3b03 commit dd16f0b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ocaml/xenguest/xenguest_main.ml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,22 @@ type ops = {
276276
domain_restore: Unix.file_descr -> int -> int -> int -> bool -> string;
277277
}
278278

279+
let tcp_keepcnt = 5
280+
let tcp_keepidle = 30
281+
let tcp_keepintvl = 2
282+
283+
(* CA-94829: Set the TCP keepalive options if it's a socket *)
284+
let fix_fd fd =
285+
let stats = Unix.fstat fd in
286+
if stats.Unix.st_kind = Unix.S_SOCK then begin
287+
Unix.setsockopt fd Unix.SO_KEEPALIVE true;
288+
Unixext.set_sock_keepalives fd tcp_keepcnt tcp_keepidle tcp_keepintvl;
289+
debug "Set socket TCP keepalive values to TCP_KEEPCNT=%d TCP_KEEPIDLE=%d TCP_KEEPINTVL=%d" tcp_keepcnt tcp_keepidle tcp_keepintvl
290+
end else begin
291+
debug "Skipping TCP keepalive setting as fd is not a socket"
292+
end
293+
294+
279295
(* main *)
280296
let _ =
281297
(* Union of all the options required by all modes: *)
@@ -370,7 +386,7 @@ let _ =
370386
and domid = int_of_string (get_param "domid")
371387
and flags = List.concat [ if has_param "live" then [ Xenguest.Live ] else [];
372388
if has_param "debug" then [ Xenguest.Debug ] else [] ] in
373-
389+
fix_fd fd;
374390
with_logging (fun () -> ops.domain_save fd domid 0 0 flags hvm)
375391
| Some "hvm_restore"
376392
| Some "restore" ->
@@ -382,6 +398,7 @@ let _ =
382398
and store_port = int_of_string (get_param "store_port")
383399
and console_port = int_of_string (get_param "console_port") in
384400

401+
fix_fd fd;
385402
with_logging (fun () -> ops.domain_restore fd domid store_port console_port hvm)
386403
| Some "linux_build" ->
387404
debug "linux_build mode selected";

0 commit comments

Comments
 (0)