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
44322ead
Unverified
Commit
44322ead
authored
Feb 02, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgpath: add logging
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
c5bac506
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletion
+33
-1
cgpath.c
src/tests/cgpath.c
+33
-1
No files found.
src/tests/cgpath.c
View file @
44322ead
...
@@ -30,8 +30,10 @@
...
@@ -30,8 +30,10 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include "cgroup.h"
#include "cgroup.h"
#include "lxc.h"
#include "commands.h"
#include "commands.h"
#include "lxc.h"
#include "lxctest.h"
#include "utils.h"
#ifndef HAVE_STRLCPY
#ifndef HAVE_STRLCPY
#include "include/strlcpy.h"
#include "include/strlcpy.h"
...
@@ -50,13 +52,32 @@
...
@@ -50,13 +52,32 @@
*/
*/
static
int
test_running_container
(
const
char
*
lxcpath
,
const
char
*
name
)
static
int
test_running_container
(
const
char
*
lxcpath
,
const
char
*
name
)
{
{
__do_close
int
fd_log
=
-
EBADF
;
int
ret
=
-
1
;
int
ret
=
-
1
;
struct
lxc_container
*
c
=
NULL
;
struct
lxc_container
*
c
=
NULL
;
struct
lxc_log
log
=
{};
char
template
[
sizeof
(
P_tmpdir
"/attach_XXXXXX"
)];
char
*
cgrelpath
;
char
*
cgrelpath
;
char
relpath
[
PATH_MAX
+
1
];
char
relpath
[
PATH_MAX
+
1
];
char
value
[
NAME_MAX
],
value_save
[
NAME_MAX
];
char
value
[
NAME_MAX
],
value_save
[
NAME_MAX
];
struct
cgroup_ops
*
cgroup_ops
;
struct
cgroup_ops
*
cgroup_ops
;
(
void
)
strlcpy
(
template
,
P_tmpdir
"/attach_XXXXXX"
,
sizeof
(
template
));
fd_log
=
lxc_make_tmpfile
(
template
,
false
);
if
(
fd_log
<
0
)
{
lxc_error
(
"Failed to create temporary log file for container %s
\n
"
,
name
);
exit
(
EXIT_FAILURE
);
}
log
.
name
=
name
;
log
.
file
=
template
;
log
.
level
=
"TRACE"
;
log
.
prefix
=
"cgpath"
;
log
.
quiet
=
false
;
log
.
lxcpath
=
NULL
;
if
(
lxc_log_init
(
&
log
))
goto
err1
;
sprintf
(
relpath
,
DEFAULT_PAYLOAD_CGROUP_PREFIX
"%s"
,
name
);
sprintf
(
relpath
,
DEFAULT_PAYLOAD_CGROUP_PREFIX
"%s"
,
name
);
if
((
c
=
lxc_container_new
(
name
,
lxcpath
))
==
NULL
)
{
if
((
c
=
lxc_container_new
(
name
,
lxcpath
))
==
NULL
)
{
...
@@ -123,6 +144,17 @@ err3:
...
@@ -123,6 +144,17 @@ err3:
err2:
err2:
lxc_container_put
(
c
);
lxc_container_put
(
c
);
err1:
err1:
if
(
ret
!=
0
)
{
char
buf
[
4096
];
ssize_t
buflen
;
while
((
buflen
=
read
(
fd_log
,
buf
,
1024
))
>
0
)
{
buflen
=
write
(
STDERR_FILENO
,
buf
,
buflen
);
if
(
buflen
<=
0
)
break
;
}
}
(
void
)
unlink
(
template
);
return
ret
;
return
ret
;
}
}
...
...
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