Commit 441e4963 by Michel Normand Committed by Daniel Lezcano

add quiet option

This added quiet option allow to disable the reporting via stderr of the lxc error messages. Note that the usage function is still printing in case of error, but will be removed by later patches Signed-off-by: 's avatarMichel Normand <normand@fr.ibm.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent fcffb59f
...@@ -97,7 +97,7 @@ static struct lxc_log_appender log_appender_stderr = { ...@@ -97,7 +97,7 @@ static struct lxc_log_appender log_appender_stderr = {
static struct lxc_log_appender log_appender_logfile = { static struct lxc_log_appender log_appender_logfile = {
.name = "logfile", .name = "logfile",
.append = log_append_logfile, .append = log_append_logfile,
.next = &log_appender_stderr, .next = NULL,
}; };
static struct lxc_log_category log_root = { static struct lxc_log_category log_root = {
...@@ -147,7 +147,7 @@ static int log_open(const char *name) ...@@ -147,7 +147,7 @@ static int log_open(const char *name)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
extern int lxc_log_init(const char *file, const char *priority, extern int lxc_log_init(const char *file, const char *priority,
const char *prefix) const char *prefix, int quiet)
{ {
int lxc_priority = LXC_LOG_PRIORITY_ERROR; int lxc_priority = LXC_LOG_PRIORITY_ERROR;
...@@ -162,6 +162,9 @@ extern int lxc_log_init(const char *file, const char *priority, ...@@ -162,6 +162,9 @@ extern int lxc_log_init(const char *file, const char *priority,
lxc_log_category_lxc.priority = lxc_priority; lxc_log_category_lxc.priority = lxc_priority;
if (!quiet)
lxc_log_category_lxc.appender->next = &log_appender_stderr;
if (prefix) if (prefix)
lxc_log_setprefix(prefix); lxc_log_setprefix(prefix);
......
...@@ -286,5 +286,5 @@ extern struct lxc_log_category lxc_log_category_lxc; ...@@ -286,5 +286,5 @@ extern struct lxc_log_category lxc_log_category_lxc;
} while (0) } while (0)
extern int lxc_log_init(const char *file, const char *priority, extern int lxc_log_init(const char *file, const char *priority,
const char *prefix); const char *prefix, int quiet);
#endif #endif
...@@ -36,6 +36,7 @@ void usage(char *cmd) ...@@ -36,6 +36,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container\n"); fprintf(stderr, "\t -n <name> : name of the container\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -45,6 +46,7 @@ int main(int argc, char *argv[]) ...@@ -45,6 +46,7 @@ int main(int argc, char *argv[])
char *name = NULL, *subsystem = NULL, *value = NULL; char *name = NULL, *subsystem = NULL, *value = NULL;
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
int nbargs = 0; int nbargs = 0;
int quiet = 0;
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
switch (opt) { switch (opt) {
...@@ -57,6 +59,9 @@ int main(int argc, char *argv[]) ...@@ -57,6 +59,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -65,7 +70,7 @@ int main(int argc, char *argv[]) ...@@ -65,7 +70,7 @@ int main(int argc, char *argv[])
if (!name || (argc-optind) < 1) if (!name || (argc-optind) < 1)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
if ((argc -optind) >= 1) if ((argc -optind) >= 1)
......
...@@ -33,6 +33,7 @@ void usage(char *cmd) ...@@ -33,6 +33,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container\n"); fprintf(stderr, "\t -n <name> : name of the container\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -44,6 +45,7 @@ int main(int argc, char *argv[]) ...@@ -44,6 +45,7 @@ int main(int argc, char *argv[])
int stop = 0; int stop = 0;
int nbargs = 0; int nbargs = 0;
int ret = 1; int ret = 1;
int quiet = 0;
while ((opt = getopt(argc, argv, "sn:o:l:")) != -1) { while ((opt = getopt(argc, argv, "sn:o:l:")) != -1) {
switch (opt) { switch (opt) {
...@@ -59,6 +61,9 @@ int main(int argc, char *argv[]) ...@@ -59,6 +61,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -70,7 +75,7 @@ int main(int argc, char *argv[]) ...@@ -70,7 +75,7 @@ int main(int argc, char *argv[])
if (!argv[1]) if (!argv[1])
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return -1; return -1;
if (lxc_freeze(name)) if (lxc_freeze(name))
......
...@@ -50,6 +50,7 @@ void usage(char *cmd) ...@@ -50,6 +50,7 @@ void usage(char *cmd)
fprintf(stderr, "\t [-t <tty#>] : tty number\n"); fprintf(stderr, "\t [-t <tty#>] : tty number\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -57,6 +58,7 @@ int main(int argc, char *argv[]) ...@@ -57,6 +58,7 @@ int main(int argc, char *argv[])
{ {
char *name = NULL; char *name = NULL;
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
int quiet = 0;
int opt; int opt;
int nbargs = 0; int nbargs = 0;
int master = -1; int master = -1;
...@@ -80,6 +82,9 @@ int main(int argc, char *argv[]) ...@@ -80,6 +82,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -88,7 +93,7 @@ int main(int argc, char *argv[]) ...@@ -88,7 +93,7 @@ int main(int argc, char *argv[])
if (!name) if (!name)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
/* Get current termios */ /* Get current termios */
......
...@@ -41,6 +41,7 @@ void usage(char *cmd) ...@@ -41,6 +41,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -f <confile> : path of the configuration file\n"); fprintf(stderr, "\t -f <confile> : path of the configuration file\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -50,8 +51,9 @@ int main(int argc, char *argv[]) ...@@ -50,8 +51,9 @@ int main(int argc, char *argv[])
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
struct lxc_conf lxc_conf; struct lxc_conf lxc_conf;
int err, opt; int err, opt;
int quiet = 0;
while ((opt = getopt(argc, argv, "f:n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "f:n:o:l:q")) != -1) {
switch (opt) { switch (opt) {
case 'n': case 'n':
name = optarg; name = optarg;
...@@ -65,13 +67,16 @@ int main(int argc, char *argv[]) ...@@ -65,13 +67,16 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
} }
if (!name) if (!name)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
if (lxc_conf_init(&lxc_conf)) if (lxc_conf_init(&lxc_conf))
......
...@@ -33,6 +33,7 @@ void usage(char *cmd) ...@@ -33,6 +33,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container\n"); fprintf(stderr, "\t -n <name> : name of the container\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -43,6 +44,7 @@ int main(int argc, char *argv[]) ...@@ -43,6 +44,7 @@ int main(int argc, char *argv[])
int opt; int opt;
int nbargs = 0; int nbargs = 0;
int err; int err;
int quiet = 0;
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
switch (opt) { switch (opt) {
...@@ -55,6 +57,9 @@ int main(int argc, char *argv[]) ...@@ -55,6 +57,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -63,7 +68,7 @@ int main(int argc, char *argv[]) ...@@ -63,7 +68,7 @@ int main(int argc, char *argv[])
if (!name) if (!name)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
err = lxc_destroy(name); err = lxc_destroy(name);
......
...@@ -42,6 +42,7 @@ void usage(char *cmd) ...@@ -42,6 +42,7 @@ void usage(char *cmd)
fprintf(stderr, "\t [-f <confile>] : path of the configuration file\n"); fprintf(stderr, "\t [-f <confile>] : path of the configuration file\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -55,9 +56,10 @@ int main(int argc, char *argv[]) ...@@ -55,9 +56,10 @@ int main(int argc, char *argv[])
int nbargs = 0; int nbargs = 0;
int autodestroy = 0; int autodestroy = 0;
int ret = 1; int ret = 1;
int quiet = 0;
struct lxc_conf lxc_conf; struct lxc_conf lxc_conf;
while ((opt = getopt(argc, argv, "f:n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "f:n:o:l:q")) != -1) {
switch (opt) { switch (opt) {
case 'n': case 'n':
name = optarg; name = optarg;
...@@ -71,6 +73,9 @@ int main(int argc, char *argv[]) ...@@ -71,6 +73,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -81,7 +86,7 @@ int main(int argc, char *argv[]) ...@@ -81,7 +86,7 @@ int main(int argc, char *argv[])
argc -= nbargs; argc -= nbargs;
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
goto out; goto out;
if (lxc_conf_init(&lxc_conf)) if (lxc_conf_init(&lxc_conf))
......
...@@ -34,6 +34,7 @@ void usage(char *cmd) ...@@ -34,6 +34,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container\n"); fprintf(stderr, "\t -n <name> : name of the container\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -43,6 +44,7 @@ int main(int argc, char *argv[]) ...@@ -43,6 +44,7 @@ int main(int argc, char *argv[])
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
int opt; int opt;
int nbargs = 0; int nbargs = 0;
int quiet = 0;
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
switch (opt) { switch (opt) {
...@@ -55,6 +57,9 @@ int main(int argc, char *argv[]) ...@@ -55,6 +57,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -63,7 +68,7 @@ int main(int argc, char *argv[]) ...@@ -63,7 +68,7 @@ int main(int argc, char *argv[])
if (!name) if (!name)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
if (lxc_freeze(name)) if (lxc_freeze(name))
......
...@@ -33,6 +33,7 @@ void usage(char *cmd) ...@@ -33,6 +33,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container\n"); fprintf(stderr, "\t -n <name> : name of the container\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -41,6 +42,7 @@ int main(int argc, char *argv[]) ...@@ -41,6 +42,7 @@ int main(int argc, char *argv[])
char *name = NULL; char *name = NULL;
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
int opt, state, nbargs = 0; int opt, state, nbargs = 0;
int quiet = 0;
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
switch (opt) { switch (opt) {
...@@ -53,6 +55,9 @@ int main(int argc, char *argv[]) ...@@ -53,6 +55,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -61,7 +66,7 @@ int main(int argc, char *argv[]) ...@@ -61,7 +66,7 @@ int main(int argc, char *argv[])
if (!name) if (!name)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
state = lxc_getstate(name); state = lxc_getstate(name);
......
...@@ -37,6 +37,7 @@ void usage(char *cmd) ...@@ -37,6 +37,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container or regular expression\n"); fprintf(stderr, "\t -n <name> : name of the container or regular expression\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -48,8 +49,9 @@ int main(int argc, char *argv[]) ...@@ -48,8 +49,9 @@ int main(int argc, char *argv[])
struct lxc_msg msg; struct lxc_msg msg;
regex_t preg; regex_t preg;
int fd, opt; int fd, opt;
int quiet = 0;
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "n:o:l:q")) != -1) {
switch (opt) { switch (opt) {
case 'n': case 'n':
name = optarg; name = optarg;
...@@ -60,13 +62,16 @@ int main(int argc, char *argv[]) ...@@ -60,13 +62,16 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
} }
if (!name) if (!name)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
regexp = malloc(strlen(name) + 3); regexp = malloc(strlen(name) + 3);
......
...@@ -35,6 +35,7 @@ void usage(char *cmd) ...@@ -35,6 +35,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container\n"); fprintf(stderr, "\t -n <name> : name of the container\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -43,6 +44,7 @@ int main(int argc, char *argv[]) ...@@ -43,6 +44,7 @@ int main(int argc, char *argv[])
char *name = NULL; char *name = NULL;
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
int opt, nbargs = 0; int opt, nbargs = 0;
int quiet = 0;
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
switch (opt) { switch (opt) {
...@@ -55,6 +57,9 @@ int main(int argc, char *argv[]) ...@@ -55,6 +57,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -66,7 +71,7 @@ int main(int argc, char *argv[]) ...@@ -66,7 +71,7 @@ int main(int argc, char *argv[])
if (!argv[optind]) if (!argv[optind])
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
if (lxc_restart(name, argv[1], 0)) { if (lxc_restart(name, argv[1], 0)) {
......
...@@ -45,6 +45,7 @@ void usage(char *cmd) ...@@ -45,6 +45,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container\n"); fprintf(stderr, "\t -n <name> : name of the container\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -54,6 +55,7 @@ int main(int argc, char *argv[]) ...@@ -54,6 +55,7 @@ int main(int argc, char *argv[])
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
char **args; char **args;
int opt, err = LXC_ERROR_INTERNAL, nbargs = 0; int opt, err = LXC_ERROR_INTERNAL, nbargs = 0;
int quiet = 0;
struct termios tios; struct termios tios;
char *default_args[] = { char *default_args[] = {
...@@ -72,6 +74,9 @@ int main(int argc, char *argv[]) ...@@ -72,6 +74,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -87,7 +92,7 @@ int main(int argc, char *argv[]) ...@@ -87,7 +92,7 @@ int main(int argc, char *argv[])
if (!name) if (!name)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
if (tcgetattr(0, &tios)) { if (tcgetattr(0, &tios)) {
......
...@@ -33,6 +33,7 @@ void usage(char *cmd) ...@@ -33,6 +33,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container\n"); fprintf(stderr, "\t -n <name> : name of the container\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -41,8 +42,9 @@ int main(int argc, char *argv[]) ...@@ -41,8 +42,9 @@ int main(int argc, char *argv[])
char *name = NULL; char *name = NULL;
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
int opt, err, nbargs = 0; int opt, err, nbargs = 0;
int quiet = 0;
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "n:o:l:q")) != -1) {
switch (opt) { switch (opt) {
case 'n': case 'n':
name = optarg; name = optarg;
...@@ -53,6 +55,9 @@ int main(int argc, char *argv[]) ...@@ -53,6 +55,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -61,7 +66,7 @@ int main(int argc, char *argv[]) ...@@ -61,7 +66,7 @@ int main(int argc, char *argv[])
if (!name) if (!name)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
err = lxc_stop(name); err = lxc_stop(name);
......
...@@ -33,6 +33,7 @@ void usage(char *cmd) ...@@ -33,6 +33,7 @@ void usage(char *cmd)
fprintf(stderr, "\t -n <name> : name of the container\n"); fprintf(stderr, "\t -n <name> : name of the container\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -41,6 +42,7 @@ int main(int argc, char *argv[]) ...@@ -41,6 +42,7 @@ int main(int argc, char *argv[])
char *name = NULL; char *name = NULL;
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
int opt, nbargs = 0; int opt, nbargs = 0;
int quiet = 0;
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
switch (opt) { switch (opt) {
...@@ -53,6 +55,9 @@ int main(int argc, char *argv[]) ...@@ -53,6 +55,9 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
nbargs++; nbargs++;
...@@ -61,7 +66,7 @@ int main(int argc, char *argv[]) ...@@ -61,7 +66,7 @@ int main(int argc, char *argv[])
if (!name) if (!name)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return 1; return 1;
if (lxc_unfreeze(name)) if (lxc_unfreeze(name))
......
...@@ -38,6 +38,7 @@ void usage(char *cmd) ...@@ -38,6 +38,7 @@ void usage(char *cmd)
"STARTING, RUNNING, STOPPING, ABORTING, FREEZING, FROZEN\n"); "STARTING, RUNNING, STOPPING, ABORTING, FREEZING, FROZEN\n");
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n"); fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n"); fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
fprintf(stderr, "\t[-q ] : be quiet\n");
_exit(1); _exit(1);
} }
...@@ -66,6 +67,7 @@ int main(int argc, char *argv[]) ...@@ -66,6 +67,7 @@ int main(int argc, char *argv[])
const char *log_file = NULL, *log_priority = NULL; const char *log_file = NULL, *log_priority = NULL;
struct lxc_msg msg; struct lxc_msg msg;
int s[MAX_STATE] = { }, fd, opt; int s[MAX_STATE] = { }, fd, opt;
int quiet = 0;
while ((opt = getopt(argc, argv, "s:n:o:l:")) != -1) { while ((opt = getopt(argc, argv, "s:n:o:l:")) != -1) {
switch (opt) { switch (opt) {
...@@ -81,13 +83,16 @@ int main(int argc, char *argv[]) ...@@ -81,13 +83,16 @@ int main(int argc, char *argv[])
case 'l': case 'l':
log_priority = optarg; log_priority = optarg;
break; break;
case 'q':
quiet = 1;
break;
} }
} }
if (!name || !states) if (!name || !states)
usage(argv[0]); usage(argv[0]);
if (lxc_log_init(log_file, log_priority, basename(argv[0]))) if (lxc_log_init(log_file, log_priority, basename(argv[0]), quiet))
return -1; return -1;
if (fillwaitedstates(states, s)) { if (fillwaitedstates(states, s)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment