This commit adds support for the 2.1 vserver API.
[util-vserver.git] / kernel / context.h
index 816b8a2..463c036 100644 (file)
@@ -2,10 +2,16 @@
 #define _VX_CONTEXT_H
 
 #include <linux/types.h>
+//#include <linux/capability.h>
 
 
 #define MAX_S_CONTEXT  65535   /* Arbitrary limit */
+
+#ifdef CONFIG_VSERVER_DYNAMIC_IDS
 #define MIN_D_CONTEXT  49152   /* dynamic contexts start here */
+#else
+#define MIN_D_CONTEXT  65536
+#endif
 
 #define VX_DYNAMIC_ID  ((uint32_t)-1)          /* id for dynamic context */
 
 #define VXF_VIRT_UPTIME                0x00020000
 #define VXF_VIRT_CPU           0x00040000
 #define VXF_VIRT_LOAD          0x00080000
+#define VXF_VIRT_TIME          0x00100000
 
 #define VXF_HIDE_MOUNT         0x01000000
 #define VXF_HIDE_NETIF         0x02000000
+#define VXF_HIDE_VINFO         0x04000000
 
 #define VXF_STATE_SETUP                (1ULL<<32)
 #define VXF_STATE_INIT         (1ULL<<33)
+#define VXF_STATE_ADMIN                (1ULL<<34)
 
 #define VXF_SC_HELPER          (1ULL<<36)
 #define VXF_REBOOT_KILL                (1ULL<<37)
@@ -45,9 +54,9 @@
 
 #define VXF_IGNEG_NICE         (1ULL<<52)
 
-#define VXF_ONE_TIME           (0x0003ULL<<32)
+#define VXF_ONE_TIME           (0x0007ULL<<32)
 
-#define VXF_INIT_SET           (VXF_STATE_SETUP|VXF_STATE_INIT)
+#define VXF_INIT_SET           (VXF_STATE_SETUP|VXF_STATE_INIT|VXF_STATE_ADMIN)
 
 
 /* context migration */
@@ -70,6 +79,8 @@
 #define VXC_BINARY_MOUNT       0x00040000
 
 #define VXC_QUOTA_CTL          0x00100000
+#define VXC_ADMIN_MAPPER       0x00200000
+#define VXC_ADMIN_CLOOP                0x00400000
 
 
 /* context state changes */
@@ -92,6 +103,12 @@ enum {
 #include "limit_def.h"
 #include "sched_def.h"
 #include "cvirt_def.h"
+#include "cacct_def.h"
+
+struct _vx_info_pc {
+       struct _vx_sched_pc sched_pc;
+       struct _vx_cvirt_pc cvirt_pc;
+};
 
 struct vx_info {
        struct hlist_node vx_hlist;             /* linked list of contexts */
@@ -106,6 +123,7 @@ struct vx_info {
        uint64_t vx_flags;                      /* context flags */
        uint64_t vx_bcaps;                      /* bounding caps (system) */
        uint64_t vx_ccaps;                      /* context caps (vserver) */
+       kernel_cap_t vx_cap_bset;               /* the guest's bset */
 
        struct task_struct *vx_reaper;          /* guest reaper process */
        pid_t vx_initpid;                       /* PID of guest init */
@@ -115,6 +133,12 @@ struct vx_info {
        struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
        struct _vx_cacct cacct;                 /* context accounting */
 
+#ifndef CONFIG_SMP
+       struct _vx_info_pc info_pc;             /* per cpu data */
+#else
+       struct _vx_info_pc *ptr_pc;             /* per cpu array */
+#endif
+
        wait_queue_head_t vx_wait;              /* context exit waitqueue */
        int reboot_cmd;                         /* last sys_reboot() cmd */
        int exit_code;                          /* last process exit code */
@@ -122,12 +146,27 @@ struct vx_info {
        char vx_name[65];                       /* vserver name */
 };
 
+#ifndef CONFIG_SMP
+#define        vx_ptr_pc(vxi)          (&(vxi)->info_pc)
+#define        vx_per_cpu(vxi, v, id)  vx_ptr_pc(vxi)->v
+#else
+#define        vx_ptr_pc(vxi)          ((vxi)->ptr_pc)
+#define        vx_per_cpu(vxi, v, id)  per_cpu_ptr(vx_ptr_pc(vxi), id)->v
+#endif
+
+#define        vx_cpu(vxi, v)          vx_per_cpu(vxi, v, smp_processor_id())
+
+
+struct vx_info_save {
+       struct vx_info *vxi;
+       xid_t xid;
+};
+
 
 /* status flags */
 
 #define VXS_HASHED     0x0001
 #define VXS_PAUSED     0x0010
-#define VXS_ONHOLD     0x0020
 #define VXS_SHUTDOWN   0x0100
 #define VXS_HELPER     0x1000
 #define VXS_RELEASED   0x8000
@@ -152,6 +191,14 @@ struct vx_info {
 #define VX_ATR_MASK    0x0F00
 
 
+#ifdef CONFIG_VSERVER_PRIVACY
+#define VX_ADMIN_P     (0)
+#define VX_WATCH_P     (0)
+#else
+#define VX_ADMIN_P     VX_ADMIN
+#define VX_WATCH_P     VX_WATCH
+#endif
+
 extern void claim_vx_info(struct vx_info *, struct task_struct *);
 extern void release_vx_info(struct vx_info *, struct task_struct *);