-.X_user_local_etc-up-to-date
+.X_usr_local_etc-up-to-date
.deps
.fixups
.pathconfig.h.pathsubst.stamp
import fcntl
import os
import re
+import signal
import sys
import time
import traceback
def __do_chcontext(self, state_file):
- vserverimpl.chcontext(self.ctx, self.resources)
+ if state_file:
+ print >>state_file, "S_CONTEXT=%u" % self.ctx
+ print >>state_file, "S_PROFILE="
+ state_file.close()
- if not state_file:
- return
- print >>state_file, "S_CONTEXT=%d" % self.ctx
- print >>state_file, "S_PROFILE=%s" % self.config.get("S_PROFILE", "")
- state_file.close()
+ vserverimpl.chcontext(self.ctx, self.resources)
def __prep(self, runlevel, log):
self.__do_chroot()
log = open("/var/log/boot.log", "w", 0)
os.dup2(1, 2)
- # XXX - close all other fds
print >>log, ("%s: starting the virtual server %s" %
(time.asctime(time.gmtime()), self.name))
(self.disk_inodes, self.disk_blocks, size) = vduimpl.vdu(self.dir)
return size
+
+ def stop(self, signal = signal.SIGKILL):
+
+ vserverimpl.killall(self.ctx, signal)
+ self.vm_running = False
#include "vserver.h"
#include "vserver-internal.h"
+static int
+get_rspec(PyObject *resources, rspec_t *rspec)
+{
+ PyObject *cpu_share;
+
+ if (!PyMapping_Check(resources))
+ {
+ PyErr_SetString(PyExc_TypeError, "invalid rspec");
+ return -1;
+ }
+ if ((cpu_share = PyMapping_GetItemString(resources, "nm_cpu_share")))
+ {
+ if (PyInt_Check(cpu_share))
+ {
+ rspec->cpu_share = PyInt_AS_LONG(cpu_share);
+ return 0;
+ }
+ PyErr_SetString(PyExc_TypeError, "nm_cpu_share not an integer");
+ }
+
+ return -1;
+}
+
/*
* context create
*/
uint32_t bcaps = ~vc_get_insecurebcaps();
rspec_t rspec = { 32, VC_VXF_SCHED_FLAGS, -1, -1 };
PyObject *resources;
- PyObject *cpu_share;
- if (!PyArg_ParseTuple(args, "IO|K", &ctx, &resources, &flags))
+ if (!PyArg_ParseTuple(args, "IO|K", &ctx, &resources, &flags) ||
+ get_rspec(resources, &rspec))
return NULL;
- if (!PyMapping_Check(resources))
- {
- PyErr_SetString(PyExc_TypeError, "invalid resources object");
- return NULL;
- }
- if ((cpu_share = PyMapping_GetItemString(resources, "nm_cpu_share")) &&
- (cpu_share = PyNumber_Int(cpu_share)))
- rspec.cpu_share = PyInt_AsLong(cpu_share);
if (pl_chcontext(ctx, flags, bcaps, &rspec))
- PyErr_SetFromErrno(PyExc_OSError);
+ return PyErr_SetFromErrno(PyExc_OSError);
return Py_None;
}
xid_t ctx;
rspec_t rspec = { 32, VC_VXF_SCHED_FLAGS, -1, -1 };
PyObject *resources;
- PyObject *cpu_share;
- if (!PyArg_ParseTuple(args, "IO", &ctx, &resources))
+ if (!PyArg_ParseTuple(args, "IO", &ctx, &resources) ||
+ get_rspec(resources, &rspec))
return NULL;
- if (!PyMapping_Check(resources))
- {
- PyErr_SetString(PyExc_TypeError, "invalid resources object");
- return NULL;
- }
- if ((cpu_share = PyMapping_GetItemString(resources, "nm_cpu_share")) &&
- (cpu_share = PyNumber_Int(cpu_share)))
- rspec.cpu_share = PyInt_AsLong(cpu_share);
if (pl_setsched(ctx, rspec.cpu_share, rspec.cpu_sched_flags))
- PyErr_SetFromErrno(PyExc_OSError);
+ return PyErr_SetFromErrno(PyExc_OSError);
return Py_None;
}
return Py_None;
}
+static PyObject *
+vserver_killall(PyObject *self, PyObject *args)
+{
+ xid_t ctx;
+ int sig;
+
+ if (!PyArg_ParseTuple(args, "Ii", &ctx, &sig))
+ return NULL;
+
+ if (vc_ctx_kill(ctx, 0, sig) && errno != ESRCH)
+ return PyErr_SetFromErrno(PyExc_OSError);
+
+ return Py_None;
+}
+
static PyMethodDef methods[] = {
{ "chcontext", vserver_chcontext, METH_VARARGS,
"chcontext to vserver with provided flags" },
"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" },
{ NULL, NULL, 0, NULL }
};
{0,0}};
get_limits(context,list);
+
+ /* check whether the slice has been disabled */
+ if (!cpu)
+ {
+ fprintf(stderr, "*** this slice has been suspended ***\n");
+ exit(0);
+ }
+
(void) (sandbox_chroot(ctx));
rspec.cpu_share = cpu;
%define name util-vserver
%define version 0.30.208
-%define release 6.planetlab%{?date:.%{date}}
+%define release 7.planetlab%{?date:.%{date}}
%define _without_dietlibc 1
%define _without_xalan 1
+# don't build debuginfo RPM
+%define debug_package %{nil}
+
Vendor: PlanetLab
Packager: PlanetLab Central <support@planet-lab.org>
Distribution: PlanetLab 3.0
%changelog
+* Fri Dec 2 2005 Steve Muir <smuir@cs.princeton.edu>
+- fix bugs in python/vserverimpl.c where exceptions were not raised when
+ they should be and thus occured later at unexpected times
+- add support for stopping a vserver
+
* Wed Nov 9 2005 Steve Muir <smuir@cs.princeton.edu>
- add support for removing resource limits e.g., when a slice is deleted
%define name @PACKAGE@
%define version @VERSION@
-%define release 1.planetlab%{?date:.%{date}}
+%define release 7.planetlab%{?date:.%{date}}
%define _without_dietlibc 1
%define _without_xalan 1
+# don't build debuginfo RPM
+%define debug_package %{nil}
+
Vendor: PlanetLab
Packager: PlanetLab Central <support@planet-lab.org>
Distribution: PlanetLab 3.0
%changelog
+* Fri Dec 2 2005 Steve Muir <smuir@cs.princeton.edu>
+- fix bugs in python/vserverimpl.c where exceptions were not raised when
+ they should be and thus occured later at unexpected times
+- add support for stopping a vserver
+
+* Wed Nov 9 2005 Steve Muir <smuir@cs.princeton.edu>
+- add support for removing resource limits e.g., when a slice is deleted
+
+* Mon Nov 7 2005 Steve Muir <smuir@cs.princeton.edu>
+- fix file descriptor leak in vduimpl
+- clean up handling of network parameters
+- don't rely upon /etc/vservers/foo.conf to initialise vserver object
+
+* Wed Nov 2 2005 Steve Muir <smuir@cs.princeton.edu>
+- fix Python modules to handling scheduling parameters correctly
+
+* Fri Oct 28 2005 Steve Muir <smuir@cs.princeton.edu>
+- raise exception about being over disk limit after setting usage values
+
+* Fri Oct 7 2005 Steve Muir <smuir@cs.princeton.edu>
+- create common function to be used for entering a vserver and applying
+ resource limits
+
* Thu Aug 21 2005 Mark Huang <mlhuang@cs.princeton.edu>
- restore build of python modules