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
097268e1
Unverified
Commit
097268e1
authored
Jun 27, 2018
by
2xsec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: cgroup, freeze, unfreeze, wait: change fprintf => lxc_error
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
a13daf8e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
25 deletions
+36
-25
lxc_cgroup.c
src/lxc/tools/lxc_cgroup.c
+14
-10
lxc_freeze.c
src/lxc/tools/lxc_freeze.c
+5
-5
lxc_unfreeze.c
src/lxc/tools/lxc_unfreeze.c
+7
-5
lxc_wait.c
src/lxc/tools/lxc_wait.c
+10
-5
No files found.
src/lxc/tools/lxc_cgroup.c
View file @
097268e1
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
static
int
my_checker
(
const
struct
lxc_arguments
*
args
)
static
int
my_checker
(
const
struct
lxc_arguments
*
args
)
{
{
if
(
!
args
->
argc
)
{
if
(
!
args
->
argc
)
{
lxc_error
(
args
,
"
m
issing state object"
);
lxc_error
(
args
,
"
M
issing state object"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -95,44 +95,48 @@ int main(int argc, char *argv[])
...
@@ -95,44 +95,48 @@ int main(int argc, char *argv[])
if
(
my_args
.
rcfile
)
{
if
(
my_args
.
rcfile
)
{
c
->
clear_config
(
c
);
c
->
clear_config
(
c
);
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
fprintf
(
stderr
,
"Failed to load rcfile
\n
"
);
lxc_error
(
&
my_args
,
"Failed to load rcfile
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
if
(
!
c
->
configfile
)
{
if
(
!
c
->
configfile
)
{
fprintf
(
stderr
,
"Out of memory setting new config filename
\n
"
);
lxc_error
(
&
my_args
,
"Out of memory setting new config filename
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
if
(
!
c
->
may_control
(
c
))
{
if
(
!
c
->
may_control
(
c
))
{
fprintf
(
stderr
,
"Insufficent privileges to control %s:%s
\n
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_error
(
&
my_args
,
"Insufficent privileges to control %s:%s
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
!
c
->
is_running
(
c
))
{
if
(
!
c
->
is_running
(
c
))
{
fprintf
(
stderr
,
"'%s:%s' is not running
\n
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_error
(
&
my_args
,
"'%s:%s' is not running
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
((
my_args
.
argc
)
>
1
)
{
if
((
my_args
.
argc
)
>
1
)
{
value
=
my_args
.
argv
[
1
];
value
=
my_args
.
argv
[
1
];
if
(
!
c
->
set_cgroup_item
(
c
,
state_object
,
value
))
{
if
(
!
c
->
set_cgroup_item
(
c
,
state_object
,
value
))
{
fprintf
(
stderr
,
"failed to assign '%s' value to '%s' for '%s'
\n
"
,
lxc_error
(
&
my_args
,
"Failed to assign '%s' value to '%s' for '%s'
"
,
value
,
state_object
,
my_args
.
name
);
value
,
state_object
,
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
{
}
else
{
char
buffer
[
TOOL_MAXPATHLEN
];
char
buffer
[
TOOL_MAXPATHLEN
];
int
ret
=
c
->
get_cgroup_item
(
c
,
state_object
,
buffer
,
TOOL_MAXPATHLEN
);
int
ret
;
ret
=
c
->
get_cgroup_item
(
c
,
state_object
,
buffer
,
TOOL_MAXPATHLEN
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"failed to retrieve value of '%s' for '%s:%s'
\n
"
,
lxc_error
(
&
my_args
,
"Failed to retrieve value of '%s' for '%s:%s'
"
,
state_object
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
state_object
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
...
src/lxc/tools/lxc_freeze.c
View file @
097268e1
...
@@ -75,33 +75,33 @@ int main(int argc, char *argv[])
...
@@ -75,33 +75,33 @@ int main(int argc, char *argv[])
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
,
"No such container: %s:%s
\n
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_error
(
&
my_args
,
"No such container: %s:%s
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
my_args
.
rcfile
)
{
if
(
my_args
.
rcfile
)
{
c
->
clear_config
(
c
);
c
->
clear_config
(
c
);
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
fprintf
(
stderr
,
"Failed to load rcfile
\n
"
);
lxc_error
(
&
my_args
,
"Failed to load rcfile
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
if
(
!
c
->
configfile
)
{
if
(
!
c
->
configfile
)
{
fprintf
(
stderr
,
"Out of memory setting new config filename
\n
"
);
lxc_error
(
&
my_args
,
"Out of memory setting new config filename
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
if
(
!
c
->
may_control
(
c
))
{
if
(
!
c
->
may_control
(
c
))
{
fprintf
(
stderr
,
"Insufficent privileges to control %s:%s
\n
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_error
(
&
my_args
,
"Insufficent privileges to control %s:%s
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
!
c
->
freeze
(
c
))
{
if
(
!
c
->
freeze
(
c
))
{
fprintf
(
stderr
,
"Failed to freeze %s:%s
\n
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_error
(
&
my_args
,
"Failed to freeze %s:%s
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
...
src/lxc/tools/lxc_unfreeze.c
View file @
097268e1
...
@@ -75,33 +75,35 @@ int main(int argc, char *argv[])
...
@@ -75,33 +75,35 @@ int main(int argc, char *argv[])
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
,
"No such container: %s:%s
\n
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_error
(
&
my_args
,
"No such container: %s:%s
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
!
c
->
may_control
(
c
))
{
if
(
!
c
->
may_control
(
c
))
{
fprintf
(
stderr
,
"Insufficent privileges to control %s:%s
\n
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_error
(
&
my_args
,
"Insufficent privileges to control %s:%s
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
my_args
.
rcfile
)
{
if
(
my_args
.
rcfile
)
{
c
->
clear_config
(
c
);
c
->
clear_config
(
c
);
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
fprintf
(
stderr
,
"Failed to load rcfile
\n
"
);
lxc_error
(
&
my_args
,
"Failed to load rcfile
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
if
(
!
c
->
configfile
)
{
if
(
!
c
->
configfile
)
{
fprintf
(
stderr
,
"Out of memory setting new config filename
\n
"
);
lxc_error
(
&
my_args
,
"Out of memory setting new config filename
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
if
(
!
c
->
unfreeze
(
c
))
{
if
(
!
c
->
unfreeze
(
c
))
{
fprintf
(
stderr
,
"Failed to unfreeze %s:%s
\n
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_error
(
&
my_args
,
"Failed to unfreeze %s:%s
"
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
...
src/lxc/tools/lxc_wait.c
View file @
097268e1
...
@@ -35,21 +35,23 @@
...
@@ -35,21 +35,23 @@
#include "arguments.h"
#include "arguments.h"
#include "tool_utils.h"
#include "tool_utils.h"
static
int
my_checker
(
const
struct
lxc_arguments
*
args
)
static
int
my_checker
(
const
struct
lxc_arguments
*
args
)
{
{
if
(
!
args
->
states
)
{
if
(
!
args
->
states
)
{
lxc_error
(
args
,
"missing state option to wait for."
);
lxc_error
(
args
,
"missing state option to wait for."
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
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
's'
:
args
->
states
=
optarg
;
break
;
case
's'
:
args
->
states
=
optarg
;
break
;
case
't'
:
args
->
timeout
=
atol
(
optarg
);
break
;
case
't'
:
args
->
timeout
=
atol
(
optarg
);
break
;
}
}
return
0
;
return
0
;
}
}
...
@@ -105,21 +107,23 @@ int main(int argc, char *argv[])
...
@@ -105,21 +107,23 @@ int main(int argc, char *argv[])
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
if
(
!
c
->
may_control
(
c
))
{
if
(
!
c
->
may_control
(
c
))
{
fprintf
(
stderr
,
"Insufficent privileges to control %s
\n
"
,
c
->
name
);
lxc_error
(
&
my_args
,
"Insufficent privileges to control %s
"
,
c
->
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
my_args
.
rcfile
)
{
if
(
my_args
.
rcfile
)
{
c
->
clear_config
(
c
);
c
->
clear_config
(
c
);
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
fprintf
(
stderr
,
"Failed to load rcfile
\n
"
);
lxc_error
(
&
my_args
,
"Failed to load rcfile
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
if
(
!
c
->
configfile
)
{
if
(
!
c
->
configfile
)
{
fprintf
(
stderr
,
"Out of memory setting new config filename
\n
"
);
lxc_error
(
&
my_args
,
"Out of memory setting new config filename
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -129,5 +133,6 @@ int main(int argc, char *argv[])
...
@@ -129,5 +133,6 @@ int main(int argc, char *argv[])
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
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