1(* 2 * Copyright (C) 2006-2007 XenSource Ltd. 3 * Copyright (C) 2008 Citrix Ltd. 4 * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as published 8 * by the Free Software Foundation; version 2.1 only. with the special 9 * exception on linking described in file LICENSE. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 *) 16 17type config = 18{ 19 domain_init: bool; 20 activate_access_log: bool; 21 daemonize: bool; 22 reraise_top_level: bool; 23 config_file: string option; 24 pidfile: string option; (* old xenstored compatibility *) 25 tracefile: string option; (* old xenstored compatibility *) 26 restart: bool; 27 disable_socket: bool; 28 use_select: bool; 29} 30 31let do_argv = 32 let pidfile = ref "" and tracefile = ref "" (* old xenstored compatibility *) 33 and domain_init = ref true 34 and activate_access_log = ref true 35 and daemonize = ref true 36 and reraise_top_level = ref false 37 and config_file = ref "" 38 and restart = ref false 39 and disable_socket = ref false 40 and use_select = ref false in 41 42 let speclist = 43 [ ("--no-domain-init", Arg.Unit (fun () -> domain_init := false), 44 "to state that xenstored should not initialise dom0"); 45 ("--config-file", Arg.Set_string config_file, 46 "set an alternative location for the configuration file"); 47 ("--no-fork", Arg.Unit (fun () -> daemonize := false), 48 "to request that the daemon does not fork"); 49 ("--reraise-top-level", Arg.Unit (fun () -> reraise_top_level := true), 50 "reraise exceptions caught at the top level"); 51 ("--no-access-log", Arg.Unit (fun () -> activate_access_log := false), 52 "do not create a xenstore-access.log file"); 53 ("--pid-file", Arg.Set_string pidfile, ""); (* for compatibility *) 54 ("-T", Arg.Set_string tracefile, ""); (* for compatibility *) 55 ("--restart", Arg.Set restart, "Read database on starting"); 56 ("--disable-socket", Arg.Unit (fun () -> disable_socket := true), "Disable socket"); 57 ("--use-select", Arg.Unit (fun () -> use_select := true), "Use select instead of poll"); (* for backward compatibility and testing *) 58 ] in 59 let usage_msg = "usage : xenstored [--config-file <filename>] [--no-domain-init] [--help] [--no-fork] [--reraise-top-level] [--restart] [--disable-socket] [--use-select]" in 60 Arg.parse speclist (fun s -> ()) usage_msg; 61 { 62 domain_init = !domain_init; 63 activate_access_log = !activate_access_log; 64 daemonize = !daemonize; 65 reraise_top_level = !reraise_top_level; 66 config_file = if !config_file <> "" then Some !config_file else None; 67 pidfile = if !pidfile <> "" then Some !pidfile else None; 68 tracefile = if !tracefile <> "" then Some !tracefile else None; 69 restart = !restart; 70 disable_socket = !disable_socket; 71 use_select = !use_select; 72 } 73