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
746aab51
Unverified
Commit
746aab51
authored
Mar 11, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: LXC_CMD_GET_INIT_PIDFD
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
890ecf08
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
commands.c
src/lxc/commands.c
+44
-0
commands.h
src/lxc/commands.h
+2
-0
No files found.
src/lxc/commands.c
View file @
746aab51
...
...
@@ -83,6 +83,7 @@ static const char *lxc_cmd_str(lxc_cmd_t cmd)
[
LXC_CMD_FREEZE
]
=
"freeze"
,
[
LXC_CMD_UNFREEZE
]
=
"unfreeze"
,
[
LXC_CMD_GET_CGROUP2_FD
]
=
"get_cgroup2_fd"
,
[
LXC_CMD_GET_INIT_PIDFD
]
=
"get_init_pidfd"
,
};
if
(
cmd
>=
LXC_CMD_MAX
)
...
...
@@ -146,6 +147,11 @@ static int lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
rsp
->
data
=
INT_TO_PTR
(
cgroup2_fd
);
}
if
(
cmd
->
req
.
cmd
==
LXC_CMD_GET_INIT_PIDFD
)
{
int
init_pidfd
=
move_fd
(
fd_rsp
);
rsp
->
data
=
INT_TO_PTR
(
init_pidfd
);
}
if
(
rsp
->
datalen
==
0
)
return
log_debug
(
ret
,
"Response data length for command
\"
%s
\"
is 0"
,
...
...
@@ -372,6 +378,43 @@ static int lxc_cmd_get_init_pid_callback(int fd, struct lxc_cmd_req *req,
return
0
;
}
int
lxc_cmd_get_init_pidfd
(
const
char
*
name
,
const
char
*
lxcpath
)
{
int
ret
,
stopped
;
struct
lxc_cmd_rr
cmd
=
{
.
req
=
{
.
cmd
=
LXC_CMD_GET_INIT_PIDFD
,
},
};
ret
=
lxc_cmd
(
name
,
&
cmd
,
&
stopped
,
lxcpath
,
NULL
);
if
(
ret
<
0
)
return
log_debug_errno
(
-
1
,
errno
,
"Failed to process init pidfd command"
);
if
(
cmd
.
rsp
.
ret
<
0
)
return
log_debug_errno
(
-
EBADF
,
errno
,
"Failed to receive init pidfd"
);
return
PTR_TO_INT
(
cmd
.
rsp
.
data
);
}
static
int
lxc_cmd_get_init_pidfd_callback
(
int
fd
,
struct
lxc_cmd_req
*
req
,
struct
lxc_handler
*
handler
,
struct
lxc_epoll_descr
*
descr
)
{
struct
lxc_cmd_rsp
rsp
=
{
.
ret
=
0
,
};
int
ret
;
if
(
handler
->
pidfd
<
0
)
rsp
.
ret
=
-
EBADF
;
ret
=
lxc_abstract_unix_send_fds
(
fd
,
&
handler
->
pidfd
,
1
,
&
rsp
,
sizeof
(
rsp
));
if
(
ret
<
0
)
return
log_error
(
LXC_CMD_REAP_CLIENT_FD
,
"Failed to send init pidfd"
);
return
0
;
}
/*
* lxc_cmd_get_clone_flags: Get clone flags container was spawned with
*
...
...
@@ -1329,6 +1372,7 @@ static int lxc_cmd_process(int fd, struct lxc_cmd_req *req,
[
LXC_CMD_FREEZE
]
=
lxc_cmd_freeze_callback
,
[
LXC_CMD_UNFREEZE
]
=
lxc_cmd_unfreeze_callback
,
[
LXC_CMD_GET_CGROUP2_FD
]
=
lxc_cmd_get_cgroup2_fd_callback
,
[
LXC_CMD_GET_INIT_PIDFD
]
=
lxc_cmd_get_init_pidfd_callback
,
};
if
(
req
->
cmd
>=
LXC_CMD_MAX
)
...
...
src/lxc/commands.h
View file @
746aab51
...
...
@@ -37,6 +37,7 @@ typedef enum {
LXC_CMD_FREEZE
,
LXC_CMD_UNFREEZE
,
LXC_CMD_GET_CGROUP2_FD
,
LXC_CMD_GET_INIT_PIDFD
,
LXC_CMD_MAX
,
}
lxc_cmd_t
;
...
...
@@ -84,6 +85,7 @@ extern char *lxc_cmd_get_config_item(const char *name, const char *item, const c
extern
char
*
lxc_cmd_get_name
(
const
char
*
hashed_sock
);
extern
char
*
lxc_cmd_get_lxcpath
(
const
char
*
hashed_sock
);
extern
pid_t
lxc_cmd_get_init_pid
(
const
char
*
name
,
const
char
*
lxcpath
);
extern
int
lxc_cmd_get_init_pidfd
(
const
char
*
name
,
const
char
*
lxcpath
);
extern
int
lxc_cmd_get_state
(
const
char
*
name
,
const
char
*
lxcpath
);
extern
int
lxc_cmd_stop
(
const
char
*
name
,
const
char
*
lxcpath
);
...
...
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