patch-2_6_7-vs1_9_1_12
[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
31         struct namespace *vx_namespace;         /* private namespace */
32         struct fs_struct *vx_fs;                /* private namespace fs */
33         uint64_t vx_flags;                      /* VX_INFO_xxx */
34         uint64_t vx_bcaps;                      /* bounding caps (system) */
35         uint64_t vx_ccaps;                      /* context caps (vserver) */
36
37         pid_t vx_initpid;                       /* PID of fake init process */
38
39         struct _vx_limit limit;                 /* vserver limits */
40         struct _vx_sched sched;                 /* vserver scheduler */
41         struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
42         struct _vx_cacct cacct;                 /* context accounting */
43
44         char vx_name[65];                       /* vserver name */
45 };
46
47
48 #define VX_ADMIN        0x0001
49 #define VX_WATCH        0x0002
50 #define VX_DUMMY        0x0008
51
52 #define VX_IDENT        0x0010
53 #define VX_EQUIV        0x0020
54 #define VX_PARENT       0x0040
55 #define VX_CHILD        0x0080
56
57 #define VX_ARG_MASK     0x00F0
58
59 #define VX_DYNAMIC      0x0100
60 #define VX_STATIC       0x0200
61
62 #define VX_ATR_MASK     0x0F00
63
64
65 extern void rcu_free_vx_info(void *);
66 extern void unhash_vx_info(struct vx_info *);
67
68 extern struct vx_info *locate_vx_info(int);
69 extern struct vx_info *locate_or_create_vx_info(int);
70
71 extern int get_xid_list(int, unsigned int *, int);
72 extern int vx_info_is_hashed(xid_t);
73
74 extern int vx_migrate_task(struct task_struct *, struct vx_info *);
75
76 #endif  /* __KERNEL__ */
77
78 #include "switch.h"
79
80 /* vinfo commands */
81
82 #define VCMD_task_xid           VC_CMD(VINFO, 1, 0)
83 #define VCMD_task_nid           VC_CMD(VINFO, 2, 0)
84
85 #ifdef  __KERNEL__
86 extern int vc_task_xid(uint32_t, void __user *);
87
88 #endif  /* __KERNEL__ */
89
90 #define VCMD_vx_info            VC_CMD(VINFO, 5, 0)
91 #define VCMD_nx_info            VC_CMD(VINFO, 6, 0)
92
93 struct  vcmd_vx_info_v0 {
94         uint32_t xid;
95         uint32_t initpid;
96         /* more to come */      
97 };
98
99 #ifdef  __KERNEL__
100 extern int vc_vx_info(uint32_t, void __user *);
101
102 #endif  /* __KERNEL__ */
103
104 #define VCMD_ctx_create         VC_CMD(VPROC, 1, 0)
105 #define VCMD_ctx_migrate        VC_CMD(PROCMIG, 1, 0)
106
107 #ifdef  __KERNEL__
108 extern int vc_ctx_create(uint32_t, void __user *);
109 extern int vc_ctx_migrate(uint32_t, void __user *);
110
111 #endif  /* __KERNEL__ */
112
113 #define VCMD_get_cflags         VC_CMD(FLAGS, 1, 0)
114 #define VCMD_set_cflags         VC_CMD(FLAGS, 2, 0)
115
116 struct  vcmd_ctx_flags_v0 {
117         uint64_t flagword;
118         uint64_t mask;
119 };
120
121 #ifdef  __KERNEL__
122 extern int vc_get_cflags(uint32_t, void __user *);
123 extern int vc_set_cflags(uint32_t, void __user *);
124
125 #endif  /* __KERNEL__ */
126
127 #define VXF_INFO_LOCK           0x00000001
128 #define VXF_INFO_SCHED          0x00000002
129 #define VXF_INFO_NPROC          0x00000004
130 #define VXF_INFO_PRIVATE        0x00000008
131
132 #define VXF_INFO_INIT           0x00000010
133 #define VXF_INFO_HIDE           0x00000020
134 #define VXF_INFO_ULIMIT         0x00000040
135 #define VXF_INFO_NSPACE         0x00000080
136
137 #define VXF_SCHED_HARD          0x00000100
138 #define VXF_SCHED_PRIO          0x00000200
139 #define VXF_SCHED_PAUSE         0x00000400
140
141 #define VXF_VIRT_MEM            0x00010000
142 #define VXF_VIRT_UPTIME         0x00020000
143 #define VXF_VIRT_CPU            0x00040000
144
145 #define VXF_HIDE_MOUNT          0x01000000
146 #define VXF_HIDE_NETIF          0x02000000
147
148 #define VXF_STATE_SETUP         (1ULL<<32)
149 #define VXF_STATE_INIT          (1ULL<<33)
150
151 #define VXF_FORK_RSS            (1ULL<<48)
152 #define VXF_PROLIFIC            (1ULL<<49)
153
154 #define VXF_ONE_TIME            (0x0003ULL<<32)
155
156 #define VCMD_get_ccaps          VC_CMD(FLAGS, 3, 0)
157 #define VCMD_set_ccaps          VC_CMD(FLAGS, 4, 0)
158
159 struct  vcmd_ctx_caps_v0 {
160         uint64_t bcaps;
161         uint64_t ccaps;
162         uint64_t cmask;
163 };
164
165 #ifdef  __KERNEL__
166 extern int vc_get_ccaps(uint32_t, void __user *);
167 extern int vc_set_ccaps(uint32_t, void __user *);
168
169 #endif  /* __KERNEL__ */
170
171 #define VXC_SET_UTSNAME         0x00000001
172 #define VXC_SET_RLIMIT          0x00000002
173
174 #define VXC_RAW_ICMP            0x00000100
175
176 #define VXC_SECURE_MOUNT        0x00010000
177
178
179 #endif  /* _VX_CONTEXT_H */