From 8fa8073640bd30280f0a59e3932a0354ac362158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Thu, 30 May 2024 18:28:54 +0100 Subject: [PATCH] xapi.conf: introduce test_open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default is 0 but can be set to 1024 to test for the absence of Unix.select. Signed-off-by: Edwin Török --- ocaml/xapi/xapi.ml | 9 +++++++++ ocaml/xapi/xapi_globs.ml | 3 +++ ocaml/xenopsd/lib/xenopsd.ml | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/ocaml/xapi/xapi.ml b/ocaml/xapi/xapi.ml index 105fd9db581..0323327779d 100644 --- a/ocaml/xapi/xapi.ml +++ b/ocaml/xapi/xapi.ml @@ -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) *) diff --git a/ocaml/xapi/xapi_globs.ml b/ocaml/xapi/xapi_globs.ml index 0e2fe61e605..3f5517faf47 100644 --- a/ocaml/xapi/xapi_globs.ml +++ b/ocaml/xapi/xapi_globs.ml @@ -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" @@ -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 diff --git a/ocaml/xenopsd/lib/xenopsd.ml b/ocaml/xenopsd/lib/xenopsd.ml index 98c88561572..2052d367585 100644 --- a/ocaml/xenopsd/lib/xenopsd.ml +++ b/ocaml/xenopsd/lib/xenopsd.ml @@ -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" @@ -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" @@ -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 *)