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
00194067
Commit
00194067
authored
Dec 03, 2013
by
S.Çağlar Onur
Committed by
Serge Hallyn
Dec 04, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add destroy option to lxc-snapshot
Signed-off-by:
S.Çağlar Onur
<
caglar@10ur.org
>
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
parent
2b25068a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
lxc_snapshot.c
src/lxc/lxc_snapshot.c
+19
-3
No files found.
src/lxc/lxc_snapshot.c
View file @
00194067
...
@@ -41,6 +41,7 @@ char *snapshot;
...
@@ -41,6 +41,7 @@ char *snapshot;
#define DO_SNAP 0
#define DO_SNAP 0
#define DO_LIST 1
#define DO_LIST 1
#define DO_RESTORE 2
#define DO_RESTORE 2
#define DO_DESTROY 3
int
action
;
int
action
;
int
print_comments
;
int
print_comments
;
char
*
commentfile
;
char
*
commentfile
;
...
@@ -100,7 +101,7 @@ int do_list_snapshots(struct lxc_container *c)
...
@@ -100,7 +101,7 @@ int do_list_snapshots(struct lxc_container *c)
return
0
;
return
0
;
}
}
int
do_restore_snapshots
(
struct
lxc_container
*
c
,
char
*
snap
,
char
*
new
)
int
do_restore_snapshots
(
struct
lxc_container
*
c
)
{
{
if
(
c
->
snapshot_restore
(
c
,
snapshot
,
newname
))
if
(
c
->
snapshot_restore
(
c
,
snapshot
,
newname
))
return
0
;
return
0
;
...
@@ -109,11 +110,21 @@ int do_restore_snapshots(struct lxc_container *c, char *snap, char *new)
...
@@ -109,11 +110,21 @@ int do_restore_snapshots(struct lxc_container *c, char *snap, char *new)
return
-
1
;
return
-
1
;
}
}
int
do_destroy_snapshots
(
struct
lxc_container
*
c
)
{
if
(
c
->
snapshot_destroy
(
c
,
snapshot
))
return
0
;
ERROR
(
"Error destroying snapshot %s"
,
snapshot
);
return
-
1
;
}
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
{
{
switch
(
c
)
{
switch
(
c
)
{
case
'L'
:
action
=
DO_LIST
;
break
;
case
'L'
:
action
=
DO_LIST
;
break
;
case
'r'
:
snapshot
=
arg
;
action
=
DO_RESTORE
;
break
;
case
'r'
:
snapshot
=
arg
;
action
=
DO_RESTORE
;
break
;
case
'd'
:
snapshot
=
arg
;
action
=
DO_DESTROY
;
break
;
case
'c'
:
commentfile
=
arg
;
break
;
case
'c'
:
commentfile
=
arg
;
break
;
case
'C'
:
print_comments
=
true
;
break
;
case
'C'
:
print_comments
=
true
;
break
;
}
}
...
@@ -123,6 +134,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
...
@@ -123,6 +134,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
static
const
struct
option
my_longopts
[]
=
{
static
const
struct
option
my_longopts
[]
=
{
{
"list"
,
no_argument
,
0
,
'L'
},
{
"list"
,
no_argument
,
0
,
'L'
},
{
"restore"
,
required_argument
,
0
,
'r'
},
{
"restore"
,
required_argument
,
0
,
'r'
},
{
"destroy"
,
required_argument
,
0
,
'd'
},
{
"comment"
,
required_argument
,
0
,
'c'
},
{
"comment"
,
required_argument
,
0
,
'c'
},
{
"showcomments"
,
no_argument
,
0
,
'C'
},
{
"showcomments"
,
no_argument
,
0
,
'C'
},
LXC_COMMON_OPTIONS
LXC_COMMON_OPTIONS
...
@@ -141,7 +153,8 @@ Options :\n\
...
@@ -141,7 +153,8 @@ Options :\n\
-L, --list list snapshots
\n
\
-L, --list list snapshots
\n
\
-C, --showcomments show snapshot comments in list
\n
\
-C, --showcomments show snapshot comments in list
\n
\
-c, --comment=file add file as a comment
\n
\
-c, --comment=file add file as a comment
\n
\
-r, --restore=name restore snapshot name, i.e. 'snap0'
\n
"
,
-r, --restore=name restore snapshot name, i.e. 'snap0'
\n
\
-d, --destroy=name destroy snapshot name, i.e. 'snap0'
\n
"
,
.
options
=
my_longopts
,
.
options
=
my_longopts
,
.
parser
=
my_parser
,
.
parser
=
my_parser
,
.
checker
=
NULL
,
.
checker
=
NULL
,
...
@@ -202,7 +215,10 @@ int main(int argc, char *argv[])
...
@@ -202,7 +215,10 @@ int main(int argc, char *argv[])
ret
=
do_list_snapshots
(
c
);
ret
=
do_list_snapshots
(
c
);
break
;
break
;
case
DO_RESTORE
:
case
DO_RESTORE
:
ret
=
do_restore_snapshots
(
c
,
snapshot
,
newname
);
ret
=
do_restore_snapshots
(
c
);
break
;
case
DO_DESTROY
:
ret
=
do_destroy_snapshots
(
c
);
break
;
break
;
}
}
...
...
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