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
69dffc98
Commit
69dffc98
authored
Aug 26, 2016
by
Christian Brauner
Committed by
GitHub
Aug 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1152 from tych0/fix-migration-2.0.4
c/r: use /proc/self/tid/children instead of pidfile
parents
e854c5e3
75d219f0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
24 deletions
+14
-24
criu.c
src/lxc/criu.c
+14
-24
No files found.
src/lxc/criu.c
View file @
69dffc98
...
@@ -69,7 +69,6 @@ struct criu_opts {
...
@@ -69,7 +69,6 @@ struct criu_opts {
char
tty_id
[
32
];
/* the criu tty id for /dev/console, i.e. "tty[${rdev}:${dev}]" */
char
tty_id
[
32
];
/* the criu tty id for /dev/console, i.e. "tty[${rdev}:${dev}]" */
/* restore: the file to write the init process' pid into */
/* restore: the file to write the init process' pid into */
char
*
pidfile
;
const
char
*
cgroup_path
;
const
char
*
cgroup_path
;
int
console_fd
;
int
console_fd
;
/* The path that is bind mounted from /dev/console, if any. We don't
/* The path that is bind mounted from /dev/console, if any. We don't
...
@@ -176,10 +175,10 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -176,10 +175,10 @@ static void exec_criu(struct criu_opts *opts)
static_args
+=
2
;
static_args
+=
2
;
}
else
if
(
strcmp
(
opts
->
action
,
"restore"
)
==
0
)
{
}
else
if
(
strcmp
(
opts
->
action
,
"restore"
)
==
0
)
{
/* --root $(lxc_mount_point) --restore-detached
/* --root $(lxc_mount_point) --restore-detached
* --restore-sibling --
pidfile $foo --
cgroup-root $foo
* --restore-sibling --cgroup-root $foo
* --lsm-profile apparmor:whatever
* --lsm-profile apparmor:whatever
*/
*/
static_args
+=
10
;
static_args
+=
8
;
tty_info
[
0
]
=
0
;
tty_info
[
0
]
=
0
;
if
(
load_tty_major_minor
(
opts
->
user
->
directory
,
tty_info
,
sizeof
(
tty_info
)))
if
(
load_tty_major_minor
(
opts
->
user
->
directory
,
tty_info
,
sizeof
(
tty_info
)))
...
@@ -330,8 +329,6 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -330,8 +329,6 @@ static void exec_criu(struct criu_opts *opts)
DECLARE_ARG
(
opts
->
c
->
lxc_conf
->
rootfs
.
mount
);
DECLARE_ARG
(
opts
->
c
->
lxc_conf
->
rootfs
.
mount
);
DECLARE_ARG
(
"--restore-detached"
);
DECLARE_ARG
(
"--restore-detached"
);
DECLARE_ARG
(
"--restore-sibling"
);
DECLARE_ARG
(
"--restore-sibling"
);
DECLARE_ARG
(
"--pidfile"
);
DECLARE_ARG
(
opts
->
pidfile
);
DECLARE_ARG
(
"--cgroup-root"
);
DECLARE_ARG
(
"--cgroup-root"
);
DECLARE_ARG
(
opts
->
cgroup_path
);
DECLARE_ARG
(
opts
->
cgroup_path
);
...
@@ -604,13 +601,8 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
...
@@ -604,13 +601,8 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
{
{
pid_t
pid
;
pid_t
pid
;
struct
lxc_handler
*
handler
;
struct
lxc_handler
*
handler
;
int
fd
,
status
;
int
status
;
int
pipes
[
2
]
=
{
-
1
,
-
1
};
int
pipes
[
2
]
=
{
-
1
,
-
1
};
char
pidfile
[]
=
"criu_restore_XXXXXX"
;
fd
=
mkstemp
(
pidfile
);
if
(
fd
<
0
)
goto
out
;
handler
=
lxc_init
(
c
->
name
,
c
->
lxc_conf
,
c
->
config_path
);
handler
=
lxc_init
(
c
->
name
,
c
->
lxc_conf
,
c
->
config_path
);
if
(
!
handler
)
if
(
!
handler
)
...
@@ -690,7 +682,6 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
...
@@ -690,7 +682,6 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
os
.
action
=
"restore"
;
os
.
action
=
"restore"
;
os
.
user
=
opts
;
os
.
user
=
opts
;
os
.
c
=
c
;
os
.
c
=
c
;
os
.
pidfile
=
pidfile
;
os
.
cgroup_path
=
cgroup_canonical_path
(
handler
);
os
.
cgroup_path
=
cgroup_canonical_path
(
handler
);
os
.
console_fd
=
c
->
lxc_conf
->
console
.
slave
;
os
.
console_fd
=
c
->
lxc_conf
->
console
.
slave
;
os
.
criu_version
=
criu_version
;
os
.
criu_version
=
criu_version
;
...
@@ -742,8 +733,9 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
...
@@ -742,8 +733,9 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
}
}
if
(
WIFEXITED
(
status
))
{
if
(
WIFEXITED
(
status
))
{
if
(
WEXITSTATUS
(
status
))
{
char
buf
[
4096
];
char
buf
[
4096
];
if
(
WEXITSTATUS
(
status
))
{
int
n
;
int
n
;
n
=
read
(
pipes
[
0
],
buf
,
sizeof
(
buf
));
n
=
read
(
pipes
[
0
],
buf
,
sizeof
(
buf
));
...
@@ -758,18 +750,21 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
...
@@ -758,18 +750,21 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
goto
out_fini_handler
;
goto
out_fini_handler
;
}
else
{
}
else
{
int
ret
;
int
ret
;
FILE
*
f
=
fdopen
(
fd
,
"r"
);
ret
=
snprintf
(
buf
,
sizeof
(
buf
),
"/proc/self/task/%"
PRId64
"/children"
,
syscall
(
__NR_gettid
));
if
(
ret
<
0
||
ret
>=
sizeof
(
buf
))
{
ERROR
(
"snprintf'd too many characters: %d"
,
ret
);
goto
out_fini_handler
;
}
FILE
*
f
=
fopen
(
buf
,
"r"
);
if
(
!
f
)
{
if
(
!
f
)
{
SYSERROR
(
"couldn't read restore's
init pidfile %s
\n
"
,
pidfile
);
SYSERROR
(
"couldn't read restore's
children file %s
\n
"
,
buf
);
goto
out_fini_handler
;
goto
out_fini_handler
;
}
}
fd
=
-
1
;
ret
=
fscanf
(
f
,
"%d"
,
(
int
*
)
&
handler
->
pid
);
ret
=
fscanf
(
f
,
"%d"
,
(
int
*
)
&
handler
->
pid
);
fclose
(
f
);
fclose
(
f
);
if
(
unlink
(
pidfile
)
<
0
&&
errno
!=
ENOENT
)
SYSERROR
(
"unlinking pidfile failed"
);
if
(
ret
!=
1
)
{
if
(
ret
!=
1
)
{
ERROR
(
"reading restore pid failed"
);
ERROR
(
"reading restore pid failed"
);
goto
out_fini_handler
;
goto
out_fini_handler
;
...
@@ -809,8 +804,6 @@ out_fini_handler:
...
@@ -809,8 +804,6 @@ out_fini_handler:
close
(
pipes
[
1
]);
close
(
pipes
[
1
]);
lxc_fini
(
c
->
name
,
handler
);
lxc_fini
(
c
->
name
,
handler
);
if
(
unlink
(
pidfile
)
<
0
&&
errno
!=
ENOENT
)
SYSERROR
(
"unlinking pidfile failed"
);
out:
out:
if
(
status_pipe
>=
0
)
{
if
(
status_pipe
>=
0
)
{
...
@@ -821,9 +814,6 @@ out:
...
@@ -821,9 +814,6 @@ out:
close
(
status_pipe
);
close
(
status_pipe
);
}
}
if
(
fd
>
0
)
close
(
fd
);
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