vserver 1.9.3
[linux-2.6.git] / include / linux / vserver / context.h
1 #ifndef _VX_CONTEXT_H
2 #define _VX_CONTEXT_H
3
4 #include <linux/types.h>
5
6 #define MAX_S_CONTEXT   65535   /* Arbitrary limit */
7 #define MIN_D_CONTEXT   49152   /* dynamic contexts start here */
8
9 #define VX_DYNAMIC_ID   ((uint32_t)-1)          /* id for dynamic context */
10
11 #ifdef  __KERNEL__
12
13 #include <linux/list.h>
14 #include <linux/spinlock.h>
15 #include <linux/rcupdate.h>
16
17 #define _VX_INFO_DEF_
18 #include "cvirt.h"
19 #include "limit.h"
20 #include "sched.h"
21 #undef  _VX_INFO_DEF_
22
23 struct vx_info {
24         struct hlist_node vx_hlist;             /* linked list of contexts */
25         struct rcu_head vx_rcu;                 /* the rcu head */
26         xid_t vx_id;                            /* context id */
27         atomic_t vx_usecnt;                     /* usage count */
28         atomic_t vx_refcnt;                     /* reference count */
29         struct vx_info *vx_parent;              /* parent context */
30         int vx_state;                           /* context state */
31
32         struct namespace *vx_namespace;         /* private namespace */
33         struct fs_struct *vx_fs;                /* private namespace fs */
34         uint64_t vx_flags;                      /* context flags */
35         uint64_t vx_bcaps;                      /* bounding caps (system) */
36         uint64_t vx_ccaps;                      /* context caps (vserver) */
37
38         pid_t vx_initpid;                       /* PID of fake init process */
39
40         spinlock_t vx_lock;
41         wait_queue_head_t vx_exit;              /* context exit waitqueue */
42
43         struct _vx_limit limit;                 /* vserver limits */
44         struct _vx_sched sched;                 /* vserver scheduler */
45         struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
46         struct _vx_cacct cacct;                 /* context accounting */
47
48         char vx_name[65];                       /* vserver name */
49 };
50
51 /* status flags */
52
53 #define VXS_HASHED      0x0001
54 #define VXS_PAUSED      0x0010
55 #define VXS_ONHOLD      0x0020
56 #define VXS_SHUTDOWN    0x0100
57 #define VXS_DEFUNCT     0x1000
58 #define VXS_RELEASED    0x8000
59
60 /* check conditions */
61
62 #define VX_ADMIN        0x0001
63 #define VX_WATCH        0x0002
64 #define VX_DUMMY        0x0008
65
66 #define VX_IDENT        0x0010
67 #define VX_EQUIV        0x0020
68 #define VX_PARENT       0x0040
69 #define VX_CHILD        0x0080
70
71 #define VX_ARG_MASK     0x00F0
72
73 #define VX_DYNAMIC      0x0100
74 #define VX_STATIC       0x0200
75
76 #define VX_ATR_MASK     0x0F00
77
78
79 struct rcu_head;
80
81 // extern void rcu_free_vx_info(struct rcu_head *);
82 extern void unhash_vx_info(struct vx_info *);
83
84 extern struct vx_info *locate_vx_info(int);
85 extern struct vx_info *locate_or_create_vx_info(int);
86
87 extern int get_xid_list(int, unsigned int *, int);
88 extern int vx_info_is_hashed(xid_t);
89
90 extern int vx_migrate_task(struct task_struct *, struct vx_info *);
91
92 #endif  /* __KERNEL__ */
93
94 #include "switch.h"
95
96 /* vinfo commands */
97
98 #define VCMD_task_xid           VC_CMD(VINFO, 1, 0)
99 #define VCMD_task_nid           VC_CMD(VINFO, 2, 0)
100
101 #ifdef  __KERNEL__
102 extern int vc_task_xid(uint32_t, void __user *);
103
104 #endif  /* __KERNEL__ */
105
106 #define VCMD_vx_info            VC_CMD(VINFO, 5, 0)
107 #define VCMD_nx_info            VC_CMD(VINFO, 6, 0)
108
109 struct  vcmd_vx_info_v0 {
110         uint32_t xid;
111         uint32_t initpid;
112         /* more to come */
113 };
114
115 #ifdef  __KERNEL__
116 extern int vc_vx_info(uint32_t, void __user *);
117
118 #endif  /* __KERNEL__ */
119
120 #define VCMD_ctx_create         VC_CMD(VPROC, 1, 0)
121 #define VCMD_ctx_migrate        VC_CMD(PROCMIG, 1, 0)
122
123 #ifdef  __KERNEL__
124 extern int vc_ctx_create(uint32_t, void __user *);
125 extern int vc_ctx_migrate(uint32_t, void __user *);
126
127 #endif  /* __KERNEL__ */
128
129 #define VCMD_get_cflags         VC_CMD(FLAGS, 1, 0)
130 #define VCMD_set_cflags         VC_CMD(FLAGS, 2, 0)
131
132 struct  vcmd_ctx_flags_v0 {
133         uint64_t flagword;
134         uint64_t mask;
135 };
136
137 #ifdef  __KERNEL__
138 extern int vc_get_cflags(uint32_t, void __user *);
139 extern int vc_set_cflags(uint32_t, void __user *);
140
141 #endif  /* __KERNEL__ */
142
143 #define VXF_INFO_LOCK           0x00000001
144 #define VXF_INFO_SCHED          0x00000002
145 #define VXF_INFO_NPROC          0x00000004
146 #define VXF_INFO_PRIVATE        0x00000008
147
148 #define VXF_INFO_INIT           0x00000010
149 #define VXF_INFO_HIDE           0x00000020
150 #define VXF_INFO_ULIMIT         0x00000040
151 #define VXF_INFO_NSPACE         0x00000080
152
153 #define VXF_SCHED_HARD          0x00000100
154 #define VXF_SCHED_PRIO          0x00000200
155 #define VXF_SCHED_PAUSE         0x00000400
156
157 #define VXF_VIRT_MEM            0x00010000
158 #define VXF_VIRT_UPTIME         0x00020000
159 #define VXF_VIRT_CPU            0x00040000
160 #define VXF_VIRT_LOAD           0x00080000
161
162 #define VXF_HIDE_MOUNT          0x01000000
163 #define VXF_HIDE_NETIF          0x02000000
164
165 #define VXF_STATE_SETUP         (1ULL<<32)
166 #define VXF_STATE_INIT          (1ULL<<33)
167
168 #define VXF_FORK_RSS            (1ULL<<48)
169 #define VXF_PROLIFIC            (1ULL<<49)
170
171 #define VXF_IGNEG_NICE          (1ULL<<52)
172
173 #define VXF_ONE_TIME            (0x0003ULL<<32)
174
175 #define VCMD_get_ccaps          VC_CMD(FLAGS, 3, 0)
176 #define VCMD_set_ccaps          VC_CMD(FLAGS, 4, 0)
177
178 struct  vcmd_ctx_caps_v0 {
179         uint64_t bcaps;
180         uint64_t ccaps;
181         uint64_t cmask;
182 };
183
184 #ifdef  __KERNEL__
185 extern int vc_get_ccaps(uint32_t, void __user *);
186 extern int vc_set_ccaps(uint32_t, void __user *);
187
188 #endif  /* __KERNEL__ */
189
190 #define VXC_SET_UTSNAME         0x00000001
191 #define VXC_SET_RLIMIT          0x00000002
192
193 #define VXC_RAW_ICMP            0x00000100
194
195 #define VXC_SECURE_MOUNT        0x00010000
196 #define VXC_SECURE_REMOUNT      0x00020000
197
198
199 #endif  /* _VX_CONTEXT_H */