Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ ocaml/fhs.ml :
let inventory=\"$(INVENTORY)\"\n \
let hooksdir=\"$(HOOKSDIR)\"\n \
let libexecdir=\"$(LIBEXECDIR)\"\n \
let xapiconf=\"$(XAPICONF)\"\n \
let scriptsdir=\"$(SCRIPTSDIR)\"\n \
let varpatchdir=\"$(VARPATCHDIR)\"\n \
let webdir=\"$(WEBDIR)\"\n \
Expand Down
6 changes: 0 additions & 6 deletions ocaml/idl/constants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,5 @@ let storage_migrate_vdi_map_key = "maps_to"
(* Used to specify mapping of VIFs to networks on the remote machine. Stored in VIF.other_config *)
let storage_migrate_vif_map_key = "maps_to"

(* Path to the pool configuration file. *)
let pool_config_file = Filename.concat Fhs.etcdir "pool.conf"

(* Path to the pool secret file. *)
let pool_secret_path = Filename.concat Fhs.etcdir "ptoken"

(* Abstract size value for tracking PGPU utilisation. *)
let pgpu_default_size = Int64.mul 1024L 1024L
5 changes: 3 additions & 2 deletions ocaml/pool_role_shared.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type t =
let role = ref None
let role_unit_tests = ref false
let role_m = Mutex.create ()
let filename = ref (Filename.concat Fhs.etcdir "pool.conf")

