pidfile: string option; (* old xenstored compatibility *)
tracefile: string option; (* old xenstored compatibility *)
restart: bool;
+ disable_socket: bool;
}
let do_argv =
and daemonize = ref true
and reraise_top_level = ref false
and config_file = ref ""
- and restart = ref false in
+ and restart = ref false
+ and disable_socket = ref false in
let speclist =
[ ("--no-domain-init", Arg.Unit (fun () -> domain_init := false),
("--pid-file", Arg.Set_string pidfile, ""); (* for compatibility *)
("-T", Arg.Set_string tracefile, ""); (* for compatibility *)
("--restart", Arg.Set restart, "Read database on starting");
- ] in
- let usage_msg = "usage : xenstored [--config-file <filename>] [--no-domain-init] [--help] [--no-fork] [--reraise-top-level] [--restart]" in
+ ("--disable-socket", Arg.Unit (fun () -> disable_socket := true), "Disable socket");
+ ] in
+ let usage_msg = "usage : xenstored [--config-file <filename>] [--no-domain-init] [--help] [--no-fork] [--reraise-top-level] [--restart] [--disable-socket]" in
Arg.parse speclist (fun s -> ()) usage_msg;
{
domain_init = !domain_init;
config_file = if !config_file <> "" then Some !config_file else None;
pidfile = if !pidfile <> "" then Some !pidfile else None;
tracefile = if !tracefile <> "" then Some !tracefile else None;
- restart = !restart
+ restart = !restart;
+ disable_socket = !disable_socket;
}
let pidfile = parse_config (config_filename cf) in
Unixext.mkdir_rec (Filename.dirname pidfile) 0o755;
- let rw_sock = Unix.handle_unix_error Utils.create_unix_socket Define.xs_daemon_socket in
- let ro_sock = Unix.handle_unix_error Utils.create_unix_socket Define.xs_daemon_socket_ro in
+ let rw_sock, ro_sock =
+ if cf.disable_socket then
+ None, None
+ else
+ Some (Unix.handle_unix_error Utils.create_unix_socket Define.xs_daemon_socket),
+ Some (Unix.handle_unix_error Utils.create_unix_socket Define.xs_daemon_socket_ro)
+ in
if cf.daemonize then
Unixext.daemonize ();
Logging.init cf.activate_access_log (fun () -> DB.to_file store cons "/var/run/xenstored/db");
- let spec_fds = [ rw_sock; ro_sock ] @
- (if cf.domain_init then [ eventchn.Event.fd ] else []) in
+ let spec_fds =
+ (match rw_sock with None -> [] | Some x -> [ x ]) @
+ (match ro_sock with None -> [] | Some x -> [ x ]) @
+ (if cf.domain_init then [ eventchn.Event.fd ] else [])
+ in
let xc = Xc.interface_open () in
if List.mem fd set then
fct fd in
- do_if_set rw_sock rset (accept_connection true);
- do_if_set ro_sock rset (accept_connection false);
+ maybe (fun fd -> do_if_set fd rset (accept_connection true)) rw_sock;
+ maybe (fun fd -> do_if_set fd rset (accept_connection false)) ro_sock;
do_if_set eventchn.Event.fd rset (handle_eventchn)
in