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
facdf925
Unverified
Commit
facdf925
authored
Mar 22, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
overlay: rewrite and simplify
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
0c241537
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
54 additions
and
40 deletions
+54
-40
conf.c
src/lxc/conf.c
+4
-4
conf.h
src/lxc/conf.h
+2
-2
list.h
src/lxc/list.h
+3
-3
lxccontainer.c
src/lxc/lxccontainer.c
+2
-3
btrfs.c
src/lxc/storage/btrfs.c
+1
-1
btrfs.h
src/lxc/storage/btrfs.h
+2
-2
dir.c
src/lxc/storage/dir.c
+1
-1
dir.h
src/lxc/storage/dir.h
+1
-1
loop.c
src/lxc/storage/loop.c
+1
-1
loop.h
src/lxc/storage/loop.h
+1
-1
lvm.c
src/lxc/storage/lvm.c
+1
-1
lvm.h
src/lxc/storage/lvm.h
+1
-1
nbd.c
src/lxc/storage/nbd.c
+1
-1
nbd.h
src/lxc/storage/nbd.h
+1
-1
overlay.c
src/lxc/storage/overlay.c
+0
-0
overlay.h
src/lxc/storage/overlay.h
+1
-1
rbd.c
src/lxc/storage/rbd.c
+1
-1
rbd.h
src/lxc/storage/rbd.h
+1
-1
storage.c
src/lxc/storage/storage.c
+9
-7
storage.h
src/lxc/storage/storage.h
+3
-2
storage_utils.h
src/lxc/storage/storage_utils.h
+10
-0
zfs.c
src/lxc/storage/zfs.c
+1
-1
zfs.h
src/lxc/storage/zfs.h
+1
-1
lxc_copy.c
src/lxc/tools/lxc_copy.c
+5
-3
No files found.
src/lxc/conf.c
View file @
facdf925
...
@@ -2795,8 +2795,8 @@ int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
...
@@ -2795,8 +2795,8 @@ int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
/* Return the host uid/gid to which the container root is mapped in val.
/* Return the host uid/gid to which the container root is mapped in val.
* Return true if id was found, false otherwise.
* Return true if id was found, false otherwise.
*/
*/
bool
get_mapped_rootid
(
struct
lxc_conf
*
conf
,
enum
idtype
idtype
,
static
bool
get_mapped_rootid
(
const
struct
lxc_conf
*
conf
,
enum
idtype
idtype
,
unsigned
long
*
val
)
unsigned
long
*
val
)
{
{
unsigned
nsid
;
unsigned
nsid
;
struct
id_map
*
map
;
struct
id_map
*
map
;
...
@@ -2820,7 +2820,7 @@ bool get_mapped_rootid(struct lxc_conf *conf, enum idtype idtype,
...
@@ -2820,7 +2820,7 @@ bool get_mapped_rootid(struct lxc_conf *conf, enum idtype idtype,
return
false
;
return
false
;
}
}
int
mapped_hostid
(
unsigned
id
,
struct
lxc_conf
*
conf
,
enum
idtype
idtype
)
int
mapped_hostid
(
unsigned
id
,
const
struct
lxc_conf
*
conf
,
enum
idtype
idtype
)
{
{
struct
id_map
*
map
;
struct
id_map
*
map
;
struct
lxc_list
*
it
;
struct
lxc_list
*
it
;
...
@@ -2871,7 +2871,7 @@ int chown_mapped_root_exec_wrapper(void *args)
...
@@ -2871,7 +2871,7 @@ int chown_mapped_root_exec_wrapper(void *args)
* root is privileged with respect to hostuid/hostgid X, allowing
* root is privileged with respect to hostuid/hostgid X, allowing
* him to do the chown.
* him to do the chown.
*/
*/
int
chown_mapped_root
(
const
char
*
path
,
struct
lxc_conf
*
conf
)
int
chown_mapped_root
(
const
char
*
path
,
const
struct
lxc_conf
*
conf
)
{
{
uid_t
rootuid
,
rootgid
;
uid_t
rootuid
,
rootgid
;
unsigned
long
val
;
unsigned
long
val
;
...
...
src/lxc/conf.h
View file @
facdf925
...
@@ -437,9 +437,9 @@ extern int lxc_setup(struct lxc_handler *handler);
...
@@ -437,9 +437,9 @@ extern int lxc_setup(struct lxc_handler *handler);
extern
int
lxc_setup_parent
(
struct
lxc_handler
*
handler
);
extern
int
lxc_setup_parent
(
struct
lxc_handler
*
handler
);
extern
int
setup_resource_limits
(
struct
lxc_list
*
limits
,
pid_t
pid
);
extern
int
setup_resource_limits
(
struct
lxc_list
*
limits
,
pid_t
pid
);
extern
int
find_unmapped_nsid
(
struct
lxc_conf
*
conf
,
enum
idtype
idtype
);
extern
int
find_unmapped_nsid
(
struct
lxc_conf
*
conf
,
enum
idtype
idtype
);
extern
int
mapped_hostid
(
unsigned
id
,
struct
lxc_conf
*
conf
,
extern
int
mapped_hostid
(
unsigned
id
,
const
struct
lxc_conf
*
conf
,
enum
idtype
idtype
);
enum
idtype
idtype
);
extern
int
chown_mapped_root
(
const
char
*
path
,
struct
lxc_conf
*
conf
);
extern
int
chown_mapped_root
(
const
char
*
path
,
const
struct
lxc_conf
*
conf
);
extern
int
userns_exec_1
(
struct
lxc_conf
*
conf
,
int
(
*
fn
)(
void
*
),
void
*
data
,
extern
int
userns_exec_1
(
struct
lxc_conf
*
conf
,
int
(
*
fn
)(
void
*
),
void
*
data
,
const
char
*
fn_name
);
const
char
*
fn_name
);
extern
int
userns_exec_full
(
struct
lxc_conf
*
conf
,
int
(
*
fn
)(
void
*
),
extern
int
userns_exec_full
(
struct
lxc_conf
*
conf
,
int
(
*
fn
)(
void
*
),
...
...
src/lxc/list.h
View file @
facdf925
...
@@ -58,19 +58,19 @@ static inline void lxc_list_add_elem(struct lxc_list *list, void *elem)
...
@@ -58,19 +58,19 @@ static inline void lxc_list_add_elem(struct lxc_list *list, void *elem)
}
}
/* Retrieve first element of list. */
/* Retrieve first element of list. */
static
inline
void
*
lxc_list_first_elem
(
struct
lxc_list
*
list
)
static
inline
void
*
lxc_list_first_elem
(
const
struct
lxc_list
*
list
)
{
{
return
list
->
next
->
elem
;
return
list
->
next
->
elem
;
}
}
/* Retrieve last element of list. */
/* Retrieve last element of list. */
static
inline
void
*
lxc_list_last_elem
(
struct
lxc_list
*
list
)
static
inline
void
*
lxc_list_last_elem
(
const
struct
lxc_list
*
list
)
{
{
return
list
->
prev
->
elem
;
return
list
->
prev
->
elem
;
}
}
/* Determine if list is empty. */
/* Determine if list is empty. */
static
inline
int
lxc_list_empty
(
struct
lxc_list
*
list
)
static
inline
int
lxc_list_empty
(
const
struct
lxc_list
*
list
)
{
{
return
list
==
list
->
next
;
return
list
==
list
->
next
;
}
}
...
...
src/lxc/lxccontainer.c
View file @
facdf925
...
@@ -1275,7 +1275,7 @@ static struct lxc_storage *do_storage_create(struct lxc_container *c,
...
@@ -1275,7 +1275,7 @@ static struct lxc_storage *do_storage_create(struct lxc_container *c,
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
return
NULL
;
return
NULL
;
bdev
=
storage_create
(
dest
,
type
,
c
->
name
,
specs
);
bdev
=
storage_create
(
dest
,
type
,
c
->
name
,
specs
,
c
->
lxc_conf
);
if
(
!
bdev
)
{
if
(
!
bdev
)
{
ERROR
(
"Failed to create
\"
%s
\"
storage"
,
type
);
ERROR
(
"Failed to create
\"
%s
\"
storage"
,
type
);
return
NULL
;
return
NULL
;
...
@@ -1290,8 +1290,7 @@ static struct lxc_storage *do_storage_create(struct lxc_container *c,
...
@@ -1290,8 +1290,7 @@ static struct lxc_storage *do_storage_create(struct lxc_container *c,
/* If we are not root, chown the rootfs dir to root in the target user
/* If we are not root, chown the rootfs dir to root in the target user
* namespace.
* namespace.
*/
*/
ret
=
geteuid
();
if
(
am_guest_unpriv
()
||
!
lxc_list_empty
(
&
c
->
lxc_conf
->
id_map
))
{
if
(
ret
!=
0
||
(
c
->
lxc_conf
&&
!
lxc_list_empty
(
&
c
->
lxc_conf
->
id_map
)))
{
ret
=
chown_mapped_root
(
bdev
->
dest
,
c
->
lxc_conf
);
ret
=
chown_mapped_root
(
bdev
->
dest
,
c
->
lxc_conf
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Error chowning
\"
%s
\"
to container root"
,
bdev
->
dest
);
ERROR
(
"Error chowning
\"
%s
\"
to container root"
,
bdev
->
dest
);
...
...
src/lxc/storage/btrfs.c
View file @
facdf925
...
@@ -906,7 +906,7 @@ int btrfs_destroy(struct lxc_storage *orig)
...
@@ -906,7 +906,7 @@ int btrfs_destroy(struct lxc_storage *orig)
}
}
int
btrfs_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
btrfs_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
)
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
)
{
{
int
ret
;
int
ret
;
size_t
len
;
size_t
len
;
...
...
src/lxc/storage/btrfs.h
View file @
facdf925
...
@@ -366,8 +366,8 @@ extern int btrfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -366,8 +366,8 @@ extern int btrfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
extern
int
btrfs_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
extern
int
btrfs_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
extern
int
btrfs_destroy
(
struct
lxc_storage
*
orig
);
extern
int
btrfs_destroy
(
struct
lxc_storage
*
orig
);
extern
bool
btrfs_detect
(
const
char
*
path
);
extern
bool
btrfs_detect
(
const
char
*
path
);
extern
int
btrfs_mount
(
struct
lxc_storage
*
bdev
);
extern
int
btrfs_mount
(
struct
lxc_storage
*
bdev
);
...
...
src/lxc/storage/dir.c
View file @
facdf925
...
@@ -58,7 +58,7 @@ int dir_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -58,7 +58,7 @@ int dir_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
}
}
int
dir_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
dir_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
)
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
)
{
{
int
ret
;
int
ret
;
const
char
*
src
;
const
char
*
src
;
...
...
src/lxc/storage/dir.h
View file @
facdf925
...
@@ -17,7 +17,7 @@ extern int dir_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -17,7 +17,7 @@ extern int dir_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
extern
int
dir_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
extern
int
dir_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
extern
int
dir_destroy
(
struct
lxc_storage
*
orig
);
extern
int
dir_destroy
(
struct
lxc_storage
*
orig
);
extern
bool
dir_detect
(
const
char
*
path
);
extern
bool
dir_detect
(
const
char
*
path
);
extern
int
dir_mount
(
struct
lxc_storage
*
bdev
);
extern
int
dir_mount
(
struct
lxc_storage
*
bdev
);
...
...
src/lxc/storage/loop.c
View file @
facdf925
...
@@ -114,7 +114,7 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -114,7 +114,7 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
}
}
int
loop_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
loop_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
)
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
)
{
{
__do_free
char
*
srcdev
=
NULL
;
__do_free
char
*
srcdev
=
NULL
;
const
char
*
fstype
;
const
char
*
fstype
;
...
...
src/lxc/storage/loop.h
View file @
facdf925
...
@@ -17,7 +17,7 @@ extern int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -17,7 +17,7 @@ extern int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
extern
int
loop_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
extern
int
loop_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
const
char
*
n
,
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
extern
int
loop_destroy
(
struct
lxc_storage
*
orig
);
extern
int
loop_destroy
(
struct
lxc_storage
*
orig
);
extern
bool
loop_detect
(
const
char
*
path
);
extern
bool
loop_detect
(
const
char
*
path
);
extern
int
loop_mount
(
struct
lxc_storage
*
bdev
);
extern
int
loop_mount
(
struct
lxc_storage
*
bdev
);
...
...
src/lxc/storage/lvm.c
View file @
facdf925
...
@@ -609,7 +609,7 @@ int lvm_destroy(struct lxc_storage *orig)
...
@@ -609,7 +609,7 @@ int lvm_destroy(struct lxc_storage *orig)
}
}
int
lvm_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
lvm_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
)
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
)
{
{
const
char
*
vg
,
*
thinpool
,
*
fstype
,
*
lv
=
n
;
const
char
*
vg
,
*
thinpool
,
*
fstype
,
*
lv
=
n
;
uint64_t
sz
;
uint64_t
sz
;
...
...
src/lxc/storage/lvm.h
View file @
facdf925
...
@@ -24,7 +24,7 @@ extern int lvm_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -24,7 +24,7 @@ extern int lvm_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
extern
int
lvm_destroy
(
struct
lxc_storage
*
orig
);
extern
int
lvm_destroy
(
struct
lxc_storage
*
orig
);
extern
int
lvm_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
extern
int
lvm_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
extern
bool
lvm_create_clone
(
struct
lxc_conf
*
conf
,
struct
lxc_storage
*
orig
,
extern
bool
lvm_create_clone
(
struct
lxc_conf
*
conf
,
struct
lxc_storage
*
orig
,
struct
lxc_storage
*
new
,
uint64_t
newsize
);
struct
lxc_storage
*
new
,
uint64_t
newsize
);
extern
bool
lvm_create_snapshot
(
struct
lxc_conf
*
conf
,
struct
lxc_storage
*
orig
,
extern
bool
lvm_create_snapshot
(
struct
lxc_conf
*
conf
,
struct
lxc_storage
*
orig
,
...
...
src/lxc/storage/nbd.c
View file @
facdf925
...
@@ -91,7 +91,7 @@ int nbd_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -91,7 +91,7 @@ int nbd_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
}
}
int
nbd_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
nbd_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
)
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
)
{
{
return
-
ENOSYS
;
return
-
ENOSYS
;
}
}
...
...
src/lxc/storage/nbd.h
View file @
facdf925
...
@@ -17,7 +17,7 @@ extern int nbd_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -17,7 +17,7 @@ extern int nbd_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
extern
int
nbd_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
extern
int
nbd_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
extern
int
nbd_destroy
(
struct
lxc_storage
*
orig
);
extern
int
nbd_destroy
(
struct
lxc_storage
*
orig
);
extern
bool
nbd_detect
(
const
char
*
path
);
extern
bool
nbd_detect
(
const
char
*
path
);
extern
int
nbd_mount
(
struct
lxc_storage
*
bdev
);
extern
int
nbd_mount
(
struct
lxc_storage
*
bdev
);
...
...
src/lxc/storage/overlay.c
View file @
facdf925
This diff is collapsed.
Click to expand it.
src/lxc/storage/overlay.h
View file @
facdf925
...
@@ -25,7 +25,7 @@ extern int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -25,7 +25,7 @@ extern int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
extern
int
ovl_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
extern
int
ovl_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
extern
int
ovl_destroy
(
struct
lxc_storage
*
orig
);
extern
int
ovl_destroy
(
struct
lxc_storage
*
orig
);
extern
bool
ovl_detect
(
const
char
*
path
);
extern
bool
ovl_detect
(
const
char
*
path
);
extern
int
ovl_mount
(
struct
lxc_storage
*
bdev
);
extern
int
ovl_mount
(
struct
lxc_storage
*
bdev
);
...
...
src/lxc/storage/rbd.c
View file @
facdf925
...
@@ -77,7 +77,7 @@ int rbd_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -77,7 +77,7 @@ int rbd_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
}
}
int
rbd_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
rbd_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
)
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
)
{
{
const
char
*
rbdpool
,
*
fstype
;
const
char
*
rbdpool
,
*
fstype
;
uint64_t
size
;
uint64_t
size
;
...
...
src/lxc/storage/rbd.h
View file @
facdf925
...
@@ -17,7 +17,7 @@ extern int rbd_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -17,7 +17,7 @@ extern int rbd_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
extern
int
rbd_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
extern
int
rbd_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
extern
int
rbd_destroy
(
struct
lxc_storage
*
orig
);
extern
int
rbd_destroy
(
struct
lxc_storage
*
orig
);
extern
bool
rbd_detect
(
const
char
*
path
);
extern
bool
rbd_detect
(
const
char
*
path
);
extern
int
rbd_mount
(
struct
lxc_storage
*
bdev
);
extern
int
rbd_mount
(
struct
lxc_storage
*
bdev
);
...
...
src/lxc/storage/storage.c
View file @
facdf925
...
@@ -259,7 +259,8 @@ struct lxc_storage *storage_get(const char *type)
...
@@ -259,7 +259,8 @@ struct lxc_storage *storage_get(const char *type)
static
struct
lxc_storage
*
do_storage_create
(
const
char
*
dest
,
const
char
*
type
,
static
struct
lxc_storage
*
do_storage_create
(
const
char
*
dest
,
const
char
*
type
,
const
char
*
cname
,
const
char
*
cname
,
struct
bdev_specs
*
specs
)
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
)
{
{
int
ret
;
int
ret
;
struct
lxc_storage
*
bdev
;
struct
lxc_storage
*
bdev
;
...
@@ -271,7 +272,7 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type,
...
@@ -271,7 +272,7 @@ static struct lxc_storage *do_storage_create(const char *dest, const char *type,
if
(
!
bdev
)
if
(
!
bdev
)
return
NULL
;
return
NULL
;
ret
=
bdev
->
ops
->
create
(
bdev
,
dest
,
cname
,
specs
);
ret
=
bdev
->
ops
->
create
(
bdev
,
dest
,
cname
,
specs
,
conf
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
storage_put
(
bdev
);
storage_put
(
bdev
);
return
NULL
;
return
NULL
;
...
@@ -521,14 +522,15 @@ on_error_put_orig:
...
@@ -521,14 +522,15 @@ on_error_put_orig:
* @specs: details about the backing store to create, like fstype
* @specs: details about the backing store to create, like fstype
*/
*/
struct
lxc_storage
*
storage_create
(
const
char
*
dest
,
const
char
*
type
,
struct
lxc_storage
*
storage_create
(
const
char
*
dest
,
const
char
*
type
,
const
char
*
cname
,
struct
bdev_specs
*
specs
)
const
char
*
cname
,
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
)
{
{
int
ret
;
int
ret
;
struct
lxc_storage
*
bdev
;
struct
lxc_storage
*
bdev
;
char
*
best_options
[]
=
{
"btrfs"
,
"zfs"
,
"lvm"
,
"dir"
,
"rbd"
,
NULL
};
char
*
best_options
[]
=
{
"btrfs"
,
"zfs"
,
"lvm"
,
"dir"
,
"rbd"
,
NULL
};
if
(
!
type
)
if
(
!
type
)
return
do_storage_create
(
dest
,
"dir"
,
cname
,
specs
);
return
do_storage_create
(
dest
,
"dir"
,
cname
,
specs
,
conf
);
ret
=
strcmp
(
type
,
"best"
);
ret
=
strcmp
(
type
,
"best"
);
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
...
@@ -537,7 +539,7 @@ struct lxc_storage *storage_create(const char *dest, const char *type,
...
@@ -537,7 +539,7 @@ struct lxc_storage *storage_create(const char *dest, const char *type,
* opinionated preferences.
* opinionated preferences.
*/
*/
for
(
i
=
0
;
best_options
[
i
];
i
++
)
{
for
(
i
=
0
;
best_options
[
i
];
i
++
)
{
bdev
=
do_storage_create
(
dest
,
best_options
[
i
],
cname
,
specs
);
bdev
=
do_storage_create
(
dest
,
best_options
[
i
],
cname
,
specs
,
conf
);
if
(
bdev
)
if
(
bdev
)
return
bdev
;
return
bdev
;
}
}
...
@@ -552,13 +554,13 @@ struct lxc_storage *storage_create(const char *dest, const char *type,
...
@@ -552,13 +554,13 @@ struct lxc_storage *storage_create(const char *dest, const char *type,
dup
=
must_copy_string
(
type
);
dup
=
must_copy_string
(
type
);
lxc_iterate_parts
(
token
,
dup
,
","
)
{
lxc_iterate_parts
(
token
,
dup
,
","
)
{
bdev
=
do_storage_create
(
dest
,
token
,
cname
,
specs
);
bdev
=
do_storage_create
(
dest
,
token
,
cname
,
specs
,
conf
);
if
(
bdev
)
if
(
bdev
)
return
bdev
;
return
bdev
;
}
}
}
}
return
do_storage_create
(
dest
,
type
,
cname
,
specs
);
return
do_storage_create
(
dest
,
type
,
cname
,
specs
,
conf
);
}
}
bool
storage_destroy
(
struct
lxc_conf
*
conf
)
bool
storage_destroy
(
struct
lxc_conf
*
conf
)
...
...
src/lxc/storage/storage.h
View file @
facdf925
...
@@ -54,7 +54,7 @@ struct lxc_storage_ops {
...
@@ -54,7 +54,7 @@ struct lxc_storage_ops {
int
(
*
umount
)(
struct
lxc_storage
*
bdev
);
int
(
*
umount
)(
struct
lxc_storage
*
bdev
);
int
(
*
destroy
)(
struct
lxc_storage
*
bdev
);
int
(
*
destroy
)(
struct
lxc_storage
*
bdev
);
int
(
*
create
)(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
(
*
create
)(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
/* given original mount, rename the paths for cloned container */
/* given original mount, rename the paths for cloned container */
int
(
*
clone_paths
)(
struct
lxc_storage
*
orig
,
struct
lxc_storage
*
new
,
int
(
*
clone_paths
)(
struct
lxc_storage
*
orig
,
struct
lxc_storage
*
new
,
const
char
*
oldname
,
const
char
*
cname
,
const
char
*
oldname
,
const
char
*
cname
,
...
@@ -111,7 +111,8 @@ extern struct lxc_storage *storage_copy(struct lxc_container *c,
...
@@ -111,7 +111,8 @@ extern struct lxc_storage *storage_copy(struct lxc_container *c,
bool
*
needs_rdep
);
bool
*
needs_rdep
);
extern
struct
lxc_storage
*
storage_create
(
const
char
*
dest
,
const
char
*
type
,
extern
struct
lxc_storage
*
storage_create
(
const
char
*
dest
,
const
char
*
type
,
const
char
*
cname
,
const
char
*
cname
,
struct
bdev_specs
*
specs
);
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
extern
void
storage_put
(
struct
lxc_storage
*
bdev
);
extern
void
storage_put
(
struct
lxc_storage
*
bdev
);
extern
bool
storage_destroy
(
struct
lxc_conf
*
conf
);
extern
bool
storage_destroy
(
struct
lxc_conf
*
conf
);
extern
bool
rootfs_is_blockdev
(
struct
lxc_conf
*
conf
);
extern
bool
rootfs_is_blockdev
(
struct
lxc_conf
*
conf
);
...
...
src/lxc/storage/storage_utils.h
View file @
facdf925
...
@@ -5,9 +5,19 @@
...
@@ -5,9 +5,19 @@
#include <stdbool.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
#include "conf.h"
#include "conf.h"
#include "macro.h"
#define LXC_OVERLAY_PRIVATE_DIR "overlay"
#define LXC_OVERLAY_DELTA_DIR "delta"
#define LXC_OVERLAY_WORK_DIR "work"
#define LXC_OVERLAY_DELTA_PATH LXC_OVERLAY_PRIVATE_DIR "/" LXC_OVERLAY_DELTA_DIR
#define LXC_OVERLAY_WORK_PATH LXC_OVERLAY_PRIVATE_DIR "/" LXC_OVERLAY_WORK_DIR
#define LXC_OVERLAY_PATH_LEN \
(STRLITERALLEN(LXC_OVERLAY_PRIVATE_DIR) + STRLITERALLEN("/") + 256 + 1)
struct
lxc_storage
;
struct
lxc_storage
;
struct
lxc_conf
;
struct
lxc_conf
;
...
...
src/lxc/storage/zfs.c
View file @
facdf925
...
@@ -684,7 +684,7 @@ int zfs_destroy(struct lxc_storage *orig)
...
@@ -684,7 +684,7 @@ int zfs_destroy(struct lxc_storage *orig)
}
}
int
zfs_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
zfs_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
)
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
)
{
{
const
char
*
zfsroot
;
const
char
*
zfsroot
;
int
ret
;
int
ret
;
...
...
src/lxc/storage/zfs.h
View file @
facdf925
...
@@ -18,7 +18,7 @@ extern int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -18,7 +18,7 @@ extern int zfs_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
const
char
*
oldpath
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
uint64_t
newsize
,
struct
lxc_conf
*
conf
);
extern
int
zfs_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
extern
int
zfs_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
);
struct
bdev_specs
*
specs
,
const
struct
lxc_conf
*
conf
);
extern
int
zfs_destroy
(
struct
lxc_storage
*
orig
);
extern
int
zfs_destroy
(
struct
lxc_storage
*
orig
);
extern
bool
zfs_detect
(
const
char
*
path
);
extern
bool
zfs_detect
(
const
char
*
path
);
extern
int
zfs_mount
(
struct
lxc_storage
*
bdev
);
extern
int
zfs_mount
(
struct
lxc_storage
*
bdev
);
...
...
src/lxc/tools/lxc_copy.c
View file @
facdf925
...
@@ -772,9 +772,11 @@ static char *mount_tmpfs(const char *oldname, const char *newname,
...
@@ -772,9 +772,11 @@ static char *mount_tmpfs(const char *oldname, const char *newname,
goto
err_close
;
goto
err_close
;
if
(
!
arg
->
keepname
)
{
if
(
!
arg
->
keepname
)
{
ret
=
fprintf
(
fp
,
"mkdir -p %s/%s/delta0/etc
\n
"
ret
=
fprintf
(
fp
,
"echo %s > %s/%s/delta0/etc/hostname
\n
"
,
"mkdir -p %s/%s/%s/etc
\n
"
path
,
newname
,
newname
,
path
,
newname
);
"echo %s > %s/%s/%s/etc/hostname
\n
"
,
path
,
newname
,
LXC_OVERLAY_DELTA_PATH
,
newname
,
path
,
newname
,
LXC_OVERLAY_DELTA_PATH
);
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
err_close
;
goto
err_close
;
}
}
...
...
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