Context commands


Data Structures

struct  _vx_info
 Context information. More...
struct  _vx_stat
 Context statistics. More...
struct  _vx_flags
 Context/migration flags. More...
struct  _vx_uname
 Virtual system information data. More...
struct  _vx_wait
 Wait results. More...

Defines

#define CAP_CHOWN   0
#define CAP_DAC_OVERRIDE   1
#define CAP_DAC_READ_SEARCH   2
#define CAP_FOWNER   3
#define CAP_FSETID   4
#define CAP_KILL   5
#define CAP_SETGID   6
#define CAP_SETUID   7
#define CAP_SETPCAP   8
#define CAP_LINUX_IMMUTABLE   9
#define CAP_NET_BIND_SERVICE   10
#define CAP_NET_BROADCAST   11
#define CAP_NET_ADMIN   12
#define CAP_NET_RAW   13
#define CAP_IPC_LOCK   14
#define CAP_IPC_OWNER   15
#define CAP_SYS_MODULE   16
#define CAP_SYS_RAWIO   17
#define CAP_SYS_CHROOT   18
#define CAP_SYS_PTRACE   19
#define CAP_SYS_PACCT   20
#define CAP_SYS_ADMIN   21
#define CAP_SYS_BOOT   22
#define CAP_SYS_NICE   23
#define CAP_SYS_RESOURCE   24
#define CAP_SYS_TIME   25
#define CAP_SYS_TTY_CONFIG   26
#define CAP_MKNOD   27
#define CAP_LEASE   28
#define CAP_AUDIT_WRITE   29
#define CAP_AUDIT_CONTROL   30
#define CAP_CONTEXT   31
#define VXC_SET_UTSNAME   0x00000001
#define VXC_SET_RLIMIT   0x00000002
#define VXC_RAW_ICMP   0x00000100
#define VXC_SYSLOG   0x00001000
#define VXC_SECURE_MOUNT   0x00010000
#define VXC_SECURE_REMOUNT   0x00020000
#define VXC_BINARY_MOUNT   0x00040000
#define VXC_QUOTA_CTL   0x00100000
#define VXC_ADMIN_MAPPER   0x00200000
#define VXC_ADMIN_CLOOP   0x00400000
#define VXF_INFO_SCHED   0x00000002
#define VXF_INFO_NPROC   0x00000004
#define VXF_INFO_PRIVATE   0x00000008
#define VXF_INFO_INIT   0x00000010
#define VXF_INFO_HIDE   0x00000020
#define VXF_INFO_ULIMIT   0x00000040
#define VXF_INFO_NSPACE   0x00000080
#define VXF_SCHED_HARD   0x00000100
#define VXF_SCHED_PRIO   0x00000200
#define VXF_SCHED_PAUSE   0x00000400
#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
#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)
#define VXF_PERSISTENT   (1ULL<<38)
#define VXF_FORK_RSS   (1ULL<<48)
#define VXF_PROLIFIC   (1ULL<<49)
#define VXF_IGNEG_NICE   (1ULL<<52)
#define VXM_SET_INIT   0x00000001
#define VXM_SET_REAPER   0x00000002
#define VHIN_CONTEXT   0
#define VHIN_SYSNAME   1
#define VHIN_NODENAME   2
#define VHIN_RELEASE   3
#define VHIN_VERSION   4
#define VHIN_MACHINE   5
#define VHIN_DOMAINNAME   6

Typedefs

typedef uint32_t xid_t
typedef _vx_info vx_info_t
 Context information.
typedef _vx_stat vx_stat_t
 Context statistics.
typedef _vx_flags vx_flags_t
 Context/migration flags.
typedef _vx_uname vx_uname_t
 Virtual system information data.
typedef _vx_wait vx_wait_t
 Wait results.

Functions

int vx_create (xid_t xid, vx_flags_t *data)
 Create a new context.
int vx_migrate (xid_t xid, vx_flags_t *data)
 Migrate to an existing context.
int vx_task_xid (pid_t pid)
 Get the context ID of a process.
int vx_info (xid_t xid, vx_info_t *data)
 Get context information.
