2 * Copyright (c) 2014-2016 Red Hat.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
30 CONTAINERS_RESTARTING
,
36 CONTAINERS_UPTODATE_NAME
,
37 CONTAINERS_UPTODATE_STATE
,
42 * General container services, abstracting individual implementations into
43 * "engines" which are then instantiated one-per-container-technology.
47 struct container_engine
;
49 typedef void (*container_setup_t
)(struct container_engine
*);
50 typedef int (*container_changed_t
)(struct container_engine
*);
51 typedef void (*container_insts_t
)(struct container_engine
*, pmInDom
);
52 typedef int (*container_values_t
)(struct container_engine
*,
53 const char *, struct container
*);
54 typedef int (*container_match_t
)(struct container_engine
*,
55 const char *, const char *, const char *);
57 typedef struct container_engine
{
58 char *name
; /* docker, lxc, rkt, etc. */
59 int state
; /* external driver states */
60 char path
[60]; /* suffix for cgroup path */
61 container_setup_t setup
;
62 container_changed_t indom_changed
;
63 container_insts_t insts_refresh
;
64 container_values_t value_refresh
;
65 container_match_t name_matching
;
69 CONTAINER_STATE_SYSTEMD
= (1<<0),
72 typedef struct container
{
74 int flags
: 8; /* CONTAINER_FLAG bitwise */
75 int state
: 8; /* internal driver states */
76 int uptodate
: 8; /* refreshed values count */
78 char *name
; /* human-presentable name */
81 container_engine_t
*engine
;
85 CONTAINER_FLAG_RUNNING
= (1<<0),
86 CONTAINER_FLAG_PAUSED
= (1<<1),
87 CONTAINER_FLAG_RESTARTING
= (1<<2),
90 extern int root_stat_time_differs(struct stat
*, struct stat
*);
93 ROOT_AGENT_SOCKET
= 1,
97 extern int root_create_agent(int, char *, char *, int *, int *);
98 extern int root_agent_wait(int *);
99 extern int root_maximum_fd
;