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
f79b86a3
Commit
f79b86a3
authored
Apr 28, 2014
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "snapshots: move snapshot directory"
This reverts commit
276a0862
. It breaks lxc-test-snapshot, and perhaps we should go with stgraber's suggestion of using $lxcpath/$lxcname/snaps/
parent
14622799
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
41 deletions
+12
-41
lxccontainer.c
src/lxc/lxccontainer.c
+10
-39
lxccontainer.h
src/lxc/lxccontainer.h
+2
-2
No files found.
src/lxc/lxccontainer.c
View file @
f79b86a3
...
@@ -2823,42 +2823,16 @@ static int get_next_index(const char *lxcpath, char *cname)
...
@@ -2823,42 +2823,16 @@ static int get_next_index(const char *lxcpath, char *cname)
}
}
}
}
static
bool
get_snappath_dir
(
struct
lxc_container
*
c
,
char
*
snappath
)
{
int
ret
;
/*
* If the old style snapshot path exists, use it
* /var/lib/lxc -> /var/lib/lxcsnaps
*/
ret
=
snprintf
(
snappath
,
MAXPATHLEN
,
"%ssnaps"
,
c
->
config_path
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
false
;
if
(
dir_exists
(
snappath
))
{
ret
=
snprintf
(
snappath
,
MAXPATHLEN
,
"%ssnaps/%s"
,
c
->
config_path
,
c
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
false
;
return
true
;
}
/*
* Use the new style path
* /var/lib/lxc -> /var/lib/lxc + /lxcsnaps/ + c->name + \0
*/
ret
=
snprintf
(
snappath
,
MAXPATHLEN
,
"%s/lxcsnaps/%s"
,
c
->
config_path
,
c
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
false
;
return
true
;
}
static
int
lxcapi_snapshot
(
struct
lxc_container
*
c
,
const
char
*
commentfile
)
static
int
lxcapi_snapshot
(
struct
lxc_container
*
c
,
const
char
*
commentfile
)
{
{
int
i
,
flags
,
ret
;
int
i
,
flags
,
ret
;
struct
lxc_container
*
c2
;
struct
lxc_container
*
c2
;
char
snappath
[
MAXPATHLEN
],
newname
[
20
];
char
snappath
[
MAXPATHLEN
],
newname
[
20
];
if
(
!
get_snappath_dir
(
c
,
snappath
))
{
// /var/lib/lxc -> /var/lib/lxcsnaps \0
ret
=
snprintf
(
snappath
,
MAXPATHLEN
,
"%ssnaps/%s"
,
c
->
config_path
,
c
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
return
-
1
;
return
-
1
;
}
i
=
get_next_index
(
snappath
,
c
->
name
);
i
=
get_next_index
(
snappath
,
c
->
name
);
if
(
mkdir_p
(
snappath
,
0755
)
<
0
)
{
if
(
mkdir_p
(
snappath
,
0755
)
<
0
)
{
...
@@ -2992,7 +2966,7 @@ static char *get_timestamp(char* snappath, char *name)
...
@@ -2992,7 +2966,7 @@ static char *get_timestamp(char* snappath, char *name)
static
int
lxcapi_snapshot_list
(
struct
lxc_container
*
c
,
struct
lxc_snapshot
**
ret_snaps
)
static
int
lxcapi_snapshot_list
(
struct
lxc_container
*
c
,
struct
lxc_snapshot
**
ret_snaps
)
{
{
char
snappath
[
MAXPATHLEN
],
path2
[
MAXPATHLEN
];
char
snappath
[
MAXPATHLEN
],
path2
[
MAXPATHLEN
];
int
count
=
0
,
ret
;
int
dirlen
,
count
=
0
,
ret
;
struct
dirent
dirent
,
*
direntp
;
struct
dirent
dirent
,
*
direntp
;
struct
lxc_snapshot
*
snaps
=
NULL
,
*
nsnaps
;
struct
lxc_snapshot
*
snaps
=
NULL
,
*
nsnaps
;
DIR
*
dir
;
DIR
*
dir
;
...
@@ -3000,7 +2974,9 @@ static int lxcapi_snapshot_list(struct lxc_container *c, struct lxc_snapshot **r
...
@@ -3000,7 +2974,9 @@ static int lxcapi_snapshot_list(struct lxc_container *c, struct lxc_snapshot **r
if
(
!
c
||
!
lxcapi_is_defined
(
c
))
if
(
!
c
||
!
lxcapi_is_defined
(
c
))
return
-
1
;
return
-
1
;
if
(
!
get_snappath_dir
(
c
,
snappath
))
{
// snappath is ${lxcpath}snaps/${lxcname}/
dirlen
=
snprintf
(
snappath
,
MAXPATHLEN
,
"%ssnaps/%s"
,
c
->
config_path
,
c
->
name
);
if
(
dirlen
<
0
||
dirlen
>=
MAXPATHLEN
)
{
ERROR
(
"path name too long"
);
ERROR
(
"path name too long"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -3068,7 +3044,7 @@ out_free:
...
@@ -3068,7 +3044,7 @@ out_free:
static
bool
lxcapi_snapshot_restore
(
struct
lxc_container
*
c
,
const
char
*
snapname
,
const
char
*
newname
)
static
bool
lxcapi_snapshot_restore
(
struct
lxc_container
*
c
,
const
char
*
snapname
,
const
char
*
newname
)
{
{
char
clonelxcpath
[
MAXPATHLEN
];
char
clonelxcpath
[
MAXPATHLEN
];
int
flags
=
0
;
int
flags
=
0
,
ret
;
struct
lxc_container
*
snap
,
*
rest
;
struct
lxc_container
*
snap
,
*
rest
;
struct
bdev
*
bdev
;
struct
bdev
*
bdev
;
bool
b
=
false
;
bool
b
=
false
;
...
@@ -3091,7 +3067,8 @@ static bool lxcapi_snapshot_restore(struct lxc_container *c, const char *snapnam
...
@@ -3091,7 +3067,8 @@ static bool lxcapi_snapshot_restore(struct lxc_container *c, const char *snapnam
return
false
;
return
false
;
}
}
}
}
if
(
!
get_snappath_dir
(
c
,
clonelxcpath
))
{
ret
=
snprintf
(
clonelxcpath
,
MAXPATHLEN
,
"%ssnaps/%s"
,
c
->
config_path
,
c
->
name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
bdev_put
(
bdev
);
bdev_put
(
bdev
);
return
false
;
return
false
;
}
}
...
@@ -3307,12 +3284,6 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath
...
@@ -3307,12 +3284,6 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
if
(
!
name
)
return
NULL
;
if
(
strcmp
(
name
,
"lxcsnaps"
)
==
0
)
return
NULL
;
c
=
malloc
(
sizeof
(
*
c
));
c
=
malloc
(
sizeof
(
*
c
));
if
(
!
c
)
{
if
(
!
c
)
{
fprintf
(
stderr
,
"failed to malloc lxc_container
\n
"
);
fprintf
(
stderr
,
"failed to malloc lxc_container
\n
"
);
...
...
src/lxc/lxccontainer.h
View file @
f79b86a3
...
@@ -649,7 +649,7 @@ struct lxc_container {
...
@@ -649,7 +649,7 @@ struct lxc_container {
* \brief Create a container snapshot.
* \brief Create a container snapshot.
*
*
* Assuming default paths, snapshots will be created as
* Assuming default paths, snapshots will be created as
* \c /var/lib/lxc
/lxc
snaps/\<c\>/snap\<n\>
* \c /var/lib/lxcsnaps/\<c\>/snap\<n\>
* where \c \<c\> represents the container name and \c \<n\>
* where \c \<c\> represents the container name and \c \<n\>
* represents the zero-based snapshot number.
* represents the zero-based snapshot number.
*
*
...
@@ -691,7 +691,7 @@ struct lxc_container {
...
@@ -691,7 +691,7 @@ struct lxc_container {
* fail if the snapshot is overlay-based, since the snapshots
* fail if the snapshot is overlay-based, since the snapshots
* will pin the original container.
* will pin the original container.
* \note As an example, if the container exists as \c /var/lib/lxc/c1, snapname might be \c 'snap0'
* \note As an example, if the container exists as \c /var/lib/lxc/c1, snapname might be \c 'snap0'
* (representing \c /var/lib/lxc
/lxc
snaps/c1/snap0). If \p newname is \p c2,
* (representing \c /var/lib/lxcsnaps/c1/snap0). If \p newname is \p c2,
* then \c snap0 will be copied to \c /var/lib/lxc/c2.
* then \c snap0 will be copied to \c /var/lib/lxc/c2.
*/
*/
bool
(
*
snapshot_restore
)(
struct
lxc_container
*
c
,
const
char
*
snapname
,
const
char
*
newname
);
bool
(
*
snapshot_restore
)(
struct
lxc_container
*
c
,
const
char
*
snapname
,
const
char
*
newname
);
...
...
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