debuggers.hg

view tools/console/daemon/main.c @ 6685:0922c82a4bf3

Exit if xen_setup fails.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Sep 06 18:18:56 2005 +0000 (2005-09-06)
parents dd668f7527cb
children 8db9c5873b9b
line source
1 /*\
2 * Copyright (C) International Business Machines Corp., 2005
3 * Author(s): Anthony Liguori <aliguori@us.ibm.com>
4 *
5 * Xen Console Daemon
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; under version 2 of the 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 General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 \*/
21 #include <getopt.h>
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <errno.h>
25 #include <unistd.h>
26 #include <sys/types.h>
28 #include "xenctrl.h"
30 #include "utils.h"
31 #include "io.h"
33 int main(int argc, char **argv)
34 {
35 const char *sopts = "hVvi";
36 struct option lopts[] = {
37 { "help", 0, 0, 'h' },
38 { "version", 0, 0, 'V' },
39 { "verbose", 0, 0, 'v' },
40 { "interactive", 0, 0, 'i' },
41 { 0 },
42 };
43 bool is_interactive = false;
44 int ch;
45 int syslog_option = LOG_CONS;
46 int syslog_mask = LOG_WARNING;
47 int opt_ind = 0;
49 while ((ch = getopt_long(argc, argv, sopts, lopts, &opt_ind)) != -1) {
50 switch (ch) {
51 case 'h':
52 //usage(argv[0]);
53 exit(0);
54 case 'V':
55 //version(argv[0]);
56 exit(0);
57 case 'v':
58 syslog_option |= LOG_PERROR;
59 syslog_mask = LOG_DEBUG;
60 break;
61 case 'i':
62 is_interactive = true;
63 break;
64 case '?':
65 fprintf(stderr,
66 "Try `%s --help' for more information\n",
67 argv[0]);
68 exit(EINVAL);
69 }
70 }
72 if (geteuid() != 0) {
73 fprintf(stderr, "%s requires root to run.\n", argv[0]);
74 exit(EPERM);
75 }
77 openlog("xenconsoled", syslog_option, LOG_DAEMON);
78 setlogmask(syslog_mask);
80 if (!is_interactive) {
81 daemonize("/var/run/xenconsoled.pid");
82 }
84 if (!xen_setup())
85 exit(1);
87 enum_domains();
89 handle_io();
91 closelog();
93 return 0;
94 }