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
06d0056c
Unverified
Commit
06d0056c
authored
Nov 28, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: make storage_copy() cleaner
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
Signed-off-by:
Adrian Reber
<
areber@redhat.com
>
parent
e9e29a33
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
storage.c
src/lxc/storage/storage.c
+17
-17
storage.h
src/lxc/storage/storage.h
+1
-1
No files found.
src/lxc/storage/storage.c
View file @
06d0056c
...
@@ -338,16 +338,16 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
...
@@ -338,16 +338,16 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
uint64_t
newsize
,
bool
*
needs_rdep
)
uint64_t
newsize
,
bool
*
needs_rdep
)
{
{
int
ret
;
int
ret
;
struct
lxc_storage
*
orig
,
*
new
;
char
*
src_no_prefix
;
char
*
src_no_prefix
;
bool
snap
=
flags
&
LXC_CLONE_SNAPSHOT
;
struct
lxc_storage
*
new
,
*
orig
;
bool
maybe_snap
=
flags
&
LXC_CLONE_MAYBE_SNAPSHOT
;
bool
snap
=
(
flags
&
LXC_CLONE_SNAPSHOT
);
bool
keepbdevtype
=
flags
&
LXC_CLONE_KEEPBDEVTYPE
;
bool
maybe_snap
=
(
flags
&
LXC_CLONE_MAYBE_SNAPSHOT
);
bool
keepbdevtype
=
(
flags
&
LXC_CLONE_KEEPBDEVTYPE
);
const
char
*
src
=
c
->
lxc_conf
->
rootfs
.
path
;
const
char
*
src
=
c
->
lxc_conf
->
rootfs
.
path
;
const
char
*
oldname
=
c
->
name
;
const
char
*
oldname
=
c
->
name
;
const
char
*
oldpath
=
c
->
config_path
;
const
char
*
oldpath
=
c
->
config_path
;
struct
rsync_data
data
=
{
0
};
char
cmd_output
[
MAXPATHLEN
]
=
{
0
};
char
cmd_output
[
MAXPATHLEN
]
=
{
0
};
struct
rsync_data
data
=
{
0
};
if
(
!
src
)
{
if
(
!
src
)
{
ERROR
(
"No rootfs specified"
);
ERROR
(
"No rootfs specified"
);
...
@@ -365,7 +365,7 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
...
@@ -365,7 +365,7 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
orig
=
storage_init
(
c
->
lxc_conf
);
orig
=
storage_init
(
c
->
lxc_conf
);
if
(
!
orig
)
{
if
(
!
orig
)
{
ERROR
(
"Failed to detect storage driver for
\"
%s
\"
"
,
src
);
ERROR
(
"Failed to detect storage driver for
\"
%s
\"
"
,
oldname
);
return
NULL
;
return
NULL
;
}
}
...
@@ -434,11 +434,11 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
...
@@ -434,11 +434,11 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
/* get new bdev type */
/* get new bdev type */
new
=
storage_get
(
bdevtype
);
new
=
storage_get
(
bdevtype
);
if
(
!
new
)
{
if
(
!
new
)
{
ERROR
(
"Failed to initialize
\"
%s
\"
storage driver"
,
ERROR
(
"Failed to initialize
%s
storage driver"
,
bdevtype
?
bdevtype
:
orig
->
type
);
bdevtype
?
bdevtype
:
orig
->
type
);
goto
on_error_put_orig
;
goto
on_error_put_orig
;
}
}
TRACE
(
"Initialized
\"
%s
\"
storage driver"
,
new
->
type
);
TRACE
(
"Initialized
%s
storage driver"
,
new
->
type
);
/* create new paths */
/* create new paths */
ret
=
new
->
ops
->
clone_paths
(
orig
,
new
,
oldname
,
cname
,
oldpath
,
lxcpath
,
ret
=
new
->
ops
->
clone_paths
(
orig
,
new
,
oldname
,
cname
,
oldpath
,
lxcpath
,
...
@@ -452,14 +452,15 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
...
@@ -452,14 +452,15 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
* snapshot directory under "<lxcpath>/<name>/snaps/" we don't need to
* snapshot directory under "<lxcpath>/<name>/snaps/" we don't need to
* record a dependency. If we would restore would also fail.
* record a dependency. If we would restore would also fail.
*/
*/
if
((
!
strcmp
(
new
->
type
,
"overlay"
)
||
if
((
strcmp
(
new
->
type
,
"overlay"
)
==
0
||
!
strcmp
(
new
->
type
,
"overlayfs"
)
)
&&
strcmp
(
new
->
type
,
"overlayfs"
)
==
0
)
&&
ret
==
LXC_CLONE_SNAPSHOT
)
ret
==
LXC_CLONE_SNAPSHOT
)
*
needs_rdep
=
false
;
*
needs_rdep
=
false
;
/* btrfs */
/* btrfs */
if
(
!
strcmp
(
orig
->
type
,
"btrfs"
)
&&
!
strcmp
(
new
->
type
,
"btrfs"
))
{
if
(
!
strcmp
(
orig
->
type
,
"btrfs"
)
&&
!
strcmp
(
new
->
type
,
"btrfs"
))
{
bool
bret
=
false
;
bool
bret
;
if
(
snap
||
btrfs_same_fs
(
orig
->
dest
,
new
->
dest
)
==
0
)
if
(
snap
||
btrfs_same_fs
(
orig
->
dest
,
new
->
dest
)
==
0
)
bret
=
new
->
ops
->
snapshot
(
c
->
lxc_conf
,
orig
,
new
,
0
);
bret
=
new
->
ops
->
snapshot
(
c
->
lxc_conf
,
orig
,
new
,
0
);
else
else
...
@@ -472,10 +473,10 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
...
@@ -472,10 +473,10 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
/* lvm */
/* lvm */
if
(
!
strcmp
(
orig
->
type
,
"lvm"
)
&&
!
strcmp
(
new
->
type
,
"lvm"
))
{
if
(
!
strcmp
(
orig
->
type
,
"lvm"
)
&&
!
strcmp
(
new
->
type
,
"lvm"
))
{
bool
bret
=
false
;
bool
bret
;
if
(
snap
)
if
(
snap
)
bret
=
new
->
ops
->
snapshot
(
c
->
lxc_conf
,
orig
,
bret
=
new
->
ops
->
snapshot
(
c
->
lxc_conf
,
orig
,
new
,
newsize
);
new
,
newsize
);
else
else
bret
=
new
->
ops
->
copy
(
c
->
lxc_conf
,
orig
,
new
,
newsize
);
bret
=
new
->
ops
->
copy
(
c
->
lxc_conf
,
orig
,
new
,
newsize
);
if
(
!
bret
)
if
(
!
bret
)
...
@@ -486,11 +487,10 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
...
@@ -486,11 +487,10 @@ struct lxc_storage *storage_copy(struct lxc_container *c, const char *cname,
/* zfs */
/* zfs */
if
(
!
strcmp
(
orig
->
type
,
"zfs"
)
&&
!
strcmp
(
new
->
type
,
"zfs"
))
{
if
(
!
strcmp
(
orig
->
type
,
"zfs"
)
&&
!
strcmp
(
new
->
type
,
"zfs"
))
{
bool
bret
=
false
;
bool
bret
;
if
(
snap
)
if
(
snap
)
bret
=
new
->
ops
->
snapshot
(
c
->
lxc_conf
,
orig
,
new
,
bret
=
new
->
ops
->
snapshot
(
c
->
lxc_conf
,
orig
,
new
,
newsize
);
newsize
);
else
else
bret
=
new
->
ops
->
copy
(
c
->
lxc_conf
,
orig
,
new
,
newsize
);
bret
=
new
->
ops
->
copy
(
c
->
lxc_conf
,
orig
,
new
,
newsize
);
if
(
!
bret
)
if
(
!
bret
)
...
...
src/lxc/storage/storage.h
View file @
06d0056c
...
@@ -126,7 +126,7 @@ extern bool storage_can_backup(struct lxc_conf *conf);
...
@@ -126,7 +126,7 @@ extern bool storage_can_backup(struct lxc_conf *conf);
extern
struct
lxc_storage
*
storage_init
(
struct
lxc_conf
*
conf
);
extern
struct
lxc_storage
*
storage_init
(
struct
lxc_conf
*
conf
);
extern
struct
lxc_storage
*
storage_copy
(
struct
lxc_container
*
c
0
,
extern
struct
lxc_storage
*
storage_copy
(
struct
lxc_container
*
c
,
const
char
*
cname
,
const
char
*
lxcpath
,
const
char
*
cname
,
const
char
*
lxcpath
,
const
char
*
bdevtype
,
int
flags
,
const
char
*
bdevtype
,
int
flags
,
const
char
*
bdevdata
,
uint64_t
newsize
,
const
char
*
bdevdata
,
uint64_t
newsize
,
...
...
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