]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
xenstored: add a disable socket option.
authorVincent Hanquez <vincent.hanquez@eu.citrix.com>
Tue, 7 Apr 2009 11:21:56 +0000 (12:21 +0100)
committerVincent Hanquez <vincent.hanquez@eu.citrix.com>
Tue, 7 Apr 2009 11:21:56 +0000 (12:21 +0100)
xenstored/parse_arg.ml
xenstored/xenstored.ml

index 86d06d2e649948d82fb77f167a612b40880bb609..5d216010447d77360f98731d5cf56b093cf99c3c 100644 (file)
@@ -24,6 +24,7 @@ type config =
        pidfile: string option; (* old xenstored compatibility *)
        tracefile: string option; (* old xenstored compatibility *)
        restart: bool;
+       disable_socket: bool;
 }
 
 let do_argv =
@@ -33,7 +34,8 @@ 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),
@@ -49,8 +51,9 @@ let do_argv =
                  ("--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;
@@ -60,5 +63,6 @@ let do_argv =
                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;
        }
index be4e6365799e94f3ae91a6fba1a67137a6875ffc..1fc43cf1fead2b2d0559efa651bb04c31840c914 100644 (file)
@@ -228,8 +228,13 @@ let _ =
        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 ();
@@ -278,8 +283,11 @@ let _ =
 
        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
 
@@ -302,8 +310,8 @@ let _ =
                        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