mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 13:31:27 +00:00
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: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
fcffb59fc8
commit
441e496395
@ -97,7 +97,7 @@ static struct lxc_log_appender log_appender_stderr = {
|
||||
static struct lxc_log_appender log_appender_logfile = {
|
||||
.name = "logfile",
|
||||
.append = log_append_logfile,
|
||||
.next = &log_appender_stderr,
|
||||
.next = NULL,
|
||||
};
|
||||
|
||||
static struct lxc_log_category log_root = {
|
||||
@ -147,7 +147,7 @@ static int log_open(const char *name)
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
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;
|
||||
|
||||
@ -162,6 +162,9 @@ extern int lxc_log_init(const char *file, const char *priority,
|
||||
|
||||
lxc_log_category_lxc.priority = lxc_priority;
|
||||
|
||||
if (!quiet)
|
||||
lxc_log_category_lxc.appender->next = &log_appender_stderr;
|
||||
|
||||
if (prefix)
|
||||
lxc_log_setprefix(prefix);
|
||||
|
||||
|
@ -286,5 +286,5 @@ extern struct lxc_log_category lxc_log_category_lxc;
|
||||
} while (0)
|
||||
|
||||
extern int lxc_log_init(const char *file, const char *priority,
|
||||
const char *prefix);
|
||||
const char *prefix, int quiet);
|
||||
#endif
|
||||
|
@ -36,6 +36,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -45,6 +46,7 @@ int main(int argc, char *argv[])
|
||||
char *name = NULL, *subsystem = NULL, *value = NULL;
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
int nbargs = 0;
|
||||
int quiet = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
|
||||
switch (opt) {
|
||||
@ -57,6 +59,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -65,7 +70,7 @@ int main(int argc, char *argv[])
|
||||
if (!name || (argc-optind) < 1)
|
||||
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;
|
||||
|
||||
if ((argc -optind) >= 1)
|
||||
|
@ -33,6 +33,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -44,6 +45,7 @@ int main(int argc, char *argv[])
|
||||
int stop = 0;
|
||||
int nbargs = 0;
|
||||
int ret = 1;
|
||||
int quiet = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "sn:o:l:")) != -1) {
|
||||
switch (opt) {
|
||||
@ -59,6 +61,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -70,7 +75,7 @@ int main(int argc, char *argv[])
|
||||
if (!argv[1])
|
||||
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;
|
||||
|
||||
if (lxc_freeze(name))
|
||||
|
@ -50,6 +50,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t [-t <tty#>] : tty number\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -57,6 +58,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
char *name = NULL;
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
int quiet = 0;
|
||||
int opt;
|
||||
int nbargs = 0;
|
||||
int master = -1;
|
||||
@ -80,6 +82,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -88,7 +93,7 @@ int main(int argc, char *argv[])
|
||||
if (!name)
|
||||
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;
|
||||
|
||||
/* Get current termios */
|
||||
|
@ -41,6 +41,7 @@ void usage(char *cmd)
|
||||
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[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -50,8 +51,9 @@ int main(int argc, char *argv[])
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
struct lxc_conf lxc_conf;
|
||||
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) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
@ -65,13 +67,16 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name)
|
||||
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;
|
||||
|
||||
if (lxc_conf_init(&lxc_conf))
|
||||
|
@ -33,6 +33,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -43,6 +44,7 @@ int main(int argc, char *argv[])
|
||||
int opt;
|
||||
int nbargs = 0;
|
||||
int err;
|
||||
int quiet = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
|
||||
switch (opt) {
|
||||
@ -55,6 +57,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -63,7 +68,7 @@ int main(int argc, char *argv[])
|
||||
if (!name)
|
||||
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;
|
||||
|
||||
err = lxc_destroy(name);
|
||||
|
@ -42,6 +42,7 @@ void usage(char *cmd)
|
||||
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[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -55,9 +56,10 @@ int main(int argc, char *argv[])
|
||||
int nbargs = 0;
|
||||
int autodestroy = 0;
|
||||
int ret = 1;
|
||||
int quiet = 0;
|
||||
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) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
@ -71,6 +73,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -81,7 +86,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
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;
|
||||
|
||||
if (lxc_conf_init(&lxc_conf))
|
||||
|
@ -34,6 +34,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -43,6 +44,7 @@ int main(int argc, char *argv[])
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
int opt;
|
||||
int nbargs = 0;
|
||||
int quiet = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
|
||||
switch (opt) {
|
||||
@ -55,6 +57,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -63,7 +68,7 @@ int main(int argc, char *argv[])
|
||||
if (!name)
|
||||
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;
|
||||
|
||||
if (lxc_freeze(name))
|
||||
|
@ -33,6 +33,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -41,6 +42,7 @@ int main(int argc, char *argv[])
|
||||
char *name = NULL;
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
int opt, state, nbargs = 0;
|
||||
int quiet = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
|
||||
switch (opt) {
|
||||
@ -53,6 +55,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -61,7 +66,7 @@ int main(int argc, char *argv[])
|
||||
if (!name)
|
||||
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;
|
||||
|
||||
state = lxc_getstate(name);
|
||||
|
@ -37,6 +37,7 @@ void usage(char *cmd)
|
||||
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[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -48,8 +49,9 @@ int main(int argc, char *argv[])
|
||||
struct lxc_msg msg;
|
||||
regex_t preg;
|
||||
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) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
@ -60,13 +62,16 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name)
|
||||
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;
|
||||
|
||||
regexp = malloc(strlen(name) + 3);
|
||||
|
@ -35,6 +35,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -43,6 +44,7 @@ int main(int argc, char *argv[])
|
||||
char *name = NULL;
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
int opt, nbargs = 0;
|
||||
int quiet = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
|
||||
switch (opt) {
|
||||
@ -55,6 +57,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -66,7 +71,7 @@ int main(int argc, char *argv[])
|
||||
if (!argv[optind])
|
||||
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;
|
||||
|
||||
if (lxc_restart(name, argv[1], 0)) {
|
||||
|
@ -45,6 +45,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -54,6 +55,7 @@ int main(int argc, char *argv[])
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
char **args;
|
||||
int opt, err = LXC_ERROR_INTERNAL, nbargs = 0;
|
||||
int quiet = 0;
|
||||
struct termios tios;
|
||||
|
||||
char *default_args[] = {
|
||||
@ -72,6 +74,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -87,7 +92,7 @@ int main(int argc, char *argv[])
|
||||
if (!name)
|
||||
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;
|
||||
|
||||
if (tcgetattr(0, &tios)) {
|
||||
|
@ -33,6 +33,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -41,8 +42,9 @@ int main(int argc, char *argv[])
|
||||
char *name = NULL;
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
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) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
@ -53,6 +55,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -61,7 +66,7 @@ int main(int argc, char *argv[])
|
||||
if (!name)
|
||||
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;
|
||||
|
||||
err = lxc_stop(name);
|
||||
|
@ -33,6 +33,7 @@ void usage(char *cmd)
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -41,6 +42,7 @@ int main(int argc, char *argv[])
|
||||
char *name = NULL;
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
int opt, nbargs = 0;
|
||||
int quiet = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:o:l:")) != -1) {
|
||||
switch (opt) {
|
||||
@ -53,6 +55,9 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -61,7 +66,7 @@ int main(int argc, char *argv[])
|
||||
if (!name)
|
||||
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;
|
||||
|
||||
if (lxc_unfreeze(name))
|
||||
|
@ -38,6 +38,7 @@ void usage(char *cmd)
|
||||
"STARTING, RUNNING, STOPPING, ABORTING, FREEZING, FROZEN\n");
|
||||
fprintf(stderr, "\t[-o <logfile>] : path of the log file\n");
|
||||
fprintf(stderr, "\t[-l <logpriority>]: log level priority\n");
|
||||
fprintf(stderr, "\t[-q ] : be quiet\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@ -66,6 +67,7 @@ int main(int argc, char *argv[])
|
||||
const char *log_file = NULL, *log_priority = NULL;
|
||||
struct lxc_msg msg;
|
||||
int s[MAX_STATE] = { }, fd, opt;
|
||||
int quiet = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "s:n:o:l:")) != -1) {
|
||||
switch (opt) {
|
||||
@ -81,13 +83,16 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
log_priority = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name || !states)
|
||||
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;
|
||||
|
||||
if (fillwaitedstates(states, s)) {
|
||||
|
Loading…
Reference in New Issue
Block a user