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
0db85c58
Unverified
Commit
0db85c58
authored
Nov 29, 2017
by
Christian Brauner
Committed by
GitHub
Nov 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1970 from AustinReichert/tools-refactor-lxc-device
tools/lxc_device: remove internal logging
parents
dd9a1c4a
f132fdbd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
16 deletions
+12
-16
lxc_device.c
src/lxc/tools/lxc_device.c
+12
-16
No files found.
src/lxc/tools/lxc_device.c
View file @
0db85c58
...
@@ -39,8 +39,6 @@
...
@@ -39,8 +39,6 @@
#include <../include/ifaddrs.h>
#include <../include/ifaddrs.h>
#endif
#endif
lxc_log_define
(
lxc_device
,
lxc
);
static
const
struct
option
my_longopts
[]
=
{
static
const
struct
option
my_longopts
[]
=
{
LXC_COMMON_OPTIONS
LXC_COMMON_OPTIONS
};
};
...
@@ -65,7 +63,7 @@ static bool is_interface(const char* dev_name, pid_t pid)
...
@@ -65,7 +63,7 @@ static bool is_interface(const char* dev_name, pid_t pid)
pid_t
p
=
fork
();
pid_t
p
=
fork
();
if
(
p
<
0
)
{
if
(
p
<
0
)
{
SYSERROR
(
"failed to fork task.
"
);
fprintf
(
stderr
,
"failed to fork task.
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -73,13 +71,13 @@ static bool is_interface(const char* dev_name, pid_t pid)
...
@@ -73,13 +71,13 @@ static bool is_interface(const char* dev_name, pid_t pid)
struct
ifaddrs
*
interfaceArray
=
NULL
,
*
tempIfAddr
=
NULL
;
struct
ifaddrs
*
interfaceArray
=
NULL
,
*
tempIfAddr
=
NULL
;
if
(
!
switch_to_ns
(
pid
,
"net"
))
{
if
(
!
switch_to_ns
(
pid
,
"net"
))
{
ERROR
(
"failed to enter netns of container.
"
);
fprintf
(
stderr
,
"failed to enter netns of container.
\n
"
);
exit
(
-
1
);
exit
(
-
1
);
}
}
/* Grab the list of interfaces */
/* Grab the list of interfaces */
if
(
getifaddrs
(
&
interfaceArray
))
{
if
(
getifaddrs
(
&
interfaceArray
))
{
ERROR
(
"failed to get interfaces list
"
);
fprintf
(
stderr
,
"failed to get interfaces list
\n
"
);
exit
(
-
1
);
exit
(
-
1
);
}
}
...
@@ -106,7 +104,7 @@ int main(int argc, char *argv[])
...
@@ -106,7 +104,7 @@ int main(int argc, char *argv[])
bool
ret
=
false
;
bool
ret
=
false
;
if
(
geteuid
()
!=
0
)
{
if
(
geteuid
()
!=
0
)
{
ERROR
(
"%s must be run as root
"
,
argv
[
0
]);
fprintf
(
stderr
,
"%s must be run as root
\n
"
,
argv
[
0
]);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -132,30 +130,30 @@ int main(int argc, char *argv[])
...
@@ -132,30 +130,30 @@ 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
)
{
ERROR
(
"%s doesn't exist
"
,
my_args
.
name
);
fprintf
(
stderr
,
"%s doesn't exist
\n
"
,
my_args
.
name
);
goto
err
;
goto
err
;
}
}
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
))
{
ERROR
(
"Failed to load rcfile
"
);
fprintf
(
stderr
,
"Failed to load rcfile
\n
"
);
goto
err1
;
goto
err1
;
}
}
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
if
(
!
c
->
configfile
)
{
if
(
!
c
->
configfile
)
{
ERROR
(
"Out of memory setting new config filename
"
);
fprintf
(
stderr
,
"Out of memory setting new config filename
\n
"
);
goto
err1
;
goto
err1
;
}
}
}
}
if
(
!
c
->
is_running
(
c
))
{
if
(
!
c
->
is_running
(
c
))
{
ERROR
(
"Container %s is not running.
"
,
c
->
name
);
fprintf
(
stderr
,
"Container %s is not running.
\n
"
,
c
->
name
);
goto
err1
;
goto
err1
;
}
}
if
(
my_args
.
argc
<
2
)
{
if
(
my_args
.
argc
<
2
)
{
ERROR
(
"Error: no command given (Please see --help output)
"
);
fprintf
(
stderr
,
"Error: no command given (Please see --help output)
\n
"
);
goto
err1
;
goto
err1
;
}
}
...
@@ -173,10 +171,9 @@ int main(int argc, char *argv[])
...
@@ -173,10 +171,9 @@ int main(int argc, char *argv[])
ret
=
c
->
add_device_node
(
c
,
dev_name
,
dst_name
);
ret
=
c
->
add_device_node
(
c
,
dev_name
,
dst_name
);
}
}
if
(
ret
!=
true
)
{
if
(
ret
!=
true
)
{
ERROR
(
"Failed to add %s to %s.
"
,
dev_name
,
c
->
name
);
fprintf
(
stderr
,
"Failed to add %s to %s.
\n
"
,
dev_name
,
c
->
name
);
goto
err1
;
goto
err1
;
}
}
INFO
(
"Add %s to %s."
,
dev_name
,
c
->
name
);
}
else
if
(
strcmp
(
cmd
,
"del"
)
==
0
)
{
}
else
if
(
strcmp
(
cmd
,
"del"
)
==
0
)
{
if
(
is_interface
(
dev_name
,
c
->
init_pid
(
c
)))
{
if
(
is_interface
(
dev_name
,
c
->
init_pid
(
c
)))
{
ret
=
c
->
detach_interface
(
c
,
dev_name
,
dst_name
);
ret
=
c
->
detach_interface
(
c
,
dev_name
,
dst_name
);
...
@@ -184,12 +181,11 @@ int main(int argc, char *argv[])
...
@@ -184,12 +181,11 @@ int main(int argc, char *argv[])
ret
=
c
->
remove_device_node
(
c
,
dev_name
,
dst_name
);
ret
=
c
->
remove_device_node
(
c
,
dev_name
,
dst_name
);
}
}
if
(
ret
!=
true
)
{
if
(
ret
!=
true
)
{
ERROR
(
"Failed to del %s from %s.
"
,
dev_name
,
c
->
name
);
fprintf
(
stderr
,
"Failed to del %s from %s.
\n
"
,
dev_name
,
c
->
name
);
goto
err1
;
goto
err1
;
}
}
INFO
(
"Delete %s from %s."
,
dev_name
,
c
->
name
);
}
else
{
}
else
{
ERROR
(
"Error: Please use add or del (Please see --help output)
"
);
fprintf
(
stderr
,
"Error: Please use add or del (Please see --help output)
\n
"
);
goto
err1
;
goto
err1
;
}
}
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