int vx_stat (xid_t xid, vx_stat_t *data)
 Get context statistics.
int vx_bcaps_set (xid_t xid, vx_flags_t *data)
 Set system capabilities.
int vx_bcaps_get (xid_t xid, vx_flags_t *data)
 Get system capabilities.
int vx_ccaps_set (xid_t xid, vx_flags_t *data)
 Set context capabilities.
int vx_ccaps_get (xid_t xid, vx_flags_t *data)
 Get context capabilities.
int vx_flags_set (xid_t xid, vx_flags_t *data)
 Set context flags.
int vx_flags_get (xid_t xid, vx_flags_t *data)
 Get context flags.
int vx_uname_set (xid_t xid, vx_uname_t *data)
 Set virtual system information.
int vx_uname_get (xid_t xid, vx_uname_t *data)
 Get virtual system information.
int vx_kill (xid_t xid, pid_t pid, int sig)
 Kill one or more processes.
int vx_wait (xid_t xid, vx_wait_t *data)
 Wait for context death.


Define Documentation

#define CAP_CHOWN   0

Definition at line 85 of file vserver.h.

#define CAP_DAC_OVERRIDE   1

Definition at line 86 of file vserver.h.

#define CAP_DAC_READ_SEARCH   2

Definition at line 87 of file vserver.h.

#define CAP_FOWNER   3

Definition at line 88 of file vserver.h.

#define CAP_FSETID   4

Definition at line 89 of file vserver.h.

#define CAP_KILL   5

Definition at line 90 of file vserver.h.

#define CAP_SETGID   6

Definition at line 91 of file vserver.h.

#define CAP_SETUID   7

Definition at line 92 of file vserver.h.

#define CAP_SETPCAP   8

Definition at line 93 of file vserver.h.

#define CAP_LINUX_IMMUTABLE   9

Definition at line 94 of file vserver.h.

#define CAP_NET_BIND_SERVICE   10

Definition at line 95 of file vserver.h.

#define CAP_NET_BROADCAST   11

Definition at line 96 of file vserver.h.

#define CAP_NET_ADMIN   12

Definition at line 97 of file vserver.h.

#define CAP_NET_RAW   13

Definition at line 98 of file vserver.h.

#define CAP_IPC_LOCK   14

Definition at line 99 of file vserver.h.

#define CAP_IPC_OWNER   15

Definition at line 100 of file vserver.h.

#define CAP_SYS_MODULE   16

Definition at line 101 of file vserver.h.

#define CAP_SYS_RAWIO   17

Definition at line 102 of file vserver.h.

#define CAP_SYS_CHROOT   18

Definition at line 103 of file vserver.h.

#define CAP_SYS_PTRACE   19

Definition at line 104 of file vserver.h.

#define CAP_SYS_PACCT   20

Definition at line 105 of file vserver.h.

#define CAP_SYS_ADMIN   21

Definition at line 106 of file vserver.h.

#define CAP_SYS_BOOT   22

Definition at line 107 of file vserver.h.

#define CAP_SYS_NICE   23

Definition at line 108 of file vserver.h.

#define CAP_SYS_RESOURCE   24

Definition at line 109 of file vserver.h.

#define CAP_SYS_TIME   25

Definition at line 110 of file vserver.h.

#define CAP_SYS_TTY_CONFIG   26

Definition at line 111 of file vserver.h.

#define CAP_MKNOD   27

Definition at line 112 of file vserver.h.

#define CAP_LEASE   28

Definition at line 113 of file vserver.h.

#define CAP_AUDIT_WRITE   29

Definition at line 114 of file vserver.h.

#define CAP_AUDIT_CONTROL   30

Definition at line 115 of file vserver.h.

#define CAP_CONTEXT   31

Definition at line 116 of file vserver.h.

#define VXC_SET_UTSNAME   0x00000001

Allow setdomainname(2) and sethostname(2)

Definition at line 120 of file vserver.h.

#define VXC_SET_RLIMIT   0x00000002

Allow setrlimit(2)

Definition at line 121 of file vserver.h.

#define VXC_RAW_ICMP   0x00000100

