return NULL;
xid = vc_ctx_create(ctx);
- if (xid == VC_NOCTX && errno != EEXIST) {
+#ifdef MEF_DEBUG
+ printf("vserver_create xid = %d\n",xid);
+#endif
+ if (xid == VC_NOCTX && errno != EEXIST)
return PyErr_SetFromErrno(PyExc_OSError);
- }
return Py_None;
}
{
struct vc_ctx_caps caps;
struct vc_ctx_flags flags;
+#ifdef MEF_DEBUG
+ xid_t xid;
+#endif
xid_t ctx;
caps.ccaps = ~vc_get_insecureccaps();
caps.bcaps = ~vc_get_insecurebcaps();
caps.bmask = ~0ull;
- flags.flagword = VC_VXF_INFO_LOCK;
+ flags.flagword = VC_VXF_STATE_SETUP| VC_VXF_INFO_LOCK;
flags.mask = VC_VXF_STATE_SETUP | VC_VXF_INFO_LOCK;
if (!PyArg_ParseTuple(args, "I", &ctx))
return NULL;
- if (vc_set_ccaps(ctx, &caps) == -1) {
+#ifdef MEF_DEBUG
+ xid = vc_get_task_xid(0);
+ printf("vserver_flags xid = %d, ctx = %d\n",xid,ctx);
+#endif
+
+ if (vc_set_ccaps(ctx, &caps) == -1)
return PyErr_SetFromErrno(PyExc_OSError);
- }
- if (vc_set_cflags(ctx, &flags) == -1) {
+#ifdef MEF_DEBUG
+ xid = vc_get_task_xid(0);
+ printf("vserver_flags xid = %d, ctx = %d\n",xid,ctx);
+#endif
+
+ if (vc_set_cflags(ctx, &flags) == -1)
return PyErr_SetFromErrno(PyExc_OSError);
- }
+
+#ifdef MEF_DEBUG
+ xid = vc_get_task_xid(0);
+ printf("vserver_flags xid = %d, ctx = %d\n",xid,ctx);
+#endif
+
+
return Py_None;
}
if (!PyArg_ParseTuple(args, "I", &ctx))
return NULL;
- xid = vc_ctx_create(ctx);
- if (xid == VC_NOCTX && errno != EEXIST) {
- return PyErr_SetFromErrno(PyExc_OSError);
+ xid = vc_get_task_xid(0);
+#ifdef MEF_DEBUG
+ printf("vserver_enter xid = %d\n",xid);
+#endif
+ if (xid != ctx) {
+ if (xid!=0) {
+ errno=EPERM;
+ return PyErr_SetFromErrno(PyExc_OSError);
+ } else if (vc_ctx_migrate(ctx) == -1)
+ return PyErr_SetFromErrno(PyExc_OSError);
}
- if (xid == VC_NOCTX && vc_ctx_migrate(ctx) == -1) {
- return PyErr_SetFromErrno(PyExc_OSError);
- }
return Py_None;
}
static PyObject *
vserver_set_rlimit(PyObject *self, PyObject *args) {
struct vc_rlimit limits;
- int xid, resource;
+ xid_t xid;
+ int resource;
PyObject *ret;
limits.min = VC_LIM_KEEP;
limits.soft = VC_LIM_KEEP;
limits.hard = VC_LIM_KEEP;
- if (!PyArg_ParseTuple(args, "iiL", &xid, &resource, &limits.hard))
+ if (!PyArg_ParseTuple(args, "IiL", &xid, &resource, &limits.hard))
return NULL;
ret = Py_None;
static PyObject *
vserver_get_rlimit(PyObject *self, PyObject *args) {
struct vc_rlimit limits;
- int xid, resource;
+ xid_t xid;
+ int resource;
PyObject *ret;
limits.min = VC_LIM_KEEP;
limits.soft = VC_LIM_KEEP;
limits.hard = VC_LIM_KEEP;
- if (!PyArg_ParseTuple(args, "ii", &xid, &resource))
+ if (!PyArg_ParseTuple(args, "Ii", &xid, &resource))
return NULL;
ret = Py_None;
return NULL;
flags.flagword = VC_VXF_INFO_LOCK;
- flags.mask = VC_VXF_STATE_SETUP | VC_VXF_INFO_LOCK;
+ flags.mask = VC_VXF_INFO_LOCK;
flags.flagword |= VC_VXF_SCHED_HARD;
flags.mask |= VC_VXF_SCHED_HARD;
#define VC_VXF_SCHED_SHARE 0x00000800ull
flags.mask |= VC_VXF_SCHED_SHARE;
}
- if (vc_set_cflags(xid, &flags) == -1) {
+ if (vc_set_cflags(xid, &flags) == -1)
return PyErr_SetFromErrno(PyExc_OSError);
- }
if (vc_set_sched(xid, &sched) == -1)
return PyErr_SetFromErrno(PyExc_OSError);
"Create a new vserver context" },
{ "flags", vserver_flags, METH_VARARGS,
"Set the default flags and caps" },
- { "enter", vserver_flags, METH_VARARGS,
+ { "enter", vserver_enter, METH_VARARGS,
"Enter the vserver context" },
{ "setsched", vserver_setsched, METH_VARARGS,
"Change vserver scheduling attributes for given vserver context" },