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
33903369
Unverified
Commit
33903369
authored
Nov 20, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: non-functional changes
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
bfc1a0e9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
25 deletions
+22
-25
commands.c
src/lxc/commands.c
+5
-6
commands.h
src/lxc/commands.h
+1
-2
commands_utils.c
src/lxc/commands_utils.c
+5
-7
commands_utils.h
src/lxc/commands_utils.h
+1
-1
start.c
src/lxc/start.c
+10
-9
No files found.
src/lxc/commands.c
View file @
33903369
...
@@ -220,7 +220,7 @@ static int lxc_cmd_send(const char *name, struct lxc_cmd_rr *cmd,
...
@@ -220,7 +220,7 @@ static int lxc_cmd_send(const char *name, struct lxc_cmd_rr *cmd,
int
client_fd
;
int
client_fd
;
ssize_t
ret
=
-
1
;
ssize_t
ret
=
-
1
;
client_fd
=
lxc_cmd_connect
(
name
,
lxcpath
,
hashed_sock_name
);
client_fd
=
lxc_cmd_connect
(
name
,
lxcpath
,
hashed_sock_name
,
"command"
);
if
(
client_fd
<
0
)
{
if
(
client_fd
<
0
)
{
if
(
client_fd
==
-
ECONNREFUSED
)
if
(
client_fd
==
-
ECONNREFUSED
)
return
-
ECONNREFUSED
;
return
-
ECONNREFUSED
;
...
@@ -1063,8 +1063,7 @@ out_close:
...
@@ -1063,8 +1063,7 @@ out_close:
goto
out
;
goto
out
;
}
}
int
lxc_cmd_init
(
const
char
*
name
,
struct
lxc_handler
*
handler
,
int
lxc_cmd_init
(
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
suffix
)
const
char
*
lxcpath
)
{
{
int
fd
,
len
,
ret
;
int
fd
,
len
,
ret
;
char
path
[
sizeof
(((
struct
sockaddr_un
*
)
0
)
->
sun_path
)]
=
{
0
};
char
path
[
sizeof
(((
struct
sockaddr_un
*
)
0
)
->
sun_path
)]
=
{
0
};
...
@@ -1076,9 +1075,10 @@ int lxc_cmd_init(const char *name, struct lxc_handler *handler,
...
@@ -1076,9 +1075,10 @@ int lxc_cmd_init(const char *name, struct lxc_handler *handler,
* because we print the sockname out sometimes.
* because we print the sockname out sometimes.
*/
*/
len
=
sizeof
(
path
)
-
2
;
len
=
sizeof
(
path
)
-
2
;
ret
=
lxc_make_abstract_socket_name
(
offset
,
len
,
name
,
lxcpath
,
NULL
,
"command"
);
ret
=
lxc_make_abstract_socket_name
(
offset
,
len
,
name
,
lxcpath
,
NULL
,
suffix
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
TRACE
(
"Creating abstract unix socket
\"
%s
\"
"
,
offset
);
fd
=
lxc_abstract_unix_open
(
path
,
SOCK_STREAM
,
0
);
fd
=
lxc_abstract_unix_open
(
path
,
SOCK_STREAM
,
0
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
...
@@ -1096,8 +1096,7 @@ int lxc_cmd_init(const char *name, struct lxc_handler *handler,
...
@@ -1096,8 +1096,7 @@ int lxc_cmd_init(const char *name, struct lxc_handler *handler,
return
-
1
;
return
-
1
;
}
}
handler
->
conf
->
maincmd_fd
=
fd
;
return
fd
;
return
0
;
}
}
int
lxc_cmd_mainloop_add
(
const
char
*
name
,
struct
lxc_epoll_descr
*
descr
,
int
lxc_cmd_mainloop_add
(
const
char
*
name
,
struct
lxc_epoll_descr
*
descr
,
...
...
src/lxc/commands.h
View file @
33903369
...
@@ -110,8 +110,7 @@ extern int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
...
@@ -110,8 +110,7 @@ extern int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
struct
lxc_epoll_descr
;
struct
lxc_epoll_descr
;
struct
lxc_handler
;
struct
lxc_handler
;
extern
int
lxc_cmd_init
(
const
char
*
name
,
struct
lxc_handler
*
handler
,
extern
int
lxc_cmd_init
(
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
suffix
);
const
char
*
lxcpath
);
extern
int
lxc_cmd_mainloop_add
(
const
char
*
name
,
struct
lxc_epoll_descr
*
descr
,
extern
int
lxc_cmd_mainloop_add
(
const
char
*
name
,
struct
lxc_epoll_descr
*
descr
,
struct
lxc_handler
*
handler
);
struct
lxc_handler
*
handler
);
extern
int
lxc_try_cmd
(
const
char
*
name
,
const
char
*
lxcpath
);
extern
int
lxc_try_cmd
(
const
char
*
name
,
const
char
*
lxcpath
);
...
...
src/lxc/commands_utils.c
View file @
33903369
...
@@ -68,16 +68,14 @@ again:
...
@@ -68,16 +68,14 @@ again:
goto
again
;
goto
again
;
}
}
ERROR
(
"
f
ailed to receive message: %s"
,
strerror
(
errno
));
ERROR
(
"
F
ailed to receive message: %s"
,
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
if
(
ret
==
0
)
{
if
(
ret
<
0
)
ERROR
(
"length of message was 0"
);
return
-
1
;
return
-
1
;
}
TRACE
(
"
r
eceived state %s from state client %d"
,
TRACE
(
"
R
eceived state %s from state client %d"
,
lxc_state2str
(
msg
.
value
),
state_client_fd
);
lxc_state2str
(
msg
.
value
),
state_client_fd
);
return
msg
.
value
;
return
msg
.
value
;
...
@@ -163,7 +161,7 @@ int lxc_make_abstract_socket_name(char *path, int len, const char *lxcname,
...
@@ -163,7 +161,7 @@ int lxc_make_abstract_socket_name(char *path, int len, const char *lxcname,
}
}
int
lxc_cmd_connect
(
const
char
*
name
,
const
char
*
lxcpath
,
int
lxc_cmd_connect
(
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
hashed_sock_name
)
const
char
*
hashed_sock_name
,
const
char
*
suffix
)
{
{
int
ret
,
client_fd
;
int
ret
,
client_fd
;
char
path
[
sizeof
(((
struct
sockaddr_un
*
)
0
)
->
sun_path
)]
=
{
0
};
char
path
[
sizeof
(((
struct
sockaddr_un
*
)
0
)
->
sun_path
)]
=
{
0
};
...
@@ -176,7 +174,7 @@ int lxc_cmd_connect(const char *name, const char *lxcpath,
...
@@ -176,7 +174,7 @@ int lxc_cmd_connect(const char *name, const char *lxcpath,
*/
*/
size_t
len
=
sizeof
(
path
)
-
2
;
size_t
len
=
sizeof
(
path
)
-
2
;
ret
=
lxc_make_abstract_socket_name
(
offset
,
len
,
name
,
lxcpath
,
ret
=
lxc_make_abstract_socket_name
(
offset
,
len
,
name
,
lxcpath
,
hashed_sock_name
,
"command"
);
hashed_sock_name
,
suffix
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
...
...
src/lxc/commands_utils.h
View file @
33903369
...
@@ -79,6 +79,6 @@ extern int lxc_add_state_client(int state_client_fd,
...
@@ -79,6 +79,6 @@ extern int lxc_add_state_client(int state_client_fd,
* >= 0 client fd
* >= 0 client fd
*/
*/
extern
int
lxc_cmd_connect
(
const
char
*
name
,
const
char
*
lxcpath
,
extern
int
lxc_cmd_connect
(
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
hashed_sock_name
);
const
char
*
hashed_sock_name
,
const
char
*
suffix
);
#endif
/* __LXC_COMMANDS_UTILS_H */
#endif
/* __LXC_COMMANDS_UTILS_H */
src/lxc/start.c
View file @
33903369
...
@@ -357,10 +357,10 @@ static int lxc_serve_state_clients(const char *name,
...
@@ -357,10 +357,10 @@ static int lxc_serve_state_clients(const char *name,
* lxc_cmd_add_state_client() to miss a state.
* lxc_cmd_add_state_client() to miss a state.
*/
*/
handler
->
state
=
state
;
handler
->
state
=
state
;
TRACE
(
"
s
et container state to %s"
,
lxc_state2str
(
state
));
TRACE
(
"
S
et container state to %s"
,
lxc_state2str
(
state
));
if
(
lxc_list_empty
(
&
handler
->
state_clients
))
{
if
(
lxc_list_empty
(
&
handler
->
state_clients
))
{
TRACE
(
"
n
o state clients registered"
);
TRACE
(
"
N
o state clients registered"
);
process_unlock
();
process_unlock
();
lxc_monitor_send_state
(
name
,
state
,
handler
->
lxcpath
);
lxc_monitor_send_state
(
name
,
state
,
handler
->
lxcpath
);
return
0
;
return
0
;
...
@@ -373,12 +373,12 @@ static int lxc_serve_state_clients(const char *name,
...
@@ -373,12 +373,12 @@ static int lxc_serve_state_clients(const char *name,
client
=
cur
->
elem
;
client
=
cur
->
elem
;
if
(
!
client
->
states
[
state
])
{
if
(
!
client
->
states
[
state
])
{
TRACE
(
"
s
tate %s not registered for state client %d"
,
TRACE
(
"
S
tate %s not registered for state client %d"
,
lxc_state2str
(
state
),
client
->
clientfd
);
lxc_state2str
(
state
),
client
->
clientfd
);
continue
;
continue
;
}
}
TRACE
(
"
s
ending state %s to state client %d"
,
TRACE
(
"
S
ending state %s to state client %d"
,
lxc_state2str
(
state
),
client
->
clientfd
);
lxc_state2str
(
state
),
client
->
clientfd
);
again:
again:
...
@@ -389,7 +389,8 @@ static int lxc_serve_state_clients(const char *name,
...
@@ -389,7 +389,8 @@ static int lxc_serve_state_clients(const char *name,
goto
again
;
goto
again
;
}
}
ERROR
(
"failed to send message to client"
);
ERROR
(
"%s - Failed to send message to client"
,
strerror
(
errno
));
}
}
/* kick client from list */
/* kick client from list */
...
@@ -573,12 +574,12 @@ struct lxc_handler *lxc_init_handler(const char *name, struct lxc_conf *conf,
...
@@ -573,12 +574,12 @@ struct lxc_handler *lxc_init_handler(const char *name, struct lxc_conf *conf,
handler
->
state_socket_pair
[
1
]);
handler
->
state_socket_pair
[
1
]);
}
}
if
(
lxc_cmd_init
(
name
,
handler
,
lxcpath
))
{
handler
->
conf
->
maincmd_fd
=
lxc_cmd_init
(
name
,
lxcpath
,
"command"
);
ERROR
(
"failed to set up command socket"
);
if
(
handler
->
conf
->
maincmd_fd
<
0
)
{
ERROR
(
"Failed to set up command socket"
);
goto
on_error
;
goto
on_error
;
}
}
TRACE
(
"Unix domain socket %d for command server is ready"
,
TRACE
(
"unix domain socket %d for command server is ready"
,
handler
->
conf
->
maincmd_fd
);
handler
->
conf
->
maincmd_fd
);
return
handler
;
return
handler
;
...
...
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