Allow raw ICMP sockets

Definition at line 122 of file vserver.h.

#define VXC_SYSLOG   0x00001000

Allow syslog(2)

Definition at line 123 of file vserver.h.

#define VXC_SECURE_MOUNT   0x00010000

Allow secure mount(2)

Definition at line 124 of file vserver.h.

#define VXC_SECURE_REMOUNT   0x00020000

Allow secure remount

Definition at line 125 of file vserver.h.

#define VXC_BINARY_MOUNT   0x00040000

Allow binary/network mounts

Definition at line 126 of file vserver.h.

#define VXC_QUOTA_CTL   0x00100000

Allow quota ioctl

Definition at line 127 of file vserver.h.

#define VXC_ADMIN_MAPPER   0x00200000

Allow access to device mapper

Definition at line 128 of file vserver.h.

#define VXC_ADMIN_CLOOP   0x00400000

Allow access to loop devices

Definition at line 129 of file vserver.h.

#define VXF_INFO_SCHED   0x00000002

Account all processes as one (L)

Definition at line 131 of file vserver.h.

#define VXF_INFO_NPROC   0x00000004

Apply process limits to context (L)

Definition at line 132 of file vserver.h.

#define VXF_INFO_PRIVATE   0x00000008

Context cannot be entered

Definition at line 133 of file vserver.h.

#define VXF_INFO_INIT   0x00000010

Show a fake init process

Definition at line 134 of file vserver.h.

#define VXF_INFO_HIDE   0x00000020

Hide context information in task status

Definition at line 135 of file vserver.h.

#define VXF_INFO_ULIMIT   0x00000040

Apply ulimits to context (L)

Definition at line 136 of file vserver.h.

#define VXF_INFO_NSPACE   0x00000080

Use private namespace (L)

Definition at line 137 of file vserver.h.

#define VXF_SCHED_HARD   0x00000100

Enable hard scheduler

Definition at line 138 of file vserver.h.

#define VXF_SCHED_PRIO   0x00000200

Enable priority scheduler

Definition at line 139 of file vserver.h.

#define VXF_SCHED_PAUSE   0x00000400

Pause context (unschedule)

Definition at line 140 of file vserver.h.

#define VXF_VIRT_MEM   0x00010000

Virtualize memory information

Definition at line 141 of file vserver.h.

#define VXF_VIRT_UPTIME   0x00020000

Virtualize uptime information

Definition at line 142 of file vserver.h.

#define VXF_VIRT_CPU   0x00040000

Virtualize cpu usage information

Definition at line 143 of file vserver.h.

#define VXF_VIRT_LOAD   0x00080000

Virtualize load average information

Definition at line 144 of file vserver.h.

#define VXF_VIRT_TIME   0x00100000

Allow per guest time offsets

Definition at line 145 of file vserver.h.

#define VXF_HIDE_MOUNT   0x01000000

Hide entries in /proc/$pid/mounts

Definition at line 146 of file vserver.h.

#define VXF_HIDE_NETIF   0x02000000

Hide foreign network interfaces

Definition at line 147 of file vserver.h.

#define VXF_HIDE_VINFO   0x04000000

Hide context information in task status

Definition at line 148 of file vserver.h.

#define VXF_STATE_SETUP   (1ULL<<32)

Enable setup state

Definition at line 149 of file vserver.h.

#define VXF_STATE_INIT   (1ULL<<33)

Enable init state

Definition at line 150 of file vserver.h.

#define VXF_STATE_ADMIN   (1ULL<<34)

Enable admin state

Definition at line 151 of file vserver.h.

#define VXF_SC_HELPER   (1ULL<<36)

Context state change helper

Definition at line 152 of file vserver.h.

#define VXF_REBOOT_KILL   (1ULL<<37)

Kill all processes on reboot(2)

Definition at line 153 of file vserver.h.

#define VXF_PERSISTENT   (1ULL<<38)

Make context persistent

Definition at line 154 of file vserver.h.

#define VXF_FORK_RSS   (1ULL<<48)

Block fork when over RSS

Definition at line 155 of file vserver.h.

