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
504687d5
Commit
504687d5
authored
Mar 26, 2015
by
Tycho Andersen
Committed by
Stéphane Graber
Apr 10, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c/r: tell CRIU about all external mounts in the config
Signed-off-by:
Tycho Andersen
<
tycho.andersen@canonical.com
>
Acked-by:
Stéphane Graber
<
stgraber@ubuntu.com
>
parent
b75e9e23
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
13 deletions
+91
-13
conf.c
src/lxc/conf.c
+14
-4
conf.h
src/lxc/conf.h
+2
-0
list.h
src/lxc/list.h
+11
-0
lxccontainer.c
src/lxc/lxccontainer.c
+64
-9
No files found.
src/lxc/conf.c
View file @
504687d5
...
@@ -2051,18 +2051,16 @@ static int setup_mount(const struct lxc_rootfs *rootfs, const char *fstab,
...
@@ -2051,18 +2051,16 @@ static int setup_mount(const struct lxc_rootfs *rootfs, const char *fstab,
return
ret
;
return
ret
;
}
}
static
int
setup_mount_entries
(
const
struct
lxc_rootfs
*
rootfs
,
struct
lxc_list
*
mount
,
FILE
*
write_mount_file
(
struct
lxc_list
*
mount
)
const
char
*
lxc_name
)
{
{
FILE
*
file
;
FILE
*
file
;
struct
lxc_list
*
iterator
;
struct
lxc_list
*
iterator
;
char
*
mount_entry
;
char
*
mount_entry
;
int
ret
;
file
=
tmpfile
();
file
=
tmpfile
();
if
(
!
file
)
{
if
(
!
file
)
{
ERROR
(
"tmpfile error: %m"
);
ERROR
(
"tmpfile error: %m"
);
return
-
1
;
return
NULL
;
}
}
lxc_list_for_each
(
iterator
,
mount
)
{
lxc_list_for_each
(
iterator
,
mount
)
{
...
@@ -2071,6 +2069,18 @@ static int setup_mount_entries(const struct lxc_rootfs *rootfs, struct lxc_list
...
@@ -2071,6 +2069,18 @@ static int setup_mount_entries(const struct lxc_rootfs *rootfs, struct lxc_list
}
}
rewind
(
file
);
rewind
(
file
);
return
file
;
}
static
int
setup_mount_entries
(
const
struct
lxc_rootfs
*
rootfs
,
struct
lxc_list
*
mount
,
const
char
*
lxc_name
)
{
FILE
*
file
;
int
ret
;
file
=
write_mount_file
(
mount
);
if
(
!
file
)
return
-
1
;
ret
=
mount_file_entries
(
rootfs
,
file
,
lxc_name
);
ret
=
mount_file_entries
(
rootfs
,
file
,
lxc_name
);
...
...
src/lxc/conf.h
View file @
504687d5
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "config.h"
#include "config.h"
#include <stdio.h>
#include <netinet/in.h>
#include <netinet/in.h>
#include <net/if.h>
#include <net/if.h>
#include <sys/param.h>
#include <sys/param.h>
...
@@ -428,4 +429,5 @@ extern int parse_mntopts(const char *mntopts, unsigned long *mntflags,
...
@@ -428,4 +429,5 @@ extern int parse_mntopts(const char *mntopts, unsigned long *mntflags,
extern
void
tmp_proc_unmount
(
struct
lxc_conf
*
lxc_conf
);
extern
void
tmp_proc_unmount
(
struct
lxc_conf
*
lxc_conf
);
void
remount_all_slave
(
void
);
void
remount_all_slave
(
void
);
extern
void
suggest_default_idmap
(
void
);
extern
void
suggest_default_idmap
(
void
);
FILE
*
write_mount_file
(
struct
lxc_list
*
mount
);
#endif
#endif
src/lxc/list.h
View file @
504687d5
...
@@ -99,4 +99,15 @@ static inline void lxc_list_del(struct lxc_list *list)
...
@@ -99,4 +99,15 @@ static inline void lxc_list_del(struct lxc_list *list)
prev
->
next
=
next
;
prev
->
next
=
next
;
}
}
static
inline
int
lxc_list_len
(
struct
lxc_list
*
list
)
{
int
i
=
0
;
struct
lxc_list
*
iter
;
lxc_list_for_each
(
iter
,
list
)
{
i
++
;
}
return
i
;
}
#endif
#endif
src/lxc/lxccontainer.c
View file @
504687d5
...
@@ -35,6 +35,8 @@
...
@@ -35,6 +35,8 @@
#include <libgen.h>
#include <libgen.h>
#include <stdint.h>
#include <stdint.h>
#include <grp.h>
#include <grp.h>
#include <stdio.h>
#include <mntent.h>
#include <sys/syscall.h>
#include <sys/syscall.h>
#include <lxc/lxccontainer.h>
#include <lxc/lxccontainer.h>
...
@@ -3698,11 +3700,15 @@ struct criu_opts {
...
@@ -3698,11 +3700,15 @@ struct criu_opts {
static
void
exec_criu
(
struct
criu_opts
*
opts
)
static
void
exec_criu
(
struct
criu_opts
*
opts
)
{
{
char
**
argv
,
log
[
PATH_MAX
]
,
buf
[
257
]
;
char
**
argv
,
log
[
PATH_MAX
];
int
static_args
=
14
,
argc
=
0
,
i
,
ret
;
int
static_args
=
14
,
argc
=
0
,
i
,
ret
;
int
netnr
=
0
;
int
netnr
=
0
;
struct
lxc_list
*
it
;
struct
lxc_list
*
it
;
struct
mntent
mntent
;
char
buf
[
4096
];
FILE
*
mnts
=
NULL
;
/* 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 --force-irmap \
* --manage-cgroups action-script foo.sh -D $(directory) \
* --manage-cgroups action-script foo.sh -D $(directory) \
...
@@ -3777,6 +3783,27 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -3777,6 +3783,27 @@ static void exec_criu(struct criu_opts *opts)
if
(
opts
->
verbose
)
if
(
opts
->
verbose
)
DECLARE_ARG
(
"-vvvvvv"
);
DECLARE_ARG
(
"-vvvvvv"
);
/*
* Note: this macro is not intended to be called unless argc is equal
* to the length of the array; there is nothing that keeps track of the
* length of the array besides the location in the code that this is
* called. (Yes this is bad, and we should fix it.)
*/
#define RESIZE_ARGS(additional) \
do { \
void *m; \
if (additional < 0) { \
ERROR("resizing by negative amount"); \
goto err; \
} else if (additional == 0) \
continue; \
\
m = realloc(argv, (argc + additional + 1) * sizeof(*argv)); \
if (!m) \
goto err; \
argv = m; \
} while (0)
if
(
strcmp
(
opts
->
action
,
"dump"
)
==
0
)
{
if
(
strcmp
(
opts
->
action
,
"dump"
)
==
0
)
{
char
pid
[
32
];
char
pid
[
32
];
...
@@ -3808,9 +3835,10 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -3808,9 +3835,10 @@ static void exec_criu(struct criu_opts *opts)
DECLARE_ARG
(
"--cgroup-root"
);
DECLARE_ARG
(
"--cgroup-root"
);
DECLARE_ARG
(
opts
->
cgroup_path
);
DECLARE_ARG
(
opts
->
cgroup_path
);
RESIZE_ARGS
(
lxc_list_len
(
&
opts
->
c
->
lxc_conf
->
network
)
*
2
);
lxc_list_for_each
(
it
,
&
opts
->
c
->
lxc_conf
->
network
)
{
lxc_list_for_each
(
it
,
&
opts
->
c
->
lxc_conf
->
network
)
{
char
eth
[
128
],
*
veth
;
char
eth
[
128
],
*
veth
;
void
*
m
;
struct
lxc_netdev
*
n
=
it
->
elem
;
struct
lxc_netdev
*
n
=
it
->
elem
;
if
(
n
->
name
)
{
if
(
n
->
name
)
{
...
@@ -3826,18 +3854,42 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -3826,18 +3854,42 @@ static void exec_criu(struct criu_opts *opts)
if
(
ret
<
0
||
ret
>=
sizeof
(
buf
))
if
(
ret
<
0
||
ret
>=
sizeof
(
buf
))
goto
err
;
goto
err
;
/* final NULL and --veth-pair eth0=vethASDF */
m
=
realloc
(
argv
,
(
argc
+
1
+
2
)
*
sizeof
(
*
argv
));
if
(
!
m
)
goto
err
;
argv
=
m
;
DECLARE_ARG
(
"--veth-pair"
);
DECLARE_ARG
(
"--veth-pair"
);
DECLARE_ARG
(
buf
);
DECLARE_ARG
(
buf
);
argv
[
argc
]
=
NULL
;
}
}
// CRIU wants to know about any external bind mounts the
// container has.
mnts
=
write_mount_file
(
&
opts
->
c
->
lxc_conf
->
mount_list
);
if
(
!
mnts
)
goto
err
;
RESIZE_ARGS
(
lxc_list_len
(
&
opts
->
c
->
lxc_conf
->
mount_list
)
*
2
);
while
(
getmntent_r
(
mnts
,
&
mntent
,
buf
,
sizeof
(
buf
)))
{
char
arg
[
2048
],
*
key
,
*
val
;
int
ret
;
if
(
strcmp
(
opts
->
action
,
"dump"
)
==
0
)
{
key
=
mntent
.
mnt_fsname
;
val
=
mntent
.
mnt_dir
;
}
else
{
key
=
mntent
.
mnt_dir
;
val
=
mntent
.
mnt_fsname
;
}
}
ret
=
snprintf
(
arg
,
sizeof
(
arg
),
"%s:%s"
,
key
,
val
);
if
(
ret
<
0
||
ret
>=
sizeof
(
arg
))
{
goto
err
;
}
DECLARE_ARG
(
"--ext-mount-map"
);
DECLARE_ARG
(
arg
);
}
}
fclose
(
mnts
);
argv
[
argc
]
=
NULL
;
netnr
=
0
;
netnr
=
0
;
lxc_list_for_each
(
it
,
&
opts
->
c
->
lxc_conf
->
network
)
{
lxc_list_for_each
(
it
,
&
opts
->
c
->
lxc_conf
->
network
)
{
...
@@ -3873,8 +3925,11 @@ static void exec_criu(struct criu_opts *opts)
...
@@ -3873,8 +3925,11 @@ static void exec_criu(struct criu_opts *opts)
}
}
#undef DECLARE_ARG
#undef DECLARE_ARG
#undef RESIZE_ARGS
execv
(
argv
[
0
],
argv
);
execv
(
argv
[
0
],
argv
);
err:
err:
if
(
mnts
)
fclose
(
mnts
);
for
(
i
=
0
;
argv
[
i
];
i
++
)
for
(
i
=
0
;
argv
[
i
];
i
++
)
free
(
argv
[
i
]);
free
(
argv
[
i
]);
free
(
argv
);
free
(
argv
);
...
...
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