#define _VX_CONTEXT_H
#include <linux/types.h>
+#include <linux/capability.h>
-#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
-#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
#define VX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
-#ifdef __KERNEL__
+/* context flags */
-#include <linux/list.h>
-#include <linux/spinlock.h>
-#include <linux/rcupdate.h>
-
-#define _VX_INFO_DEF_
-#include "cvirt.h"
-#include "limit.h"
-#include "sched.h"
-#undef _VX_INFO_DEF_
-
-struct vx_info {
- struct hlist_node vx_hlist; /* linked list of contexts */
- struct rcu_head vx_rcu; /* the rcu head */
- xid_t vx_id; /* context id */
- atomic_t vx_usecnt; /* usage count */
- atomic_t vx_refcnt; /* reference count */
- struct vx_info *vx_parent; /* parent context */
+#define VXF_INFO_SCHED 0x00000002
+#define VXF_INFO_NPROC 0x00000004
+#define VXF_INFO_PRIVATE 0x00000008
- struct namespace *vx_namespace; /* private namespace */
- struct fs_struct *vx_fs; /* private namespace fs */
- uint64_t vx_flags; /* VX_INFO_xxx */
- uint64_t vx_bcaps; /* bounding caps (system) */
- uint64_t vx_ccaps; /* context caps (vserver) */
+#define VXF_INFO_INIT 0x00000010
+#define VXF_INFO_HIDE 0x00000020
+#define VXF_INFO_ULIMIT 0x00000040
+#define VXF_INFO_NSPACE 0x00000080
- pid_t vx_initpid; /* PID of fake init process */
+#define VXF_SCHED_HARD 0x00000100
+#define VXF_SCHED_PRIO 0x00000200
+#define VXF_SCHED_PAUSE 0x00000400
- struct _vx_limit limit; /* vserver limits */
- struct _vx_sched sched; /* vserver scheduler */
- struct _vx_cvirt cvirt; /* virtual/bias stuff */
- struct _vx_cacct cacct; /* context accounting */
+#define VXF_VIRT_MEM 0x00010000
+#define VXF_VIRT_UPTIME 0x00020000
+#define VXF_VIRT_CPU 0x00040000
+#define VXF_VIRT_LOAD 0x00080000
+#define VXF_VIRT_TIME 0x00100000
- char vx_name[65]; /* vserver name */
-};
+#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 VX_ADMIN 0x0001
-#define VX_WATCH 0x0002
-#define VX_DUMMY 0x0008
+#define VXF_SC_HELPER (1ULL<<36)
+#define VXF_REBOOT_KILL (1ULL<<37)
+#define VXF_PERSISTENT (1ULL<<38)
-#define VX_IDENT 0x0010
-#define VX_EQUIV 0x0020
-#define VX_PARENT 0x0040
-#define VX_CHILD 0x0080
+#define VXF_FORK_RSS (1ULL<<48)
+#define VXF_PROLIFIC (1ULL<<49)
-#define VX_ARG_MASK 0x00F0
+#define VXF_IGNEG_NICE (1ULL<<52)
-#define VX_DYNAMIC 0x0100
-#define VX_STATIC 0x0200
+#define VXF_ONE_TIME (0x0007ULL<<32)
-#define VX_ATR_MASK 0x0F00
+#define VXF_INIT_SET (VXF_STATE_SETUP|VXF_STATE_INIT|VXF_STATE_ADMIN)
-struct rcu_head;
+/* context migration */
-extern void rcu_free_vx_info(struct rcu_head *);
-extern void unhash_vx_info(struct vx_info *);
+#define VXM_SET_INIT 0x00000001
+#define VXM_SET_REAPER 0x00000002
-extern struct vx_info *locate_vx_info(int);
-extern struct vx_info *locate_or_create_vx_info(int);
+/* context caps */
-extern int get_xid_list(int, unsigned int *, int);
-extern int vx_info_is_hashed(xid_t);
+#define VXC_CAP_MASK 0x00000000
-extern int vx_migrate_task(struct task_struct *, struct vx_info *);
+#define VXC_SET_UTSNAME 0x00000001
+#define VXC_SET_RLIMIT 0x00000002
-#endif /* __KERNEL__ */
+#define VXC_RAW_ICMP 0x00000100
+#define VXC_SYSLOG 0x00001000
-#include "switch.h"
+#define VXC_SECURE_MOUNT 0x00010000
+#define VXC_SECURE_REMOUNT 0x00020000
+#define VXC_BINARY_MOUNT 0x00040000
-/* vinfo commands */
+#define VXC_QUOTA_CTL 0x00100000
+#define VXC_ADMIN_MAPPER 0x00200000
+#define VXC_ADMIN_CLOOP 0x00400000
-#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
-#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
#ifdef __KERNEL__
-extern int vc_task_xid(uint32_t, void __user *);
-#endif /* __KERNEL__ */
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/rcupdate.h>
-#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
-#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
+#include "limit_def.h"
+#include "sched_def.h"
+#include "cvirt_def.h"
+#include "cacct_def.h"
-struct vcmd_vx_info_v0 {
- uint32_t xid;
- uint32_t initpid;
- /* more to come */
+struct _vx_info_pc {
+ struct _vx_sched_pc sched_pc;
+ struct _vx_cvirt_pc cvirt_pc;
};
-#ifdef __KERNEL__
-extern int vc_vx_info(uint32_t, void __user *);
-
-#endif /* __KERNEL__ */
-
-#define VCMD_ctx_create VC_CMD(VPROC, 1, 0)
-#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 0)
+struct vx_info {
+ struct hlist_node vx_hlist; /* linked list of contexts */
+ xid_t vx_id; /* context id */
+ atomic_t vx_usecnt; /* usage count */
+ atomic_t vx_tasks; /* tasks count */
+ struct vx_info *vx_parent; /* parent context */
+ int vx_state; /* context state */
-#ifdef __KERNEL__
-extern int vc_ctx_create(uint32_t, void __user *);
-extern int vc_ctx_migrate(uint32_t, void __user *);
+ unsigned long vx_nsmask; /* assignment mask */
+ struct nsproxy *vx_nsproxy; /* private namespace */
+ struct fs_struct *vx_fs; /* private namespace fs */
-#endif /* __KERNEL__ */
+ 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 */
-#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
-#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
+ struct task_struct *vx_reaper; /* guest reaper process */
+ pid_t vx_initpid; /* PID of guest init */
-struct vcmd_ctx_flags_v0 {
- uint64_t flagword;
- uint64_t mask;
-};
-
-#ifdef __KERNEL__
-extern int vc_get_cflags(uint32_t, void __user *);
-extern int vc_set_cflags(uint32_t, void __user *);
+ struct _vx_limit limit; /* vserver limits */
+ struct _vx_sched sched; /* vserver scheduler */
+ struct _vx_cvirt cvirt; /* virtual/bias stuff */
+ struct _vx_cacct cacct; /* context accounting */
-#endif /* __KERNEL__ */
+#ifndef CONFIG_SMP
+ struct _vx_info_pc info_pc; /* per cpu data */
+#else
+ struct _vx_info_pc *ptr_pc; /* per cpu array */
+#endif
-#define VXF_INFO_LOCK 0x00000001
-#define VXF_INFO_SCHED 0x00000002
-#define VXF_INFO_NPROC 0x00000004
-#define VXF_INFO_PRIVATE 0x00000008
+ wait_queue_head_t vx_wait; /* context exit waitqueue */
+ int reboot_cmd; /* last sys_reboot() cmd */
+ int exit_code; /* last process exit code */
-#define VXF_INFO_INIT 0x00000010
-#define VXF_INFO_HIDE 0x00000020
-#define VXF_INFO_ULIMIT 0x00000040
-#define VXF_INFO_NSPACE 0x00000080
+ char vx_name[65]; /* vserver name */
+};
-#define VXF_SCHED_HARD 0x00000100
-#define VXF_SCHED_PRIO 0x00000200
-#define VXF_SCHED_PAUSE 0x00000400
+#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 VXF_VIRT_MEM 0x00010000
-#define VXF_VIRT_UPTIME 0x00020000
-#define VXF_VIRT_CPU 0x00040000
+#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
-#define VXF_HIDE_MOUNT 0x01000000
-#define VXF_HIDE_NETIF 0x02000000
-#define VXF_STATE_SETUP (1ULL<<32)
-#define VXF_STATE_INIT (1ULL<<33)
+struct vx_info_save {
+ struct vx_info *vxi;
+ xid_t xid;
+};
-#define VXF_FORK_RSS (1ULL<<48)
-#define VXF_PROLIFIC (1ULL<<49)
-#define VXF_ONE_TIME (0x0003ULL<<32)
+/* status flags */
-#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 0)
-#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 0)
+#define VXS_HASHED 0x0001
+#define VXS_PAUSED 0x0010
+#define VXS_SHUTDOWN 0x0100
+#define VXS_HELPER 0x1000
+#define VXS_RELEASED 0x8000
-struct vcmd_ctx_caps_v0 {
- uint64_t bcaps;
- uint64_t ccaps;
- uint64_t cmask;
-};
-#ifdef __KERNEL__
-extern int vc_get_ccaps(uint32_t, void __user *);
-extern int vc_set_ccaps(uint32_t, void __user *);
+extern void claim_vx_info(struct vx_info *, struct task_struct *);
+extern void release_vx_info(struct vx_info *, struct task_struct *);
-#endif /* __KERNEL__ */
+extern struct vx_info *lookup_vx_info(int);
+extern struct vx_info *lookup_or_create_vx_info(int);
-#define VXC_SET_UTSNAME 0x00000001
-#define VXC_SET_RLIMIT 0x00000002
+extern int get_xid_list(int, unsigned int *, int);
+extern int xid_is_hashed(xid_t);
-#define VXC_RAW_ICMP 0x00000100
+extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
-#define VXC_SECURE_MOUNT 0x00010000
+extern long vs_state_change(struct vx_info *, unsigned int);
+#endif /* __KERNEL__ */
#endif /* _VX_CONTEXT_H */