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
56d6e75b
Commit
56d6e75b
authored
Mar 18, 2016
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #902 from tych0/better-criu-logging
Better criu logging
parents
72e7e168
3d9a5c85
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
12 deletions
+59
-12
criu.c
src/lxc/criu.c
+59
-12
No files found.
src/lxc/criu.c
View file @
56d6e75b
...
@@ -126,7 +126,7 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -126,7 +126,7 @@ static void exec_criu(struct criu_opts *opts)
int
netnr
=
0
;
int
netnr
=
0
;
struct
lxc_list
*
it
;
struct
lxc_list
*
it
;
char
buf
[
4096
],
tty_info
[
32
];
char
buf
[
4096
],
*
pos
,
tty_info
[
32
];
/* If we are currently in a cgroup /foo/bar, and the container is in a
/* If we are currently in a cgroup /foo/bar, and the container is in a
* cgroup /lxc/foo, lxcfs will give us an ENOENT if some task in the
* cgroup /lxc/foo, lxcfs will give us an ENOENT if some task in the
...
@@ -356,6 +356,15 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -356,6 +356,15 @@ static void exec_criu(struct criu_opts *opts)
argv
[
argc
]
=
NULL
;
argv
[
argc
]
=
NULL
;
buf
[
0
]
=
0
;
pos
=
buf
;
for
(
i
=
0
;
argv
[
i
];
i
++
)
{
pos
=
strncat
(
buf
,
argv
[
i
],
buf
+
sizeof
(
buf
)
-
pos
);
pos
=
strncat
(
buf
,
" "
,
buf
+
sizeof
(
buf
)
-
pos
);
}
INFO
(
"execing: %s"
,
buf
);
#undef DECLARE_ARG
#undef DECLARE_ARG
execv
(
argv
[
0
],
argv
);
execv
(
argv
[
0
],
argv
);
err:
err:
...
@@ -521,12 +530,12 @@ out_unlock:
...
@@ -521,12 +530,12 @@ out_unlock:
// do_restore never returns, the calling process is used as the
// do_restore never returns, the calling process is used as the
// monitor process. do_restore calls exit() if it fails.
// monitor process. do_restore calls exit() if it fails.
void
do_restore
(
struct
lxc_container
*
c
,
int
pipe
,
char
*
directory
,
bool
verbose
)
void
do_restore
(
struct
lxc_container
*
c
,
int
status_
pipe
,
char
*
directory
,
bool
verbose
)
{
{
pid_t
pid
;
pid_t
pid
;
char
pidfile
[
L_tmpnam
];
char
pidfile
[
L_tmpnam
];
struct
lxc_handler
*
handler
;
struct
lxc_handler
*
handler
;
int
status
;
int
status
,
pipes
[
2
]
=
{
-
1
,
-
1
}
;
if
(
!
tmpnam
(
pidfile
))
if
(
!
tmpnam
(
pidfile
))
goto
out
;
goto
out
;
...
@@ -552,6 +561,11 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
...
@@ -552,6 +561,11 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
resolve_clone_flags
(
handler
);
resolve_clone_flags
(
handler
);
if
(
pipe
(
pipes
)
<
0
)
{
SYSERROR
(
"pipe() failed"
);
goto
out_fini_handler
;
}
pid
=
fork
();
pid
=
fork
();
if
(
pid
<
0
)
if
(
pid
<
0
)
goto
out_fini_handler
;
goto
out_fini_handler
;
...
@@ -561,8 +575,20 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
...
@@ -561,8 +575,20 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
struct
lxc_rootfs
*
rootfs
;
struct
lxc_rootfs
*
rootfs
;
int
flags
;
int
flags
;
close
(
pipe
);
close
(
status_pipe
);
pipe
=
-
1
;
status_pipe
=
-
1
;
close
(
pipes
[
0
]);
pipes
[
0
]
=
-
1
;
if
(
dup2
(
pipes
[
1
],
STDERR_FILENO
)
<
0
)
{
SYSERROR
(
"dup2 failed"
);
goto
out_fini_handler
;
}
if
(
dup2
(
pipes
[
1
],
STDOUT_FILENO
)
<
0
)
{
SYSERROR
(
"dup2 failed"
);
goto
out_fini_handler
;
}
if
(
unshare
(
CLONE_NEWNS
))
if
(
unshare
(
CLONE_NEWNS
))
goto
out_fini_handler
;
goto
out_fini_handler
;
...
@@ -623,15 +649,18 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
...
@@ -623,15 +649,18 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
int
ret
;
int
ret
;
char
title
[
2048
];
char
title
[
2048
];
close
(
pipes
[
1
]);
pipes
[
1
]
=
-
1
;
pid_t
w
=
waitpid
(
pid
,
&
status
,
0
);
pid_t
w
=
waitpid
(
pid
,
&
status
,
0
);
if
(
w
==
-
1
)
{
if
(
w
==
-
1
)
{
SYSERROR
(
"waitpid"
);
SYSERROR
(
"waitpid"
);
goto
out_fini_handler
;
goto
out_fini_handler
;
}
}
ret
=
write
(
pipe
,
&
status
,
sizeof
(
status
));
ret
=
write
(
status_
pipe
,
&
status
,
sizeof
(
status
));
close
(
pipe
);
close
(
status_
pipe
);
pipe
=
-
1
;
status_
pipe
=
-
1
;
if
(
sizeof
(
status
)
!=
ret
)
{
if
(
sizeof
(
status
)
!=
ret
)
{
SYSERROR
(
"failed to write all of status"
);
SYSERROR
(
"failed to write all of status"
);
...
@@ -640,7 +669,18 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
...
@@ -640,7 +669,18 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
if
(
WIFEXITED
(
status
))
{
if
(
WIFEXITED
(
status
))
{
if
(
WEXITSTATUS
(
status
))
{
if
(
WEXITSTATUS
(
status
))
{
ERROR
(
"criu process exited %d
\n
"
,
WEXITSTATUS
(
status
));
char
buf
[
4096
];
int
n
;
n
=
read
(
pipes
[
0
],
buf
,
sizeof
(
buf
));
if
(
n
<
0
)
{
SYSERROR
(
"failed reading from criu stderr"
);
goto
out_fini_handler
;
}
buf
[
n
]
=
0
;
ERROR
(
"criu process exited %d, output:
\n
%s
\n
"
,
WEXITSTATUS
(
status
),
buf
);
goto
out_fini_handler
;
goto
out_fini_handler
;
}
else
{
}
else
{
int
ret
;
int
ret
;
...
@@ -670,6 +710,8 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
...
@@ -670,6 +710,8 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
goto
out_fini_handler
;
goto
out_fini_handler
;
}
}
close
(
pipes
[
0
]);
/*
/*
* See comment in lxcapi_start; we don't care if these
* See comment in lxcapi_start; we don't care if these
* fail because it's just a beauty thing. We just
* fail because it's just a beauty thing. We just
...
@@ -686,17 +728,22 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
...
@@ -686,17 +728,22 @@ void do_restore(struct lxc_container *c, int pipe, char *directory, bool verbose
}
}
out_fini_handler:
out_fini_handler:
if
(
pipes
[
0
]
>=
0
)
close
(
pipes
[
0
]);
if
(
pipes
[
1
]
>=
0
)
close
(
pipes
[
1
]);
lxc_fini
(
c
->
name
,
handler
);
lxc_fini
(
c
->
name
,
handler
);
if
(
unlink
(
pidfile
)
<
0
&&
errno
!=
ENOENT
)
if
(
unlink
(
pidfile
)
<
0
&&
errno
!=
ENOENT
)
SYSERROR
(
"unlinking pidfile failed"
);
SYSERROR
(
"unlinking pidfile failed"
);
out:
out:
if
(
pipe
>=
0
)
{
if
(
status_
pipe
>=
0
)
{
status
=
1
;
status
=
1
;
if
(
write
(
pipe
,
&
status
,
sizeof
(
status
))
!=
sizeof
(
status
))
{
if
(
write
(
status_
pipe
,
&
status
,
sizeof
(
status
))
!=
sizeof
(
status
))
{
SYSERROR
(
"writing status failed"
);
SYSERROR
(
"writing status failed"
);
}
}
close
(
pipe
);
close
(
status_
pipe
);
}
}
exit
(
1
);
exit
(
1
);
...
...
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