let set_pool_role_for_test () =
Mutex.execute role_m (fun _ -> role := Some Master;
Expand All @@ -46,7 +47,7 @@ let string_of = function
let read_pool_role () =
try
let s = String.strip String.isspace
(Unixext.string_of_file Constants.pool_config_file) in
(Unixext.string_of_file !filename) in
match String.split ~limit:2 ':' s with
| [ "master" ] -> Master
| [ "slave"; m_ip ] -> Slave m_ip
Expand All @@ -58,7 +59,7 @@ let read_pool_role () =
then (debug "Executable name is not 'xapi', so we must be running \
in unit-test mode; setting pool-role to 'Master'";
Master)
else (error "Failed to read pool role from %s" Constants.pool_config_file;
else (error "Failed to read pool role from %s" !filename;
Broken)

let get_role () =
Expand Down
4 changes: 2 additions & 2 deletions ocaml/rrdd/rrdd_shared.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ let cache_sr_lock = Mutex.create ()
(** Pool secret. *)
let get_pool_secret () =
try
Unix.access Constants.pool_secret_path [Unix.F_OK];
Unixext.string_of_file Constants.pool_secret_path
Unix.access !pool_secret_path [Unix.F_OK];
Unixext.string_of_file !Xapi_globs.pool_secret_path
with _ ->
failwith "Unable to read the pool secret."

Expand Down
33 changes: 0 additions & 33 deletions ocaml/util/config_shared.ml

This file was deleted.

1 change: 0 additions & 1 deletion ocaml/xapi/OMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ XAPI_MODULES = $(COMMON) \
../license/v6rpc \
../license/v6errors \
bios_strings \
../util/config_shared \
xapi_config \
features \
pool_features \
Expand Down
6 changes: 3 additions & 3 deletions ocaml/xapi/helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,12 @@ let lookup_vdi_fields f vdi_refs l =
(* Read pool secret if it exists; otherwise, create a new one. *)
let get_pool_secret () =
try
Unix.access Constants.pool_secret_path [Unix.F_OK];
pool_secret := Unixext.string_of_file Constants.pool_secret_path
Unix.access !Xapi_globs.pool_secret_path [Unix.F_OK];
pool_secret := Unixext.string_of_file !Xapi_globs.pool_secret_path
with _ -> (* No pool secret exists. *)
let mk_rand_string () = Uuid.to_string (Uuid.make_uuid()) in
pool_secret := (mk_rand_string()) ^ "/" ^ (mk_rand_string()) ^ "/" ^ (mk_rand_string());
Unixext.write_string_to_file Constants.pool_secret_path !pool_secret
Unixext.write_string_to_file !Xapi_globs.pool_secret_path !pool_secret

(* Checks that a host has a PBD for a particular SR (meaning that the
SR is visible to the host) *)
Expand Down
3 changes: 2 additions & 1 deletion ocaml/xapi/pool_role.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ open Threadext
include Pool_role_shared

let set_role r =
filename := !Xapi_globs.pool_config_file;
let old_role = get_role () in
Mutex.execute role_m
(fun () ->
Unixext.write_string_to_file Constants.pool_config_file (string_of r));
Unixext.write_string_to_file !Xapi_globs.pool_config_file (string_of r));
Localdb.put Constants.this_node_just_became_master (string_of_bool (old_role <> Master && r = Master))
37 changes: 10 additions & 27 deletions ocaml/xapi/xapi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,10 @@ let register_callback_fns() =
Pervasiveext.exnhook := Some (fun _ -> log_backtrace ());
TaskHelper.init ()

let nowatchdog = ref false

let noevents = ref false
let debug_dummy_data = ref false

(** Start the XML-RPC server. *)
let daemonize = ref false

let show_version () =
List.iter (fun (x, y) -> printf "%s=%s\n" x y)
[ "git_id", Version.git_id;
Expand All @@ -219,22 +216,7 @@ let init_args() =
Debug.name_thread "thread_zero";
(* Immediately register callback functions *)
register_callback_fns();
Arg.parse [
"-daemon", Arg.Set daemonize, "run as a daemon in the background";
"-config", Arg.Set_string Xapi_globs.config_file, "set config file to use";
"-logconfig", Arg.Set_string Xapi_globs.log_config_file, "set log config file to use";
"-writereadyfile", Arg.Set_string Xapi_globs.ready_file, "touch specified file when xapi is ready to accept requests";
"-writeinitcomplete", Arg.Set_string Xapi_globs.init_complete, "touch specified file when xapi init process is complete";
"-nowatchdog", Arg.Set nowatchdog, "turn watchdog off, avoiding initial fork";
"-setdom0mem", Arg.Unit (fun () -> ()), "(ignored)";
"-dom0memgradient", Arg.Unit (fun () -> ()), "(ignored)";
"-dom0memintercept", Arg.Unit (fun () -> ()), "(ignored)";
"-onsystemboot", Arg.Set Xapi_globs.on_system_boot, "indicates that this server start is the first since the host rebooted";
"-noevents", Arg.Set noevents, "turn event thread off for debugging -leaves crashed guests undestroyed";
"-dummydata", Arg.Set debug_dummy_data, "populate with dummy data for demo/debugging purposes";
"-version", Arg.Unit show_version, "show version of the binary"
] (fun x -> printf "Warning, ignoring unknown argument: %s" x)
"XenAPI server"
Xcp_service.configure ~options:Xapi_globs.all_options ~resources:Xapi_globs.resources ()

let wait_to_die() =
(* don't call Thread.join cos this interacts strangely with OCAML runtime and stops
Expand Down Expand Up @@ -791,8 +773,6 @@ let server_init() =
try
Server_helpers.exec_with_new_task "server_init" (fun __context ->
Startup.run ~__context [
"Reading config file", [], (fun () -> Xapi_config.read_config !Xapi_globs.config_file);
"Reading external global variables definition", [ Startup.NoExnRaising ], Xapi_globs.read_external_config;
"XAPI SERVER STARTING", [], print_server_starting_message;
"Parsing inventory file", [], Xapi_inventory.read_inventory;
"Initialising local database", [], init_local_database;
Expand Down Expand Up @@ -982,7 +962,7 @@ let delay_on_eintr f =
| e -> raise e

let watchdog f =
if !nowatchdog then begin
if !Xapi_globs.nowatchdog then begin
try
ignore(Unix.sigprocmask Unix.SIG_UNBLOCK [Sys.sigint]);
delay_on_eintr f;
Expand Down Expand Up @@ -1013,15 +993,18 @@ let watchdog f =
let cmd = Sys.argv.(0) in

let overriden_args = [ "-onsystemboot"; "-daemon" ] in
let overriden_args1 = [ "-daemon" ] in
let core_args =
List.filter (fun x -> not(List.mem x overriden_args))
(List.tl (Array.to_list Sys.argv)) in
List.rev(fst(List.fold_left (fun (acc, delete_next) x ->
let acc = if List.mem x overriden_args || delete_next then acc else x :: acc in
let delete_next = List.mem x overriden_args1 in
acc, delete_next
) ([], false) (List.tl (Array.to_list Sys.argv)))) in

let args =
"-nowatchdog" :: core_args
@ (if !Xapi_globs.on_system_boot then [ "-onsystemboot" ] else []) in

let newpid = Forkhelpers.safe_close_and_exec ~env:(Unix.environment ()) None None None [] cmd args in

(* parent just reset the sighandler *)
Sys.set_signal Sys.sigterm (Sys.Signal_handle (fun i -> restart := false; Unix.kill (Forkhelpers.getpid newpid) Sys.sigterm));
pid := Some newpid;
Expand Down
16 changes: 0 additions & 16 deletions ocaml/xapi/xapi_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@ open Stringext
module D=Debug.Make(struct let name="xapi" end)
open D

let read_config filename =
let configargs = [
"use-xenopsd", Config.Set_bool Xapi_globs.use_xenopsd;
Config_shared.disable_logging_for;
"relax-xsm-sr-check", Config.Set_bool Xapi_globs.relax_xsm_sr_check;
] in
try
Config.read filename configargs (fun _ _ -> ())
with
| Config.Error ls ->
List.iter (fun (p,s) ->
eprintf "config file error: %s: %s\n" p s) ls;
exit 2
| _ ->
eprintf "Ignoring missing config file"

let log_if_not_empty format_string value =
if value <> "" then debug format_string value

Expand Down
Loading