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
6b63f7a1
Commit
6b63f7a1
authored
May 11, 2016
by
Christian Brauner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1019 from tych0/dont-force-irmap
Dont force irmap
parents
199cb1fe
19d1509c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
57 deletions
+51
-57
criu.c
src/lxc/criu.c
+38
-51
criu.h
src/lxc/criu.h
+3
-3
lxccontainer.c
src/lxc/lxccontainer.c
+3
-3
lxccontainer.h
src/lxc/lxccontainer.h
+7
-0
No files found.
src/lxc/criu.c
View file @
6b63f7a1
...
@@ -56,20 +56,13 @@ struct criu_opts {
...
@@ -56,20 +56,13 @@ struct criu_opts {
/* The type of criu invocation, one of "dump" or "restore" */
/* The type of criu invocation, one of "dump" or "restore" */
char
*
action
;
char
*
action
;
/*
The directory to pass to criu
*/
/*
the user-provided migrate options relevant to this action
*/
char
*
directory
;
struct
migrate_opts
*
user
;
/* The container to dump */
/* The container to dump */
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
/* Enable criu verbose mode? */
bool
verbose
;
/* (pre-)dump: a directory for the previous dump's images */
char
*
predump_dir
;
/* dump: stop the container or not after dumping? */
/* dump: stop the container or not after dumping? */
bool
stop
;
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 */
...
@@ -82,10 +75,6 @@ struct criu_opts {
...
@@ -82,10 +75,6 @@ struct criu_opts {
* different) on the target host. NULL if lxc.console = "none".
* different) on the target host. NULL if lxc.console = "none".
*/
*/
char
*
console_name
;
char
*
console_name
;
/* Address and port where a criu pageserver is listening */
char
*
pageserver_address
;
char
*
pageserver_port
;
};
};
static
int
load_tty_major_minor
(
char
*
directory
,
char
*
output
,
int
len
)
static
int
load_tty_major_minor
(
char
*
directory
,
char
*
output
,
int
len
)
...
@@ -126,7 +115,7 @@ static int load_tty_major_minor(char *directory, char *output, int len)
...
@@ -126,7 +115,7 @@ static int load_tty_major_minor(char *directory, char *output, int len)
static
void
exec_criu
(
struct
criu_opts
*
opts
)
static
void
exec_criu
(
struct
criu_opts
*
opts
)
{
{
char
**
argv
,
log
[
PATH_MAX
];
char
**
argv
,
log
[
PATH_MAX
];
int
static_args
=
2
4
,
argc
=
0
,
i
,
ret
;
int
static_args
=
2
3
,
argc
=
0
,
i
,
ret
;
int
netnr
=
0
;
int
netnr
=
0
;
struct
lxc_list
*
it
;
struct
lxc_list
*
it
;
...
@@ -145,7 +134,7 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -145,7 +134,7 @@ static void exec_criu(struct criu_opts *opts)
}
}
/* The command line always looks like:
/* The command line always looks like:
* criu $(action) --tcp-established --file-locks --link-remap
--force-irmap
\
* criu $(action) --tcp-established --file-locks --link-remap \
* --manage-cgroups action-script foo.sh -D $(directory) \
* --manage-cgroups action-script foo.sh -D $(directory) \
* -o $(directory)/$(action).log --ext-mount-map auto
* -o $(directory)/$(action).log --ext-mount-map auto
* --enable-external-sharing --enable-external-masters
* --enable-external-sharing --enable-external-masters
...
@@ -157,20 +146,24 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -157,20 +146,24 @@ static void exec_criu(struct criu_opts *opts)
static_args
+=
4
;
static_args
+=
4
;
/* --prev-images-dir <path-to-directory-A-relative-to-B> */
/* --prev-images-dir <path-to-directory-A-relative-to-B> */
if
(
opts
->
predump_dir
)
if
(
opts
->
user
->
predump_dir
)
static_args
+=
2
;
static_args
+=
2
;
/* --page-server --address <address> --port <port> */
/* --page-server --address <address> --port <port> */
if
(
opts
->
pageserver_address
&&
opts
->
pageserver_port
)
if
(
opts
->
user
->
pageserver_address
&&
opts
->
user
->
pageserver_port
)
static_args
+=
5
;
static_args
+=
5
;
/* --leave-running (only for final dump) */
/* --leave-running (only for final dump) */
if
(
strcmp
(
opts
->
action
,
"dump"
)
==
0
&&
!
opts
->
stop
)
if
(
strcmp
(
opts
->
action
,
"dump"
)
==
0
&&
!
opts
->
user
->
stop
)
static_args
++
;
static_args
++
;
/* --external tty[88,4] */
/* --external tty[88,4] */
if
(
opts
->
tty_id
[
0
])
if
(
opts
->
tty_id
[
0
])
static_args
+=
2
;
static_args
+=
2
;
/* --force-irmap */
if
(
!
opts
->
user
->
preserves_inodes
)
static_args
++
;
}
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 --pidfile $foo --cgroup-root $foo
...
@@ -179,7 +172,7 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -179,7 +172,7 @@ static void exec_criu(struct criu_opts *opts)
static_args
+=
10
;
static_args
+=
10
;
tty_info
[
0
]
=
0
;
tty_info
[
0
]
=
0
;
if
(
load_tty_major_minor
(
opts
->
directory
,
tty_info
,
sizeof
(
tty_info
)))
if
(
load_tty_major_minor
(
opts
->
user
->
directory
,
tty_info
,
sizeof
(
tty_info
)))
return
;
return
;
/* --inherit-fd fd[%d]:tty[%s] */
/* --inherit-fd fd[%d]:tty[%s] */
...
@@ -189,10 +182,10 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -189,10 +182,10 @@ static void exec_criu(struct criu_opts *opts)
return
;
return
;
}
}
if
(
opts
->
verbose
)
if
(
opts
->
user
->
verbose
)
static_args
++
;
static_args
++
;
ret
=
snprintf
(
log
,
PATH_MAX
,
"%s/%s.log"
,
opts
->
directory
,
opts
->
action
);
ret
=
snprintf
(
log
,
PATH_MAX
,
"%s/%s.log"
,
opts
->
user
->
directory
,
opts
->
action
);
if
(
ret
<
0
||
ret
>=
PATH_MAX
)
{
if
(
ret
<
0
||
ret
>=
PATH_MAX
)
{
ERROR
(
"logfile name too long
\n
"
);
ERROR
(
"logfile name too long
\n
"
);
return
;
return
;
...
@@ -225,7 +218,6 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -225,7 +218,6 @@ static void exec_criu(struct criu_opts *opts)
DECLARE_ARG
(
"--tcp-established"
);
DECLARE_ARG
(
"--tcp-established"
);
DECLARE_ARG
(
"--file-locks"
);
DECLARE_ARG
(
"--file-locks"
);
DECLARE_ARG
(
"--link-remap"
);
DECLARE_ARG
(
"--link-remap"
);
DECLARE_ARG
(
"--force-irmap"
);
DECLARE_ARG
(
"--manage-cgroups"
);
DECLARE_ARG
(
"--manage-cgroups"
);
DECLARE_ARG
(
"--ext-mount-map"
);
DECLARE_ARG
(
"--ext-mount-map"
);
DECLARE_ARG
(
"auto"
);
DECLARE_ARG
(
"auto"
);
...
@@ -236,11 +228,11 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -236,11 +228,11 @@ static void exec_criu(struct criu_opts *opts)
DECLARE_ARG
(
"--enable-fs"
);
DECLARE_ARG
(
"--enable-fs"
);
DECLARE_ARG
(
"tracefs"
);
DECLARE_ARG
(
"tracefs"
);
DECLARE_ARG
(
"-D"
);
DECLARE_ARG
(
"-D"
);
DECLARE_ARG
(
opts
->
directory
);
DECLARE_ARG
(
opts
->
user
->
directory
);
DECLARE_ARG
(
"-o"
);
DECLARE_ARG
(
"-o"
);
DECLARE_ARG
(
log
);
DECLARE_ARG
(
log
);
if
(
opts
->
verbose
)
if
(
opts
->
user
->
verbose
)
DECLARE_ARG
(
"-vvvvvv"
);
DECLARE_ARG
(
"-vvvvvv"
);
if
(
strcmp
(
opts
->
action
,
"dump"
)
==
0
||
strcmp
(
opts
->
action
,
"pre-dump"
)
==
0
)
{
if
(
strcmp
(
opts
->
action
,
"dump"
)
==
0
||
strcmp
(
opts
->
action
,
"pre-dump"
)
==
0
)
{
...
@@ -275,21 +267,24 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -275,21 +267,24 @@ static void exec_criu(struct criu_opts *opts)
DECLARE_ARG
(
opts
->
tty_id
);
DECLARE_ARG
(
opts
->
tty_id
);
}
}
if
(
opts
->
predump_dir
)
{
if
(
opts
->
user
->
predump_dir
)
{
DECLARE_ARG
(
"--prev-images-dir"
);
DECLARE_ARG
(
"--prev-images-dir"
);
DECLARE_ARG
(
opts
->
predump_dir
);
DECLARE_ARG
(
opts
->
user
->
predump_dir
);
}
}
if
(
opts
->
pageserver_address
&&
opts
->
pageserver_port
)
{
if
(
opts
->
user
->
pageserver_address
&&
opts
->
user
->
pageserver_port
)
{
DECLARE_ARG
(
"--page-server"
);
DECLARE_ARG
(
"--page-server"
);
DECLARE_ARG
(
"--address"
);
DECLARE_ARG
(
"--address"
);
DECLARE_ARG
(
opts
->
pageserver_address
);
DECLARE_ARG
(
opts
->
user
->
pageserver_address
);
DECLARE_ARG
(
"--port"
);
DECLARE_ARG
(
"--port"
);
DECLARE_ARG
(
opts
->
pageserver_port
);
DECLARE_ARG
(
opts
->
user
->
pageserver_port
);
}
}
if
(
!
opts
->
user
->
preserves_inodes
)
DECLARE_ARG
(
"--force-irmap"
);
/* only for final dump */
/* only for final dump */
if
(
strcmp
(
opts
->
action
,
"dump"
)
==
0
&&
!
opts
->
stop
)
if
(
strcmp
(
opts
->
action
,
"dump"
)
==
0
&&
!
opts
->
user
->
stop
)
DECLARE_ARG
(
"--leave-running"
);
DECLARE_ARG
(
"--leave-running"
);
}
else
if
(
strcmp
(
opts
->
action
,
"restore"
)
==
0
)
{
}
else
if
(
strcmp
(
opts
->
action
,
"restore"
)
==
0
)
{
void
*
m
;
void
*
m
;
...
@@ -556,7 +551,7 @@ out_unlock:
...
@@ -556,7 +551,7 @@ 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
status_pipe
,
char
*
directory
,
bool
verbose
)
void
do_restore
(
struct
lxc_container
*
c
,
int
status_pipe
,
struct
migrate_opts
*
opts
)
{
{
pid_t
pid
;
pid_t
pid
;
char
pidfile
[
L_tmpnam
];
char
pidfile
[
L_tmpnam
];
...
@@ -642,10 +637,9 @@ void do_restore(struct lxc_container *c, int status_pipe, char *directory, bool
...
@@ -642,10 +637,9 @@ void do_restore(struct lxc_container *c, int status_pipe, char *directory, bool
}
}
os
.
action
=
"restore"
;
os
.
action
=
"restore"
;
os
.
directory
=
directory
;
os
.
user
=
opts
;
os
.
c
=
c
;
os
.
c
=
c
;
os
.
pidfile
=
pidfile
;
os
.
pidfile
=
pidfile
;
os
.
verbose
=
verbose
;
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
;
...
@@ -829,16 +823,14 @@ static int save_tty_major_minor(char *directory, struct lxc_container *c, char *
...
@@ -829,16 +823,14 @@ static int save_tty_major_minor(char *directory, struct lxc_container *c, char *
}
}
/* do one of either predump or a regular dump */
/* do one of either predump or a regular dump */
static
bool
do_dump
(
struct
lxc_container
*
c
,
char
*
mode
,
char
*
directory
,
static
bool
do_dump
(
struct
lxc_container
*
c
,
char
*
mode
,
struct
migrate_opts
*
opts
)
bool
stop
,
bool
verbose
,
char
*
predump_dir
,
char
*
pageserver_address
,
char
*
pageserver_port
)
{
{
pid_t
pid
;
pid_t
pid
;
if
(
!
criu_ok
(
c
))
if
(
!
criu_ok
(
c
))
return
false
;
return
false
;
if
(
mkdir_p
(
directory
,
0700
)
<
0
)
if
(
mkdir_p
(
opts
->
directory
,
0700
)
<
0
)
return
false
;
return
false
;
pid
=
fork
();
pid
=
fork
();
...
@@ -851,16 +843,11 @@ static bool do_dump(struct lxc_container *c, char *mode, char *directory,
...
@@ -851,16 +843,11 @@ static bool do_dump(struct lxc_container *c, char *mode, char *directory,
struct
criu_opts
os
;
struct
criu_opts
os
;
os
.
action
=
mode
;
os
.
action
=
mode
;
os
.
directory
=
directory
;
os
.
user
=
opts
;
os
.
c
=
c
;
os
.
c
=
c
;
os
.
stop
=
stop
;
os
.
verbose
=
verbose
;
os
.
predump_dir
=
predump_dir
;
os
.
console_name
=
c
->
lxc_conf
->
console
.
path
;
os
.
console_name
=
c
->
lxc_conf
->
console
.
path
;
os
.
pageserver_address
=
pageserver_address
;
os
.
pageserver_port
=
pageserver_port
;
if
(
save_tty_major_minor
(
directory
,
c
,
os
.
tty_id
,
sizeof
(
os
.
tty_id
))
<
0
)
if
(
save_tty_major_minor
(
opts
->
directory
,
c
,
os
.
tty_id
,
sizeof
(
os
.
tty_id
))
<
0
)
exit
(
1
);
exit
(
1
);
/* exec_criu() returning is an error */
/* exec_criu() returning is an error */
...
@@ -891,17 +878,17 @@ static bool do_dump(struct lxc_container *c, char *mode, char *directory,
...
@@ -891,17 +878,17 @@ static bool do_dump(struct lxc_container *c, char *mode, char *directory,
}
}
}
}
bool
__criu_pre_dump
(
struct
lxc_container
*
c
,
char
*
directory
,
bool
verbose
,
char
*
predump_dir
,
char
*
pageserver_address
,
char
*
pageserver_port
)
bool
__criu_pre_dump
(
struct
lxc_container
*
c
,
struct
migrate_opts
*
opts
)
{
{
return
do_dump
(
c
,
"pre-dump"
,
directory
,
false
,
verbose
,
predump_dir
,
pageserver_address
,
pageserver_port
);
return
do_dump
(
c
,
"pre-dump"
,
opts
);
}
}
bool
__criu_dump
(
struct
lxc_container
*
c
,
char
*
directory
,
bool
stop
,
bool
verbose
,
char
*
predump_dir
,
char
*
pageserver_address
,
char
*
pageserver_port
)
bool
__criu_dump
(
struct
lxc_container
*
c
,
struct
migrate_opts
*
opts
)
{
{
char
path
[
PATH_MAX
];
char
path
[
PATH_MAX
];
int
ret
;
int
ret
;
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/inventory.img"
,
directory
);
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/inventory.img"
,
opts
->
directory
);
if
(
ret
<
0
||
ret
>=
sizeof
(
path
))
if
(
ret
<
0
||
ret
>=
sizeof
(
path
))
return
false
;
return
false
;
...
@@ -910,10 +897,10 @@ bool __criu_dump(struct lxc_container *c, char *directory, bool stop, bool verbo
...
@@ -910,10 +897,10 @@ bool __criu_dump(struct lxc_container *c, char *directory, bool stop, bool verbo
return
false
;
return
false
;
}
}
return
do_dump
(
c
,
"dump"
,
directory
,
stop
,
verbose
,
predump_dir
,
pageserver_address
,
pageserver_port
);
return
do_dump
(
c
,
"dump"
,
opts
);
}
}
bool
__criu_restore
(
struct
lxc_container
*
c
,
char
*
directory
,
bool
verbose
)
bool
__criu_restore
(
struct
lxc_container
*
c
,
struct
migrate_opts
*
opts
)
{
{
pid_t
pid
;
pid_t
pid
;
int
status
,
nread
;
int
status
,
nread
;
...
@@ -942,7 +929,7 @@ bool __criu_restore(struct lxc_container *c, char *directory, bool verbose)
...
@@ -942,7 +929,7 @@ bool __criu_restore(struct lxc_container *c, char *directory, bool verbose)
if
(
pid
==
0
)
{
if
(
pid
==
0
)
{
close
(
pipefd
[
0
]);
close
(
pipefd
[
0
]);
// this never returns
// this never returns
do_restore
(
c
,
pipefd
[
1
],
directory
,
verbose
);
do_restore
(
c
,
pipefd
[
1
],
opts
);
}
}
close
(
pipefd
[
1
]);
close
(
pipefd
[
1
]);
...
...
src/lxc/criu.h
View file @
6b63f7a1
...
@@ -27,8 +27,8 @@
...
@@ -27,8 +27,8 @@
#include <lxc/lxccontainer.h>
#include <lxc/lxccontainer.h>
bool
__criu_pre_dump
(
struct
lxc_container
*
c
,
char
*
directory
,
bool
verbose
,
char
*
predump_dir
,
char
*
pageserver_address
,
char
*
pageserver_port
);
bool
__criu_pre_dump
(
struct
lxc_container
*
c
,
struct
migrate_opts
*
opts
);
bool
__criu_dump
(
struct
lxc_container
*
c
,
char
*
directory
,
bool
stop
,
bool
verbose
,
char
*
predump_dir
,
char
*
pageserver_address
,
char
*
pageserver_port
);
bool
__criu_dump
(
struct
lxc_container
*
c
,
struct
migrate_opts
*
opts
);
bool
__criu_restore
(
struct
lxc_container
*
c
,
char
*
directory
,
bool
verbose
);
bool
__criu_restore
(
struct
lxc_container
*
c
,
struct
migrate_opts
*
opts
);
#endif
#endif
src/lxc/lxccontainer.c
View file @
6b63f7a1
...
@@ -3968,13 +3968,13 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
...
@@ -3968,13 +3968,13 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
switch
(
cmd
)
{
switch
(
cmd
)
{
case
MIGRATE_PRE_DUMP
:
case
MIGRATE_PRE_DUMP
:
ret
=
!
__criu_pre_dump
(
c
,
opts
->
directory
,
opts
->
verbose
,
opts
->
predump_dir
,
opts
->
pageserver_address
,
opts
->
pageserver_port
);
ret
=
!
__criu_pre_dump
(
c
,
opts
);
break
;
break
;
case
MIGRATE_DUMP
:
case
MIGRATE_DUMP
:
ret
=
!
__criu_dump
(
c
,
opts
->
directory
,
opts
->
stop
,
opts
->
verbose
,
opts
->
predump_dir
,
opts
->
pageserver_address
,
opts
->
pageserver_port
);
ret
=
!
__criu_dump
(
c
,
opts
);
break
;
break
;
case
MIGRATE_RESTORE
:
case
MIGRATE_RESTORE
:
ret
=
!
__criu_restore
(
c
,
opts
->
directory
,
opts
->
verbose
);
ret
=
!
__criu_restore
(
c
,
opts
);
break
;
break
;
default
:
default
:
ERROR
(
"invalid migrate command %u"
,
cmd
);
ERROR
(
"invalid migrate command %u"
,
cmd
);
...
...
src/lxc/lxccontainer.h
View file @
6b63f7a1
...
@@ -884,6 +884,13 @@ struct migrate_opts {
...
@@ -884,6 +884,13 @@ struct migrate_opts {
char
*
predump_dir
;
/* relative to directory above */
char
*
predump_dir
;
/* relative to directory above */
char
*
pageserver_address
;
/* where should memory pages be send? */
char
*
pageserver_address
;
/* where should memory pages be send? */
char
*
pageserver_port
;
char
*
pageserver_port
;
/* This flag indicates whether or not the container's rootfs will have
* the same inodes on checkpoint and restore. In the case of e.g. zfs
* send or btrfs send, or an LVM snapshot, this will be true, but it
* won't if e.g. you rsync the filesystems between two machines.
*/
bool
preserves_inodes
;
};
};
/*!
/*!
...
...
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