#define VXF_PROLIFIC   (1ULL<<49)

Allow context to create new contexts

Definition at line 156 of file vserver.h.

#define VXF_IGNEG_NICE   (1ULL<<52)

Ignore priority raise

Definition at line 157 of file vserver.h.

#define VXM_SET_INIT   0x00000001

Make current process the new init

Definition at line 159 of file vserver.h.

#define VXM_SET_REAPER   0x00000002

Make current process the new reaper

Definition at line 160 of file vserver.h.

#define VHIN_CONTEXT   0

Definition at line 164 of file vserver.h.

#define VHIN_SYSNAME   1

Definition at line 165 of file vserver.h.

#define VHIN_NODENAME   2

Definition at line 166 of file vserver.h.

#define VHIN_RELEASE   3

Definition at line 167 of file vserver.h.

#define VHIN_VERSION   4

Definition at line 168 of file vserver.h.

#define VHIN_MACHINE   5

Definition at line 169 of file vserver.h.

#define VHIN_DOMAINNAME   6

Definition at line 170 of file vserver.h.


Typedef Documentation

typedef uint32_t xid_t

Context ID type

Definition at line 173 of file vserver.h.

typedef struct _vx_info vx_info_t

Context information.

typedef struct _vx_stat vx_stat_t

Context statistics.

typedef struct _vx_flags vx_flags_t

Context/migration flags.

typedef struct _vx_uname vx_uname_t

Virtual system information data.

typedef struct _vx_wait vx_wait_t

Wait results.


Function Documentation

int vx_create ( xid_t  xid,
vx_flags_t data 
)

Create a new context.

Parameters:
xid Context ID
data Initial context flags

Definition at line 61 of file context.c.

References _vx_flags::flags, and vserver().

00062 {
00063         struct vcmd_ctx_create kdata = {
00064                 .flagword = 0,
00065         };
00066 
00067         if (data)
00068                 kdata.flagword = data->flags;
00069 
00070         return vserver(VCMD_ctx_create, xid, &kdata);
00071 }

int vx_migrate ( xid_t  xid,
vx_flags_t data 
)

Migrate to an existing context.

Parameters:
xid Context ID
data Migration flags

Definition at line 73 of file context.c.

References _vx_flags::flags, and vserver().

00074 {
00075         struct vcmd_ctx_migrate kdata = {
00076                 .flagword = 0,
00077         };
00078 
00079         if (data)
00080                 kdata.flagword = data->flags;
00081 
00082         return vserver(VCMD_ctx_migrate, xid, &kdata);
00083 }

int vx_task_xid ( pid_t  pid  ) 

Get the context ID of a process.

Parameters:
pid Process ID
Returns:
Context ID

Definition at line 85 of file context.c.

References vserver().

00086 {
00087         return vserver(VCMD_task_xid, pid, NULL);
00088 }

int vx_info ( xid_t  xid,
vx_info_t data 
)

Get context information.

Parameters:
xid Context ID
data Empty vx_info_t struct to be filled

Definition at line 90 of file context.c.

References _vx_info::initpid, vserver(), and _vx_info::xid.

00091 {
00092         struct vcmd_vx_info_v0 kdata;
00093 
00094         int rc = vserver(VCMD_vx_info, xid, &kdata);
00095 
00096         if (rc == -1)
00097                 return rc;
00098 
00099         if (data) {
00100                 data->xid     = kdata.xid;
00101                 data->initpid = kdata.initpid;
00102         }
00103 
00104         return rc;
00105 }

int vx_stat ( xid_t  xid,
vx_stat_t data 
)

Get context statistics.

Parameters:
xid Context ID
data Empty vx_stat_t struct to be filled

Definition at line 107 of file context.c.

References _vx_stat::load, _vx_stat::nr_forks, _vx_stat::nr_onhold, _vx_stat::nr_running, _vx_stat::nr_threads, _vx_stat::nr_unintr, _vx_stat::offset, _vx_stat::tasks, _vx_stat::uptime, _vx_stat::usecnt, and vserver().

