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
5c218031
Commit
5c218031
authored
Apr 05, 2016
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #947 from brauner/bugfix_branch
add more error handling + cleanup copy_storage()
parents
bd08898f
763429b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
11 deletions
+27
-11
lxccontainer.c
src/lxc/lxccontainer.c
+27
-11
No files found.
src/lxc/lxccontainer.c
View file @
5c218031
...
@@ -2829,7 +2829,8 @@ bool should_default_to_snapshot(struct lxc_container *c0,
...
@@ -2829,7 +2829,8 @@ bool should_default_to_snapshot(struct lxc_container *c0,
}
}
static
int
copy_storage
(
struct
lxc_container
*
c0
,
struct
lxc_container
*
c
,
static
int
copy_storage
(
struct
lxc_container
*
c0
,
struct
lxc_container
*
c
,
const
char
*
newtype
,
int
flags
,
const
char
*
bdevdata
,
uint64_t
newsize
)
const
char
*
newtype
,
int
flags
,
const
char
*
bdevdata
,
uint64_t
newsize
)
{
{
struct
bdev
*
bdev
;
struct
bdev
*
bdev
;
int
need_rdep
;
int
need_rdep
;
...
@@ -2837,38 +2838,53 @@ static int copy_storage(struct lxc_container *c0, struct lxc_container *c,
...
@@ -2837,38 +2838,53 @@ static int copy_storage(struct lxc_container *c0, struct lxc_container *c,
if
(
should_default_to_snapshot
(
c0
,
c
))
if
(
should_default_to_snapshot
(
c0
,
c
))
flags
|=
LXC_CLONE_SNAPSHOT
;
flags
|=
LXC_CLONE_SNAPSHOT
;
bdev
=
bdev_copy
(
c0
,
c
->
name
,
c
->
config_path
,
newtype
,
flags
,
bdev
=
bdev_copy
(
c0
,
c
->
name
,
c
->
config_path
,
newtype
,
flags
,
bdevdata
,
bdevdata
,
newsize
,
&
need_rdep
);
newsize
,
&
need_rdep
);
if
(
!
bdev
)
{
if
(
!
bdev
)
{
ERROR
(
"Error copying storage"
);
ERROR
(
"Error copying storage
.
"
);
return
-
1
;
return
-
1
;
}
}
/* Set new rootfs. */
free
(
c
->
lxc_conf
->
rootfs
.
path
);
free
(
c
->
lxc_conf
->
rootfs
.
path
);
c
->
lxc_conf
->
rootfs
.
path
=
strdup
(
bdev
->
src
);
c
->
lxc_conf
->
rootfs
.
path
=
strdup
(
bdev
->
src
);
/* Set new bdev type. */
free
(
c
->
lxc_conf
->
rootfs
.
bdev_type
);
free
(
c
->
lxc_conf
->
rootfs
.
bdev_type
);
c
->
lxc_conf
->
rootfs
.
bdev_type
=
strdup
(
bdev
->
type
);
c
->
lxc_conf
->
rootfs
.
bdev_type
=
strdup
(
bdev
->
type
);
bdev_put
(
bdev
);
bdev_put
(
bdev
);
if
(
!
c
->
lxc_conf
->
rootfs
.
path
)
{
if
(
!
c
->
lxc_conf
->
rootfs
.
path
)
{
ERROR
(
"Out of memory while setting storage path"
);
ERROR
(
"Out of memory while setting storage path."
);
return
-
1
;
}
if
(
!
c
->
lxc_conf
->
rootfs
.
bdev_type
)
{
ERROR
(
"Out of memory while setting rootfs backend."
);
return
-
1
;
return
-
1
;
}
}
// We will simply append a new lxc.rootfs entry to the unexpanded config
/* Append a new lxc.rootfs entry to the unexpanded config. */
clear_unexp_config_line
(
c
->
lxc_conf
,
"lxc.rootfs"
,
false
);
clear_unexp_config_line
(
c
->
lxc_conf
,
"lxc.rootfs"
,
false
);
if
(
!
do_append_unexp_config_line
(
c
->
lxc_conf
,
"lxc.rootfs"
,
c
->
lxc_conf
->
rootfs
.
path
))
{
if
(
!
do_append_unexp_config_line
(
c
->
lxc_conf
,
"lxc.rootfs"
,
ERROR
(
"Error saving new rootfs to cloned config"
);
c
->
lxc_conf
->
rootfs
.
path
))
{
ERROR
(
"Error saving new rootfs to cloned config."
);
return
-
1
;
return
-
1
;
}
}
/* Append a new lxc.rootfs.backend entry to the unexpanded config. */
clear_unexp_config_line
(
c
->
lxc_conf
,
"lxc.rootfs.backend"
,
false
);
clear_unexp_config_line
(
c
->
lxc_conf
,
"lxc.rootfs.backend"
,
false
);
if
(
!
do_append_unexp_config_line
(
c
->
lxc_conf
,
"lxc.rootfs.backend"
,
c
->
lxc_conf
->
rootfs
.
bdev_type
))
{
if
(
!
do_append_unexp_config_line
(
c
->
lxc_conf
,
"lxc.rootfs.backend"
,
ERROR
(
"Error saving new rootfs to cloned config"
);
c
->
lxc_conf
->
rootfs
.
bdev_type
))
{
ERROR
(
"Error saving new rootfs backend to cloned config."
);
return
-
1
;
return
-
1
;
}
}
if
(
flags
&
LXC_CLONE_SNAPSHOT
)
if
(
flags
&
LXC_CLONE_SNAPSHOT
)
copy_rdepends
(
c
,
c0
);
copy_rdepends
(
c
,
c0
);
if
(
need_rdep
)
{
if
(
need_rdep
)
{
if
(
!
add_rdepends
(
c
,
c0
))
if
(
!
add_rdepends
(
c
,
c0
))
WARN
(
"Error adding reverse dependency from %s to %s"
,
WARN
(
"Error adding reverse dependency from %s to %s"
,
c
->
name
,
c0
->
name
);
c
->
name
,
c0
->
name
);
}
}
mod_all_rdeps
(
c
,
true
);
mod_all_rdeps
(
c
,
true
);
...
...
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