Skip to content

Commit

Permalink
xapi.conf: introduce test_open
Browse files Browse the repository at this point in the history
Default is 0 but can be set to 1024 to test for the absence of Unix.select.

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed May 30, 2024
1 parent 3cfff61 commit 8fa8073
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ocaml/xapi/xapi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -922,12 +922,21 @@ let report_tls_verification ~__context =
let value = Stunnel_client.get_verify_by_default () in
Db.Host.set_tls_verification_enabled ~__context ~self ~value

let test_open () =
let count = !Xapi_globs.test_open in
if count > 0 then begin
debug "TEST: opening %d file descriptors" count;
Xapi_stdext_unix.Unixext.test_open count;
debug "TEST: opened %d files" count
end

let server_init () =
let print_server_starting_message () =
debug "(Re)starting xapi, pid: %d" (Unix.getpid ()) ;
debug "on_system_boot=%b pool_role=%s" !Xapi_globs.on_system_boot
(Pool_role.string_of (Pool_role.get_role ()))
in
test_open ();
Unixext.unlink_safe "/etc/xensource/boot_time_info_updated" ;
(* Record the initial value of Master_connection.connection_timeout and set it to 'never'. When we are a slave who
has just started up we want to wait forever for the master to appear. (See CA-25481) *)
Expand Down
3 changes: 3 additions & 0 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,8 @@ let python3_path = ref "/usr/bin/python3"
let observer_experimental_components =
ref (StringSet.singleton Constants.observer_component_smapi)

let test_open = ref 0

let xapi_globs_spec =
[
( "master_connection_reset_timeout"
Expand Down Expand Up @@ -1114,6 +1116,7 @@ let xapi_globs_spec =
; ("max_spans", Int max_spans)
; ("max_traces", Int max_traces)
; ("max_observer_file_size", Int max_observer_file_size)
; ("test_open", Int test_open)
]

let timeout ref str = ref := Xapi_stdext_unix.Unixext.Timeout.of_string str
Expand Down
16 changes: 16 additions & 0 deletions ocaml/xenopsd/lib/xenopsd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ let max_bytes_of_xenstore_entries entries =

let vm_guest_agent_xenstore_quota_bytes = ref (25 * 1024 * 1024)

let test_open = ref 0

let options =
[
( "queue"
Expand Down Expand Up @@ -276,6 +278,11 @@ let options =
, "Maximum size in bytes of VM xenstore-data field, and guest metrics \
copied from guest's vm-data/ and data/ xenstore tree"
)
; ( "test-open"
, Arg.Set_int test_open
, (fun () -> string_of_int !test_open)
, "TESTING only: open N file descriptors"
)
]

let path () = Filename.concat !sockets_path "xenopsd"
Expand Down Expand Up @@ -424,9 +431,18 @@ let log_uncaught_exception e bt =
error "xenopsd exitted with an uncaught exception: %s" (Printexc.to_string e) ;
log_raw_backtrace bt

let test_open () =
let count = !test_open in
if count > 0 then (
debug "TEST: opening %d file descriptors" count ;
Xapi_stdext_unix.Unixext.test_open count ;
debug "TEST: opened %d file descriptors" count
)

let main backend =
Printexc.record_backtrace true ;
Printexc.set_uncaught_exception_handler log_uncaught_exception ;
test_open () ;
(* Set service name for Tracing *)
Tracing_export.set_service_name "xenopsd" ;
(* Listen for transferred file descriptors *)
Expand Down

0 comments on commit 8fa8073

Please sign in to comment.