00108 {
00109         int rc;
00110         struct vcmd_ctx_stat_v0 kdata1;
00111         struct vcmd_virt_stat_v0 kdata2;
00112 
00113         rc = vserver(VCMD_ctx_stat, xid, &kdata1);
00114 
00115         if (rc == -1)
00116                 return rc;
00117 
00118         rc = vserver(VCMD_virt_stat, xid, &kdata2);
00119 
00120         if (rc == -1)
00121                 return rc;
00122 
00123         if (data) {
00124                 data->usecnt     = kdata1.usecnt;
00125                 data->tasks      = kdata1.tasks;
00126                 data->nr_threads = kdata2.nr_threads;
00127                 data->nr_running = kdata2.nr_running;
00128                 data->nr_unintr  = kdata2.nr_uninterruptible;
00129                 data->nr_onhold  = kdata2.nr_onhold;
00130                 data->nr_forks   = kdata2.nr_forks;
00131                 data->load[0]    = kdata2.load[0];
00132                 data->load[1]    = kdata2.load[1];
00133                 data->load[2]    = kdata2.load[2];
00134                 data->offset     = kdata2.offset;
00135                 data->uptime     = kdata2.uptime;
00136         }
00137 
00138         return rc;
00139 }

int vx_bcaps_set ( xid_t  xid,
vx_flags_t data 
)

Set system capabilities.

Parameters:
xid Context ID
data System capabilities

Definition at line 141 of file context.c.

References _vx_flags::flags, _vx_flags::mask, and vserver().

00142 {
00143         struct vcmd_bcaps kdata;
00144 
00145         if (!data)
00146                 return errno = EINVAL, -1;
00147 
00148         kdata.bcaps = data->flags;
00149         kdata.bmask = data->mask;
00150 
00151         return vserver(VCMD_set_bcaps, xid, &kdata);
00152 }

int vx_bcaps_get ( xid_t  xid,
vx_flags_t data 
)

Get system capabilities.

Parameters:
xid Context ID
data Empty vx_flags_t struct to be filled

Definition at line 154 of file context.c.

References _vx_flags::flags, _vx_flags::mask, and vserver().

00155 {
00156         struct vcmd_bcaps kdata;
00157 
00158         if (!data)
00159                 return errno = EINVAL, -1;
00160 
00161         int rc = vserver(VCMD_get_bcaps, xid, &kdata);
00162 
00163         if (rc == -1)
00164                 return rc;
00165 
00166         data->flags = kdata.bcaps;
00167         data->mask  = kdata.bmask;
00168 
00169         return rc;
00170 }

int vx_ccaps_set ( xid_t  xid,
vx_flags_t data 
)

Set context capabilities.

Parameters:
xid Context ID
data Context capabilities

Definition at line 172 of file context.c.

References _vx_flags::flags, _vx_flags::mask, and vserver().

00173 {
00174         struct vcmd_ctx_caps_v1 kdata;
00175 
00176         if (!data)
00177                 return errno = EINVAL, -1;
00178 
00179         kdata.ccaps = data->flags;
00180         kdata.cmask = data->mask;
00181 
00182         return vserver(VCMD_set_ccaps, xid, &kdata);
00183 }

int vx_ccaps_get ( xid_t  xid,
vx_flags_t data 
)

Get context capabilities.

Parameters:
xid Context ID
data Empty vx_flags_t struct to be filled

Definition at line 185 of file context.c.

References _vx_flags::flags, _vx_flags::mask, and vserver().

00186 {
00187         struct vcmd_ctx_caps_v1 kdata;
00188 
00189         if (!data)
00190                 return errno = EINVAL, -1;
00191 
00192         int rc = vserver(VCMD_get_ccaps, xid, &kdata);
00193 
00194         if (rc == -1)
00195                 return rc;
00196 
00197         data->flags = kdata.ccaps;
00198         data->mask  = kdata.cmask;
00199 
00200         return rc;
00201 }

int vx_flags_set ( xid_t  xid,
vx_flags_t data 
)

Set context flags.

Parameters:
xid Context ID
data Context flags

Definition at line 203 of file context.c.

References _vx_flags::flags, _vx_flags::mask, and vserver().

