Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
73b910a3
Commit
73b910a3
authored
Jun 05, 2017
by
0x0916
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: expose function lxc_log_init
Signed-off-by:
0x0916
<
w@laoqinren.net
>
parent
beda39eb
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
228 additions
and
66 deletions
+228
-66
log.c
src/lxc/log.c
+20
-21
log.h
src/lxc/log.h
+0
-4
lxc_monitord.c
src/lxc/lxc_monitord.c
+9
-1
lxccontainer.h
src/lxc/lxccontainer.h
+16
-0
lxc_attach.c
src/lxc/tools/lxc_attach.c
+8
-2
lxc_autostart.c
src/lxc/tools/lxc_autostart.c
+9
-2
lxc_cgroup.c
src/lxc/tools/lxc_cgroup.c
+9
-2
lxc_checkpoint.c
src/lxc/tools/lxc_checkpoint.c
+9
-2
lxc_console.c
src/lxc/tools/lxc_console.c
+9
-2
lxc_copy.c
src/lxc/tools/lxc_copy.c
+9
-2
lxc_create.c
src/lxc/tools/lxc_create.c
+9
-2
lxc_destroy.c
src/lxc/tools/lxc_destroy.c
+9
-2
lxc_device.c
src/lxc/tools/lxc_device.c
+9
-2
lxc_execute.c
src/lxc/tools/lxc_execute.c
+10
-2
lxc_freeze.c
src/lxc/tools/lxc_freeze.c
+9
-2
lxc_info.c
src/lxc/tools/lxc_info.c
+9
-2
lxc_init.c
src/lxc/tools/lxc_init.c
+10
-2
lxc_ls.c
src/lxc/tools/lxc_ls.c
+9
-2
lxc_monitor.c
src/lxc/tools/lxc_monitor.c
+10
-2
lxc_snapshot.c
src/lxc/tools/lxc_snapshot.c
+9
-2
lxc_start.c
src/lxc/tools/lxc_start.c
+9
-2
lxc_stop.c
src/lxc/tools/lxc_stop.c
+9
-2
lxc_unfreeze.c
src/lxc/tools/lxc_unfreeze.c
+10
-2
lxc_wait.c
src/lxc/tools/lxc_wait.c
+9
-2
No files found.
src/lxc/log.c
View file @
73b910a3
...
@@ -44,6 +44,7 @@
...
@@ -44,6 +44,7 @@
#include "log.h"
#include "log.h"
#include "caps.h"
#include "caps.h"
#include "utils.h"
#include "utils.h"
#include "lxccontainer.h"
/* We're logging in seconds and nanoseconds. Assuming that the underlying
/* We're logging in seconds and nanoseconds. Assuming that the underlying
* datatype is currently at maximum a 64bit integer, we have a date string that
* datatype is currently at maximum a 64bit integer, we have a date string that
...
@@ -543,9 +544,7 @@ extern void lxc_log_enable_syslog(void)
...
@@ -543,9 +544,7 @@ extern void lxc_log_enable_syslog(void)
* Called from lxc front-end programs (like lxc-create, lxc-start) to
* Called from lxc front-end programs (like lxc-create, lxc-start) to
* initalize the log defaults.
* initalize the log defaults.
*/
*/
extern
int
lxc_log_init
(
const
char
*
name
,
const
char
*
file
,
extern
int
lxc_log_init
(
struct
lxc_log
*
log
)
const
char
*
priority
,
const
char
*
prefix
,
int
quiet
,
const
char
*
lxcpath
)
{
{
int
lxc_priority
=
LXC_LOG_PRIORITY_ERROR
;
int
lxc_priority
=
LXC_LOG_PRIORITY_ERROR
;
int
ret
;
int
ret
;
...
@@ -555,8 +554,8 @@ extern int lxc_log_init(const char *name, const char *file,
...
@@ -555,8 +554,8 @@ extern int lxc_log_init(const char *name, const char *file,
return
0
;
return
0
;
}
}
if
(
priority
)
if
(
log
->
priority
)
lxc_priority
=
lxc_log_priority_to_int
(
priority
);
lxc_priority
=
lxc_log_priority_to_int
(
log
->
priority
);
if
(
!
lxc_loglevel_specified
)
{
if
(
!
lxc_loglevel_specified
)
{
lxc_log_category_lxc
.
priority
=
lxc_priority
;
lxc_log_category_lxc
.
priority
=
lxc_priority
;
...
@@ -564,49 +563,49 @@ extern int lxc_log_init(const char *name, const char *file,
...
@@ -564,49 +563,49 @@ extern int lxc_log_init(const char *name, const char *file,
}
}
if
(
!
lxc_quiet_specified
)
{
if
(
!
lxc_quiet_specified
)
{
if
(
!
quiet
)
if
(
!
log
->
quiet
)
lxc_log_category_lxc
.
appender
->
next
=
&
log_appender_stderr
;
lxc_log_category_lxc
.
appender
->
next
=
&
log_appender_stderr
;
}
}
if
(
prefix
)
if
(
log
->
prefix
)
lxc_log_set_prefix
(
prefix
);
lxc_log_set_prefix
(
log
->
prefix
);
if
(
name
)
if
(
log
->
name
)
log_vmname
=
strdup
(
name
);
log_vmname
=
strdup
(
log
->
name
);
if
(
file
)
{
if
(
log
->
file
)
{
if
(
strcmp
(
file
,
"none"
)
==
0
)
if
(
strcmp
(
log
->
file
,
"none"
)
==
0
)
return
0
;
return
0
;
ret
=
__lxc_log_set_file
(
file
,
1
);
ret
=
__lxc_log_set_file
(
log
->
file
,
1
);
lxc_log_use_global_fd
=
1
;
lxc_log_use_global_fd
=
1
;
}
else
{
}
else
{
/* if no name was specified, there nothing to do */
/* if no name was specified, there nothing to do */
if
(
!
name
)
if
(
!
log
->
name
)
return
0
;
return
0
;
ret
=
-
1
;
ret
=
-
1
;
if
(
!
lxcpath
)
if
(
!
l
og
->
l
xcpath
)
lxcpath
=
LOGPATH
;
l
og
->
l
xcpath
=
LOGPATH
;
/* try LOGPATH if lxcpath is the default for the privileged containers */
/* try LOGPATH if lxcpath is the default for the privileged containers */
if
(
!
geteuid
()
&&
strcmp
(
LXCPATH
,
lxcpath
)
==
0
)
if
(
!
geteuid
()
&&
strcmp
(
LXCPATH
,
l
og
->
l
xcpath
)
==
0
)
ret
=
_lxc_log_set_file
(
name
,
NULL
,
0
);
ret
=
_lxc_log_set_file
(
log
->
name
,
NULL
,
0
);
/* try in lxcpath */
/* try in lxcpath */
if
(
ret
<
0
)
if
(
ret
<
0
)
ret
=
_lxc_log_set_file
(
name
,
lxcpath
,
1
);
ret
=
_lxc_log_set_file
(
log
->
name
,
log
->
lxcpath
,
1
);
/* try LOGPATH in case its writable by the caller */
/* try LOGPATH in case its writable by the caller */
if
(
ret
<
0
)
if
(
ret
<
0
)
ret
=
_lxc_log_set_file
(
name
,
NULL
,
0
);
ret
=
_lxc_log_set_file
(
log
->
name
,
NULL
,
0
);
}
}
/*
/*
* If !file, that is, if the user did not request this logpath, then
* If !file, that is, if the user did not request this logpath, then
* ignore failures and continue logging to console
* ignore failures and continue logging to console
*/
*/
if
(
!
file
&&
ret
!=
0
)
{
if
(
!
log
->
file
&&
ret
!=
0
)
{
INFO
(
"Ignoring failure to open default logfile."
);
INFO
(
"Ignoring failure to open default logfile."
);
ret
=
0
;
ret
=
0
;
}
}
...
...
src/lxc/log.h
View file @
73b910a3
...
@@ -348,10 +348,6 @@ ATTR_UNUSED static inline void LXC_##PRIORITY(struct lxc_log_locinfo* locinfo, \
...
@@ -348,10 +348,6 @@ ATTR_UNUSED static inline void LXC_##PRIORITY(struct lxc_log_locinfo* locinfo, \
extern
int
lxc_log_fd
;
extern
int
lxc_log_fd
;
extern
int
lxc_log_init
(
const
char
*
name
,
const
char
*
file
,
const
char
*
priority
,
const
char
*
prefix
,
int
quiet
,
const
char
*
lxcpath
);
extern
int
lxc_log_set_file
(
int
*
fd
,
const
char
*
fname
);
extern
int
lxc_log_set_file
(
int
*
fd
,
const
char
*
fname
);
extern
int
lxc_log_syslog
(
int
facility
);
extern
int
lxc_log_syslog
(
int
facility
);
extern
void
lxc_log_enable_syslog
(
void
);
extern
void
lxc_log_enable_syslog
(
void
);
...
...
src/lxc/lxc_monitord.c
View file @
73b910a3
...
@@ -44,6 +44,7 @@
...
@@ -44,6 +44,7 @@
#include "mainloop.h"
#include "mainloop.h"
#include "monitor.h"
#include "monitor.h"
#include "utils.h"
#include "utils.h"
#include "lxccontainer.h"
#define CLIENTFDS_CHUNK 64
#define CLIENTFDS_CHUNK 64
...
@@ -350,6 +351,7 @@ int main(int argc, char *argv[])
...
@@ -350,6 +351,7 @@ int main(int argc, char *argv[])
char
*
lxcpath
=
argv
[
1
];
char
*
lxcpath
=
argv
[
1
];
bool
mainloop_opened
=
false
;
bool
mainloop_opened
=
false
;
bool
monitord_created
=
false
;
bool
monitord_created
=
false
;
struct
lxc_log
log
;
if
(
argc
!=
3
)
{
if
(
argc
!=
3
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
...
@@ -364,7 +366,13 @@ int main(int argc, char *argv[])
...
@@ -364,7 +366,13 @@ int main(int argc, char *argv[])
if
(
ret
<
0
||
ret
>=
sizeof
(
logpath
))
if
(
ret
<
0
||
ret
>=
sizeof
(
logpath
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
ret
=
lxc_log_init
(
NULL
,
logpath
,
"DEBUG"
,
"lxc-monitord"
,
0
,
lxcpath
);
log
.
name
=
NULL
;
log
.
file
=
logpath
;
log
.
priority
=
"DEBUG"
;
log
.
prefix
=
"lxc-monitord"
;
log
.
quiet
=
0
;
log
.
lxcpath
=
lxcpath
;
ret
=
lxc_log_init
(
&
log
);
if
(
ret
)
if
(
ret
)
INFO
(
"Failed to open log file %s, log will be lost."
,
lxcpath
);
INFO
(
"Failed to open log file %s, log will be lost."
,
lxcpath
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/lxccontainer.h
View file @
73b910a3
...
@@ -1017,6 +1017,22 @@ int list_active_containers(const char *lxcpath, char ***names, struct lxc_contai
...
@@ -1017,6 +1017,22 @@ int list_active_containers(const char *lxcpath, char ***names, struct lxc_contai
*/
*/
int
list_all_containers
(
const
char
*
lxcpath
,
char
***
names
,
struct
lxc_container
***
cret
);
int
list_all_containers
(
const
char
*
lxcpath
,
char
***
names
,
struct
lxc_container
***
cret
);
struct
lxc_log
{
const
char
*
name
;
const
char
*
lxcpath
;
const
char
*
file
;
const
char
*
priority
;
const
char
*
prefix
;
bool
quiet
;
};
/*!
*\brief Initialize the log
*
*\param log lxc log configuration.
*/
int
lxc_log_init
(
struct
lxc_log
*
log
);
/*!
/*!
* \brief Close log file.
* \brief Close log file.
*/
*/
...
...
src/lxc/tools/lxc_attach.c
View file @
73b910a3
...
@@ -371,6 +371,7 @@ int main(int argc, char *argv[])
...
@@ -371,6 +371,7 @@ int main(int argc, char *argv[])
{
{
int
ret
=
-
1
,
r
;
int
ret
=
-
1
,
r
;
int
wexit
=
0
;
int
wexit
=
0
;
struct
lxc_log
log
;
pid_t
pid
;
pid_t
pid
;
lxc_attach_options_t
attach_options
=
LXC_ATTACH_OPTIONS_DEFAULT
;
lxc_attach_options_t
attach_options
=
LXC_ATTACH_OPTIONS_DEFAULT
;
lxc_attach_command_t
command
=
(
lxc_attach_command_t
){.
program
=
NULL
};
lxc_attach_command_t
command
=
(
lxc_attach_command_t
){.
program
=
NULL
};
...
@@ -386,8 +387,13 @@ int main(int argc, char *argv[])
...
@@ -386,8 +387,13 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
r
=
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]);
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
r
=
lxc_log_init
(
&
log
);
if
(
r
)
if
(
r
)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_autostart.c
View file @
73b910a3
...
@@ -352,12 +352,19 @@ int main(int argc, char *argv[])
...
@@ -352,12 +352,19 @@ int main(int argc, char *argv[])
struct
lxc_container
**
containers
=
NULL
;
struct
lxc_container
**
containers
=
NULL
;
struct
lxc_list
**
c_groups_lists
=
NULL
;
struct
lxc_list
**
c_groups_lists
=
NULL
;
struct
lxc_list
*
cmd_group
;
struct
lxc_list
*
cmd_group
;
struct
lxc_log
log
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_cgroup.c
View file @
73b910a3
...
@@ -67,6 +67,7 @@ int main(int argc, char *argv[])
...
@@ -67,6 +67,7 @@ int main(int argc, char *argv[])
{
{
char
*
state_object
=
NULL
,
*
value
=
NULL
;
char
*
state_object
=
NULL
,
*
value
=
NULL
;
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -74,8 +75,14 @@ int main(int argc, char *argv[])
...
@@ -74,8 +75,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_checkpoint.c
View file @
73b910a3
...
@@ -234,6 +234,7 @@ static bool restore(struct lxc_container *c)
...
@@ -234,6 +234,7 @@ static bool restore(struct lxc_container *c)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
bool
ret
;
bool
ret
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
...
@@ -242,8 +243,14 @@ int main(int argc, char *argv[])
...
@@ -242,8 +243,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_console.c
View file @
73b910a3
...
@@ -98,6 +98,7 @@ int main(int argc, char *argv[])
...
@@ -98,6 +98,7 @@ int main(int argc, char *argv[])
{
{
int
ret
;
int
ret
;
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
ret
=
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
);
ret
=
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
);
if
(
ret
)
if
(
ret
)
...
@@ -106,8 +107,14 @@ int main(int argc, char *argv[])
...
@@ -106,8 +107,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
ret
=
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]);
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
ret
=
lxc_log_init
(
&
log
);
if
(
ret
)
if
(
ret
)
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_copy.c
View file @
73b910a3
...
@@ -169,6 +169,7 @@ static int parse_ovl_mnt(char *mntstring, enum mnttype type);
...
@@ -169,6 +169,7 @@ static int parse_ovl_mnt(char *mntstring, enum mnttype type);
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
int
flags
=
0
;
int
flags
=
0
;
int
ret
=
EXIT_FAILURE
;
int
ret
=
EXIT_FAILURE
;
...
@@ -178,8 +179,14 @@ int main(int argc, char *argv[])
...
@@ -178,8 +179,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
ret
);
exit
(
ret
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_create.c
View file @
73b910a3
...
@@ -208,6 +208,7 @@ int main(int argc, char *argv[])
...
@@ -208,6 +208,7 @@ int main(int argc, char *argv[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
bdev_specs
spec
;
struct
bdev_specs
spec
;
struct
lxc_log
log
;
int
flags
=
0
;
int
flags
=
0
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
...
@@ -216,8 +217,14 @@ int main(int argc, char *argv[])
...
@@ -216,8 +217,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_destroy.c
View file @
73b910a3
...
@@ -67,6 +67,7 @@ static bool do_destroy_with_snapshots(struct lxc_container *c);
...
@@ -67,6 +67,7 @@ static bool do_destroy_with_snapshots(struct lxc_container *c);
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
bool
bret
;
bool
bret
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
...
@@ -75,8 +76,14 @@ int main(int argc, char *argv[])
...
@@ -75,8 +76,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
if
(
my_args
.
quiet
)
if
(
my_args
.
quiet
)
...
...
src/lxc/tools/lxc_device.c
View file @
73b910a3
...
@@ -101,6 +101,7 @@ static bool is_interface(const char* dev_name, pid_t pid)
...
@@ -101,6 +101,7 @@ static bool is_interface(const char* dev_name, pid_t pid)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
char
*
cmd
,
*
dev_name
,
*
dst_name
;
char
*
cmd
,
*
dev_name
,
*
dst_name
;
bool
ret
=
false
;
bool
ret
=
false
;
...
@@ -115,8 +116,14 @@ int main(int argc, char *argv[])
...
@@ -115,8 +116,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
goto
err
;
goto
err
;
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_execute.c
View file @
73b910a3
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "config.h"
#include "config.h"
#include "start.h"
#include "start.h"
#include "utils.h"
#include "utils.h"
#include "lxccontainer.h"
lxc_log_define
(
lxc_execute_ui
,
lxc
);
lxc_log_define
(
lxc_execute_ui
,
lxc
);
...
@@ -106,6 +107,7 @@ int main(int argc, char *argv[])
...
@@ -106,6 +107,7 @@ int main(int argc, char *argv[])
{
{
char
*
rcfile
;
char
*
rcfile
;
struct
lxc_conf
*
conf
;
struct
lxc_conf
*
conf
;
struct
lxc_log
log
;
int
ret
;
int
ret
;
lxc_list_init
(
&
defines
);
lxc_list_init
(
&
defines
);
...
@@ -116,8 +118,14 @@ int main(int argc, char *argv[])
...
@@ -116,8 +118,14 @@ 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
);
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_freeze.c
View file @
73b910a3
...
@@ -57,6 +57,7 @@ Options :\n\
...
@@ -57,6 +57,7 @@ Options :\n\
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -64,8 +65,14 @@ int main(int argc, char *argv[])
...
@@ -64,8 +65,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_info.c
View file @
73b910a3
...
@@ -394,6 +394,7 @@ static int print_info(const char *name, const char *lxcpath)
...
@@ -394,6 +394,7 @@ static int print_info(const char *name, const char *lxcpath)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
ret
=
EXIT_FAILURE
;
int
ret
=
EXIT_FAILURE
;
struct
lxc_log
log
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
exit
(
ret
);
exit
(
ret
);
...
@@ -401,8 +402,14 @@ int main(int argc, char *argv[])
...
@@ -401,8 +402,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
ret
);
exit
(
ret
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_init.c
View file @
73b910a3
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "caps.h"
#include "caps.h"
#include "error.h"
#include "error.h"
#include "initutils.h"
#include "initutils.h"
#include "lxccontainer.h"
lxc_log_define
(
lxc_init
,
lxc
);
lxc_log_define
(
lxc_init
,
lxc
);
...
@@ -83,6 +84,7 @@ int main(int argc, char *argv[])
...
@@ -83,6 +84,7 @@ int main(int argc, char *argv[])
int
i
,
have_status
=
0
,
shutdown
=
0
;
int
i
,
have_status
=
0
,
shutdown
=
0
;
int
opt
;
int
opt
;
char
*
lxcpath
=
NULL
,
*
name
=
NULL
,
*
logpriority
=
NULL
;
char
*
lxcpath
=
NULL
,
*
name
=
NULL
,
*
logpriority
=
NULL
;
struct
lxc_log
log
;
while
((
opt
=
getopt_long
(
argc
,
argv
,
"n:l:qP:"
,
options
,
NULL
))
!=
-
1
)
{
while
((
opt
=
getopt_long
(
argc
,
argv
,
"n:l:qP:"
,
options
,
NULL
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
...
@@ -104,8 +106,14 @@ int main(int argc, char *argv[])
...
@@ -104,8 +106,14 @@ int main(int argc, char *argv[])
}
}
}
}
err
=
lxc_log_init
(
name
,
name
?
NULL
:
"none"
,
logpriority
,
log
.
name
=
name
;
basename
(
argv
[
0
]),
quiet
,
lxcpath
);
log
.
file
=
name
?
NULL
:
"none"
;
log
.
priority
=
logpriority
;
log
.
prefix
=
basename
(
argv
[
0
]);
log
.
quiet
=
quiet
;
log
.
lxcpath
=
lxcpath
;
err
=
lxc_log_init
(
&
log
);
if
(
err
<
0
)
if
(
err
<
0
)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_ls.c
View file @
73b910a3
...
@@ -203,6 +203,7 @@ Options :\n\
...
@@ -203,6 +203,7 @@ Options :\n\
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
ret
=
EXIT_FAILURE
;
int
ret
=
EXIT_FAILURE
;
struct
lxc_log
log
;
/*
/*
* The lxc parser requires that my_args.name is set. So let's satisfy
* The lxc parser requires that my_args.name is set. So let's satisfy
* that condition by setting a dummy name which is never used.
* that condition by setting a dummy name which is never used.
...
@@ -218,8 +219,14 @@ int main(int argc, char *argv[])
...
@@ -218,8 +219,14 @@ int main(int argc, char *argv[])
* We set the first argument that usually takes my_args.name to NULL so
* We set the first argument that usually takes my_args.name to NULL so
* that the log is only used when the user specifies a file.
* that the log is only used when the user specifies a file.
*/
*/
if
(
lxc_log_init
(
NULL
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
NULL
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_monitor.c
View file @
73b910a3
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include "log.h"
#include "log.h"
#include "monitor.h"
#include "monitor.h"
#include "arguments.h"
#include "arguments.h"
#include "lxccontainer.h"
lxc_log_define
(
lxc_monitor_ui
,
lxc
);
lxc_log_define
(
lxc_monitor_ui
,
lxc
);
...
@@ -91,6 +92,7 @@ int main(int argc, char *argv[])
...
@@ -91,6 +92,7 @@ int main(int argc, char *argv[])
struct
pollfd
*
fds
;
struct
pollfd
*
fds
;
nfds_t
nfds
;
nfds_t
nfds
;
int
len
,
rc_main
,
rc_snp
,
i
;
int
len
,
rc_main
,
rc_snp
,
i
;
struct
lxc_log
log
;
rc_main
=
EXIT_FAILURE
;
rc_main
=
EXIT_FAILURE
;
...
@@ -100,8 +102,14 @@ int main(int argc, char *argv[])
...
@@ -100,8 +102,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
rc_main
);
exit
(
rc_main
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_snapshot.c
View file @
73b910a3
...
@@ -81,6 +81,7 @@ static void print_file(char *path);
...
@@ -81,6 +81,7 @@ static void print_file(char *path);
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
int
ret
;
int
ret
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
...
@@ -89,8 +90,14 @@ int main(int argc, char *argv[])
...
@@ -89,8 +90,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_start.c
View file @
73b910a3
...
@@ -205,6 +205,7 @@ int main(int argc, char *argv[])
...
@@ -205,6 +205,7 @@ int main(int argc, char *argv[])
{
{
int
err
=
EXIT_FAILURE
;
int
err
=
EXIT_FAILURE
;
struct
lxc_conf
*
conf
;
struct
lxc_conf
*
conf
;
struct
lxc_log
log
;
char
*
const
*
args
;
char
*
const
*
args
;
char
*
rcfile
=
NULL
;
char
*
rcfile
=
NULL
;
char
*
const
default_args
[]
=
{
char
*
const
default_args
[]
=
{
...
@@ -226,8 +227,14 @@ int main(int argc, char *argv[])
...
@@ -226,8 +227,14 @@ int main(int argc, char *argv[])
else
else
args
=
my_args
.
argv
;
args
=
my_args
.
argv
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
err
);
exit
(
err
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_stop.c
View file @
73b910a3
...
@@ -155,14 +155,21 @@ out:
...
@@ -155,14 +155,21 @@ out:
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
bool
s
;
bool
s
;
int
ret
=
EXIT_FAILURE
;
int
ret
=
EXIT_FAILURE
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
exit
(
ret
);
exit
(
ret
);
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
ret
);
exit
(
ret
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_unfreeze.c
View file @
73b910a3
...
@@ -55,6 +55,7 @@ Options :\n\
...
@@ -55,6 +55,7 @@ Options :\n\
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -62,8 +63,15 @@ int main(int argc, char *argv[])
...
@@ -62,8 +63,15 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
src/lxc/tools/lxc_wait.c
View file @
73b910a3
...
@@ -83,6 +83,7 @@ Options :\n\
...
@@ -83,6 +83,7 @@ Options :\n\
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
struct
lxc_log
log
;
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -90,8 +91,14 @@ int main(int argc, char *argv[])
...
@@ -90,8 +91,14 @@ int main(int argc, char *argv[])
if
(
!
my_args
.
log_file
)
if
(
!
my_args
.
log_file
)
my_args
.
log_file
=
"none"
;
my_args
.
log_file
=
"none"
;
if
(
lxc_log_init
(
my_args
.
name
,
my_args
.
log_file
,
my_args
.
log_priority
,
log
.
name
=
my_args
.
name
;
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
log
.
file
=
my_args
.
log_file
;
log
.
priority
=
my_args
.
log_priority
;
log
.
prefix
=
my_args
.
progname
;
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment