mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 17:12:14 +00:00
tools: lxc-wait: add default log priority & cleanups
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
This commit is contained in:
parent
2c70300ad8
commit
75457df5dc
@ -37,25 +37,8 @@
|
|||||||
|
|
||||||
lxc_log_define(lxc_wait, lxc);
|
lxc_log_define(lxc_wait, lxc);
|
||||||
|
|
||||||
static int my_checker(const struct lxc_arguments *args)
|
static int my_parser(struct lxc_arguments *args, int c, char *arg);
|
||||||
{
|
static int my_checker(const struct lxc_arguments *args);
|
||||||
if (!args->states) {
|
|
||||||
ERROR("Missing state option to wait for");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int my_parser(struct lxc_arguments *args, int c, char *arg)
|
|
||||||
{
|
|
||||||
switch (c) {
|
|
||||||
case 's': args->states = optarg; break;
|
|
||||||
case 't': args->timeout = atol(optarg); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct option my_longopts[] = {
|
static const struct option my_longopts[] = {
|
||||||
{"state", required_argument, 0, 's'},
|
{"state", required_argument, 0, 's'},
|
||||||
@ -80,9 +63,35 @@ Options :\n\
|
|||||||
.options = my_longopts,
|
.options = my_longopts,
|
||||||
.parser = my_parser,
|
.parser = my_parser,
|
||||||
.checker = my_checker,
|
.checker = my_checker,
|
||||||
|
.log_priority = "ERROR",
|
||||||
|
.log_file = "none",
|
||||||
.timeout = -1,
|
.timeout = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int my_parser(struct lxc_arguments *args, int c, char *arg)
|
||||||
|
{
|
||||||
|
switch (c) {
|
||||||
|
case 's':
|
||||||
|
args->states = optarg;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
args->timeout = atol(optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int my_checker(const struct lxc_arguments *args)
|
||||||
|
{
|
||||||
|
if (!args->states) {
|
||||||
|
ERROR("Missing state option to wait for");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
@ -91,8 +100,6 @@ int main(int argc, char *argv[])
|
|||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
/* Only create log if explicitly instructed */
|
|
||||||
if (my_args.log_file || my_args.log_priority) {
|
|
||||||
log.name = my_args.name;
|
log.name = my_args.name;
|
||||||
log.file = my_args.log_file;
|
log.file = my_args.log_file;
|
||||||
log.level = my_args.log_priority;
|
log.level = my_args.log_priority;
|
||||||
@ -102,7 +109,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (lxc_log_init(&log))
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
|
||||||
|
|
||||||
c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
|
c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
|
||||||
if (!c)
|
if (!c)
|
||||||
|
Loading…
Reference in New Issue
Block a user