X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=python%2Fvserverimpl.c;h=c1725f3a76aa5ea139c21bf922128944b4905ae4;hb=944bb2f51d4666898ea0365a74bcfc5b66c9d2a2;hp=b9a06aac0fc33d3fe069db1a006821110f29fa36;hpb=e42b91ff38049501d06ec043cf2d49ee43881fb9;p=util-vserver-pl.git diff --git a/python/vserverimpl.c b/python/vserverimpl.c index b9a06aa..c1725f3 100644 --- a/python/vserverimpl.c +++ b/python/vserverimpl.c @@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "config.h" #include "vserver.h" -#include "planetlab.h" static inline PyObject *inc_and_ret_none(void) { @@ -62,60 +61,6 @@ static inline PyObject *inc_and_ret_none(void) #define PL_INSECURE_BCAPS (vc_get_insecurebcaps() | (1 << VC_CAP_NET_BIND_SERVICE)) #define PL_INSECURE_CCAPS vc_get_insecureccaps() -/* - * context create - */ -static PyObject * -vserver_chcontext(PyObject *self, PyObject *args) -{ - int ctx_is_new; - xid_t ctx; - uint_least64_t bcaps = 0; - - if (!PyArg_ParseTuple(args, "I|K", &ctx, &bcaps)) - return NULL; - bcaps |= ~PL_INSECURE_BCAPS; - - if ((ctx_is_new = pl_chcontext(ctx, bcaps, 0)) < 0) - return PyErr_SetFromErrno(PyExc_OSError); - - return PyBool_FromLong(ctx_is_new); -} - -static PyObject * -vserver_setup_done(PyObject *self, PyObject *args) -{ - xid_t ctx; - - if (!PyArg_ParseTuple(args, "I", &ctx)) - return NULL; - - if (pl_setup_done(ctx) < 0) - return PyErr_SetFromErrno(PyExc_OSError); - - return NONE; -} - -static PyObject * -vserver_isrunning(PyObject *self, PyObject *args) -{ - xid_t ctx; - PyObject *ret; - struct stat statbuf; - char fname[64]; - - if (!PyArg_ParseTuple(args, "I", &ctx)) - return NULL; - - sprintf(fname,"/proc/virtual/%d", ctx); - - if(stat(&fname[0],&statbuf)==0) - ret = PyBool_FromLong(1); - else - ret = PyBool_FromLong(0); - - return ret; -} static PyObject * __vserver_get_rlimit(xid_t xid, int resource) { @@ -152,7 +97,7 @@ vserver_set_rlimit(PyObject *self, PyObject *args) { uint32_t bitmask; xid_t xid; int resource; - PyObject *ret; + PyObject *ret = NULL; limits.min = VC_LIM_KEEP; limits.soft = VC_LIM_KEEP; @@ -177,26 +122,6 @@ vserver_set_rlimit(PyObject *self, PyObject *args) { return ret; } -/* - * setsched - */ -static PyObject * -vserver_setsched(PyObject *self, PyObject *args) -{ - xid_t ctx; - uint32_t cpu_min; - uint32_t cpu_share; - - if (!PyArg_ParseTuple(args, "II|I", &ctx, &cpu_min, &cpu_share)) - return NULL; - - /* ESRCH indicates that there are no processes in the context */ - if (pl_setsched(ctx, cpu_min, cpu_share) && - errno != ESRCH) - return PyErr_SetFromErrno(PyExc_OSError); - - return NONE; -} static PyObject * vserver_get_dlimit(PyObject *self, PyObject *args) @@ -266,34 +191,6 @@ vserver_unset_dlimit(PyObject *self, PyObject *args) return NONE; } -static PyObject * -vserver_killall(PyObject *self, PyObject *args) -{ - xid_t ctx; - int sig; - struct vc_ctx_flags cflags = { - .flagword = 0, - .mask = VC_VXF_PERSISTENT - }; - struct vc_net_flags nflags = { - .flagword = 0, - .mask = VC_NXF_PERSISTENT - }; - - if (!PyArg_ParseTuple(args, "Ii", &ctx, &sig)) - return NULL; - - if (vc_ctx_kill(ctx, 0, sig) && errno != ESRCH) - return PyErr_SetFromErrno(PyExc_OSError); - - if (vc_set_cflags(ctx, &cflags) && errno != ESRCH) - return PyErr_SetFromErrno(PyExc_OSError); - - if (vc_set_nflags(ctx, &nflags) && errno != ESRCH) - return PyErr_SetFromErrno(PyExc_OSError); - - return NONE; -} static PyObject * vserver_set_bcaps(PyObject *self, PyObject *args) @@ -775,13 +672,8 @@ vserver_get_name(PyObject *self, PyObject *args) return ret; } + static PyMethodDef methods[] = { - { "chcontext", vserver_chcontext, METH_VARARGS, - "chcontext to vserver with provided flags" }, - { "setup_done", vserver_setup_done, METH_VARARGS, - "Release vserver setup lock" }, - { "setsched", vserver_setsched, METH_VARARGS, - "Change vserver scheduling attributes for given vserver context" }, { "setdlimit", vserver_set_dlimit, METH_VARARGS, "Set disk limits for given vserver context" }, { "unsetdlimit", vserver_unset_dlimit, METH_VARARGS, @@ -792,10 +684,6 @@ static PyMethodDef methods[] = { "Set resource limits for given resource of a vserver context" }, { "getrlimit", vserver_get_rlimit, METH_VARARGS, "Get resource limits for given resource of a vserver context" }, - { "killall", vserver_killall, METH_VARARGS, - "Send signal to all processes in vserver context" }, - { "isrunning", vserver_isrunning, METH_VARARGS, - "Check if vserver is running"}, { "setbcaps", vserver_set_bcaps, METH_VARARGS, "Set POSIX capabilities of a vserver context" }, { "getbcaps", vserver_get_bcaps, METH_VARARGS, @@ -845,6 +733,7 @@ initvserverimpl(void) /* export limit-related constants */ PyModule_AddIntConstant(mod, "DLIMIT_KEEP", (int)VC_CDLIM_KEEP); PyModule_AddIntConstant(mod, "DLIMIT_INF", (int)VC_CDLIM_INFINITY); + PyModule_AddIntConstant(mod, "VC_LIM_INFINITY", (int)VC_LIM_INFINITY); PyModule_AddIntConstant(mod, "VC_LIM_KEEP", (int)VC_LIM_KEEP); PyModule_AddIntConstant(mod, "RLIMIT_CPU", (int)RLIMIT_CPU);