From a2f34417d3014b229c4be27046051e194635ed36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Sun, 21 Apr 2024 20:54:42 +0100 Subject: [PATCH] CP-51693: feat(use-xmlrpc): [perf] use JSONRPC instead of XMLRPC for internal communication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Feature flag: use-xmlrpc Signed-off-by: Edwin Török --- ocaml/tests/common/mock_rpc.ml | 2 +- ocaml/xapi/helpers.ml | 10 ++++++++-- ocaml/xapi/xapi_globs.ml | 7 +++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ocaml/tests/common/mock_rpc.ml b/ocaml/tests/common/mock_rpc.ml index 808308afb1c..9edf87897e7 100644 --- a/ocaml/tests/common/mock_rpc.ml +++ b/ocaml/tests/common/mock_rpc.ml @@ -25,7 +25,7 @@ let rpc __context call = Rpc. { success= true - ; contents= contents |> Xmlrpc.to_string |> Xmlrpc.of_string + ; contents= contents |> Jsonrpc.to_string |> Jsonrpc.of_string ; is_notification= false } | "VM.update_allowed_operations", [session_id_rpc; self_rpc] -> diff --git a/ocaml/xapi/helpers.ml b/ocaml/xapi/helpers.ml index 30965068f3f..d0edcb075a6 100644 --- a/ocaml/xapi/helpers.ml +++ b/ocaml/xapi/helpers.ml @@ -395,7 +395,13 @@ let make_rpc ~__context rpc : Rpc.response = let subtask_of = Ref.string_of (Context.get_task_id __context) in let open Xmlrpc_client in let tracing = Context.set_client_span __context in - let http = xmlrpc ~subtask_of ~version:"1.1" "/" ~tracing in + let dorpc, path = + if !Xapi_globs.use_xmlrpc then + (XMLRPC_protocol.rpc, "/") + else + (JSONRPC_protocol.rpc, "/jsonrpc") + in + let http = xmlrpc ~subtask_of ~version:"1.1" path ~tracing in let transport = if Pool_role.is_master () then Unix Xapi_globs.unix_domain_socket @@ -407,7 +413,7 @@ let make_rpc ~__context rpc : Rpc.response = , !Constants.https_port ) in - XMLRPC_protocol.rpc ~srcstr:"xapi" ~dststr:"xapi" ~transport ~http rpc + dorpc ~srcstr:"xapi" ~dststr:"xapi" ~transport ~http rpc let make_timeboxed_rpc ~__context timeout rpc : Rpc.response = let subtask_of = Ref.string_of (Context.get_task_id __context) in diff --git a/ocaml/xapi/xapi_globs.ml b/ocaml/xapi/xapi_globs.ml index efdcabfbdb6..d59af9e2e49 100644 --- a/ocaml/xapi/xapi_globs.ml +++ b/ocaml/xapi/xapi_globs.ml @@ -1025,6 +1025,8 @@ let max_spans = ref 10000 let max_traces = ref 10000 +let use_xmlrpc = ref true + let compress_tracing_files = ref true let prefer_nbd_attach = ref false @@ -1436,6 +1438,11 @@ let other_options = , (fun () -> string_of_bool !allow_host_sched_gran_modification) , "Allows to modify the host's scheduler granularity" ) + ; ( "use-xmlrpc" + , Arg.Set use_xmlrpc + , (fun () -> string_of_bool !use_xmlrpc) + , "Use XMLRPC (deprecated) for internal communication or JSONRPC" + ) ; ( "extauth_ad_backend" , Arg.Set_string extauth_ad_backend , (fun () -> !extauth_ad_backend)