00204 {
00205         struct vcmd_ctx_flags_v0 kdata;
00206 
00207         if (!data)
00208                 return errno = EINVAL, -1;
00209 
00210         kdata.flagword = data->flags;
00211         kdata.mask     = data->mask;
00212 
00213         return vserver(VCMD_set_cflags, xid, &kdata);
00214 }

int vx_flags_get ( xid_t  xid,
vx_flags_t data 
)

Get context flags.

Parameters:
xid Context ID
data Empty vx_flags_t struct to be filled

Definition at line 216 of file context.c.

References _vx_flags::flags, _vx_flags::mask, and vserver().

00217 {
00218         struct vcmd_ctx_flags_v0 kdata;
00219 
00220         if (!data)
00221                 return errno = EINVAL, -1;
00222 
00223         int rc = vserver(VCMD_get_cflags, xid, &kdata);
00224 
00225         if (rc == -1)
00226                 return rc;
00227 
00228         data->flags = kdata.flagword;
00229         data->mask  = kdata.mask;
00230 
00231         return rc;
00232 }

int vx_uname_set ( xid_t  xid,
vx_uname_t data 
)

Set virtual system information.

Parameters:
xid Context ID
data Virtual system information data

Definition at line 234 of file context.c.

References _vx_uname::id, _vx_uname::value, and vserver().

00235 {
00236         struct vcmd_vhi_name_v0 kdata;
00237 
00238         if (!data)
00239                 return errno = EINVAL, -1;
00240 
00241         if (str_len(data->value) >= sizeof(kdata.name))
00242                 return errno = EINVAL, -1;
00243 
00244         kdata.field = data->id;
00245 
00246         str_zero(kdata.name, sizeof(kdata.name));
00247         str_cpyn(kdata.name, data->value, sizeof(kdata.name) - 1);
00248 
00249         return vserver(VCMD_set_vhi_name, xid, &kdata);
00250 }

int vx_uname_get ( xid_t  xid,
vx_uname_t data 
)

Get virtual system information.

Parameters:
xid Context ID
data Empty vx_uname_t struct to be filled

Definition at line 252 of file context.c.

References _vx_uname::id, _vx_uname::value, and vserver().

00253 {
00254         int rc;
00255         struct vcmd_vhi_name_v0 kdata;
00256 
00257         if (!data)
00258                 return errno = EINVAL, -1;
00259 
00260         kdata.field = data->id;
00261 
00262         rc = vserver(VCMD_get_vhi_name, xid, &kdata);
00263 
00264         if (rc == -1)
00265                 return rc;
00266 
00267         str_zero(data->value, sizeof(kdata.name));
00268         str_cpyn(data->value, kdata.name, sizeof(kdata.name) - 1);
00269 
00270         return rc;
00271 }

int vx_kill ( xid_t  xid,
pid_t  pid,
int  sig 
)

Kill one or more processes.

Parameters:
xid Context ID
pid Process ID
sig Signal number

Definition at line 273 of file context.c.

References vserver().

00274 {
00275         struct vcmd_ctx_kill_v0 kdata;
00276 
00277         kdata.pid = pid;
00278         kdata.sig = sig;
00279 
00280         return vserver(VCMD_ctx_kill, xid, &kdata);
00281 }

int vx_wait ( xid_t  xid,
vx_wait_t data 
)

Wait for context death.

Parameters:
xid Context ID
data Empty vx_wait_t struct to be filled

Definition at line 283 of file context.c.

References _vx_wait::exit_code, _vx_wait::reboot_cmd, and vserver().

00284 {
00285         struct vcmd_wait_exit_v0 kdata;
00286 
00287         int rc;
00288 
00289         rc = vserver(VCMD_wait_exit, xid, &kdata);
00290 
00291         if (rc == -1)
00292                 return -1;
00293 
00294         if (data) {
00295                 data->reboot_cmd = kdata.reboot_cmd;
00296                 data->exit_code  = kdata.exit_code;
00297         }
00298 
00299         return rc;
00300 }


Generated on Wed Jun 20 19:50:09 2007 for libvserver by  doxygen 1.5.2