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
2fa8e2cd
Commit
2fa8e2cd
authored
Feb 10, 2016
by
Christian Brauner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #811 from hallyn/2016-02-09/destroyquiet
lxc_destroy: be quiet if asked
parents
f97ab3a6
2f0e6b79
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
lxc_destroy.c
src/lxc/lxc_destroy.c
+21
-9
No files found.
src/lxc/lxc_destroy.c
View file @
2fa8e2cd
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
lxc_log_define
(
lxc_destroy_ui
,
lxc
);
lxc_log_define
(
lxc_destroy_ui
,
lxc
);
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
static
bool
quiet
;
static
const
struct
option
my_longopts
[]
=
{
static
const
struct
option
my_longopts
[]
=
{
{
"force"
,
no_argument
,
0
,
'f'
},
{
"force"
,
no_argument
,
0
,
'f'
},
...
@@ -75,28 +76,34 @@ int main(int argc, char *argv[])
...
@@ -75,28 +76,34 @@ int main(int argc, char *argv[])
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
my_args
.
progname
,
my_args
.
quiet
,
my_args
.
lxcpath
[
0
]))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
if
(
my_args
.
quiet
)
quiet
=
true
;
c
=
lxc_container_new
(
my_args
.
name
,
my_args
.
lxcpath
[
0
]);
c
=
lxc_container_new
(
my_args
.
name
,
my_args
.
lxcpath
[
0
]);
if
(
!
c
)
{
if
(
!
c
)
{
fprintf
(
stderr
,
"System error loading container
\n
"
);
if
(
!
quiet
)
fprintf
(
stderr
,
"System error loading container
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
!
c
->
may_control
(
c
))
{
if
(
!
c
->
may_control
(
c
))
{
fprintf
(
stderr
,
"Insufficent privileges to control %s
\n
"
,
my_args
.
name
);
if
(
!
quiet
)
fprintf
(
stderr
,
"Insufficent privileges to control %s
\n
"
,
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
!
c
->
is_defined
(
c
))
{
if
(
!
c
->
is_defined
(
c
))
{
fprintf
(
stderr
,
"Container is not defined
\n
"
);
if
(
!
quiet
)
fprintf
(
stderr
,
"Container is not defined
\n
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
c
->
is_running
(
c
))
{
if
(
c
->
is_running
(
c
))
{
if
(
!
my_args
.
force
)
{
if
(
!
my_args
.
force
)
{
fprintf
(
stderr
,
"%s is running
\n
"
,
my_args
.
name
);
if
(
!
quiet
)
fprintf
(
stderr
,
"%s is running
\n
"
,
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -128,11 +135,13 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
...
@@ -128,11 +135,13 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
static
int
do_destroy
(
struct
lxc_container
*
c
)
static
int
do_destroy
(
struct
lxc_container
*
c
)
{
{
if
(
!
c
->
destroy
(
c
))
{
if
(
!
c
->
destroy
(
c
))
{
fprintf
(
stderr
,
"Destroying %s failed
\n
"
,
my_args
.
name
);
if
(
!
quiet
)
fprintf
(
stderr
,
"Destroying %s failed
\n
"
,
my_args
.
name
);
return
-
1
;
return
-
1
;
}
}
printf
(
"Destroyed container %s
\n
"
,
my_args
.
name
);
if
(
!
quiet
)
printf
(
"Destroyed container %s
\n
"
,
my_args
.
name
);
return
0
;
return
0
;
}
}
...
@@ -190,7 +199,8 @@ static int do_destroy_with_snapshots(struct lxc_container *c)
...
@@ -190,7 +199,8 @@ static int do_destroy_with_snapshots(struct lxc_container *c)
continue
;
continue
;
}
}
if
(
!
c1
->
destroy
(
c1
))
{
if
(
!
c1
->
destroy
(
c1
))
{
fprintf
(
stderr
,
"Destroying snapshot %s of %s failed
\n
"
,
lxcname
,
my_args
.
name
);
if
(
!
quiet
)
fprintf
(
stderr
,
"Destroying snapshot %s of %s failed
\n
"
,
lxcname
,
my_args
.
name
);
lxc_container_put
(
c1
);
lxc_container_put
(
c1
);
free
(
buf
);
free
(
buf
);
return
-
1
;
return
-
1
;
...
@@ -212,11 +222,13 @@ static int do_destroy_with_snapshots(struct lxc_container *c)
...
@@ -212,11 +222,13 @@ static int do_destroy_with_snapshots(struct lxc_container *c)
bret
=
c
->
destroy
(
c
);
bret
=
c
->
destroy
(
c
);
if
(
!
bret
)
{
if
(
!
bret
)
{
fprintf
(
stderr
,
"Destroying %s failed
\n
"
,
my_args
.
name
);
if
(
!
quiet
)
fprintf
(
stderr
,
"Destroying %s failed
\n
"
,
my_args
.
name
);
return
-
1
;
return
-
1
;
}
}
printf
(
"Destroyed container %s including snapshots
\n
"
,
my_args
.
name
);
if
(
!
quiet
)
printf
(
"Destroyed container %s including snapshots
\n
"
,
my_args
.
name
);
return
0
;
return
0
;
}
}
...
...
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