]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/commands_utils.h
Merge pull request #4236 from mihalicyn/github_check_fixes
[mirror_lxc.git] / src / lxc / commands_utils.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #ifndef __LXC_COMMANDS_UTILS_H
4 #define __LXC_COMMANDS_UTILS_H
5
6 #include "config.h"
7
8 #include <stdio.h>
9
10 #include "state.h"
11 #include "commands.h"
12
13 __hidden extern int lxc_make_abstract_socket_name(char *path, size_t pathlen, const char *lxcname,
14 const char *lxcpath, const char *hashed_sock_name,
15 const char *suffix);
16
17 /* lxc_cmd_sock_get_state Register a new state client fd in the container's
18 * in-memory handler and retrieve the requested
19 * states.
20 *
21 * @param[in] name Name of container to connect to.
22 * @param[in] lxcpath The lxcpath in which the container is running.
23 * @param[in] states The states to wait for.
24 * @return Return < 0 on error
25 * < MAX_STATE current container state
26 */
27 __hidden extern int lxc_cmd_sock_get_state(const char *name, const char *lxcpath,
28 lxc_state_t states[MAX_STATE], int timeout);
29
30 /* lxc_cmd_sock_rcv_state Retrieve the requested state from a state client
31 * fd registerd in the container's in-memory
32 * handler.
33 *
34 * @param[int] state_client_fd The state client fd from which the state can be
35 * received.
36 * @return Return < 0 on error
37 * < MAX_STATE current container state
38 */
39 __hidden extern int lxc_cmd_sock_rcv_state(int state_client_fd, int timeout);
40
41 /* lxc_add_state_client Add a new state client to the container's
42 * in-memory handler.
43 *
44 * @param[int] state_client_fd The state client fd to add.
45 * @param[int] handler The container's in-memory handler.
46 * @param[in] states The states to wait for.
47 *
48 * @return Return < 0 on error
49 * 0 on success
50 */
51 __hidden extern int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler,
52 lxc_state_t states[MAX_STATE]);
53
54 /* lxc_cmd_connect Connect to the container's command socket.
55 *
56 * @param[in] name Name of container to connect to.
57 * @param[in] lxcpath The lxcpath in which the container is running.
58 * @param[in] hashed_sock_name The hashed name of the socket (optional). Can be
59 * NULL.
60 *
61 * @return Return < 0 on error
62 * >= 0 client fd
63 */
64 __hidden extern int lxc_cmd_connect(const char *name, const char *lxcpath,
65 const char *hashed_sock_name, const char *suffix);
66
67 __hidden extern void lxc_cmd_notify_state_listeners(const char *name,
68 const char *lxcpath,
69 lxc_state_t state);
70 #endif /* __LXC_COMMANDS_UTILS_H */