Update CPU token buckets of running vserver
[util-vserver-pl.git] / python / vserverimpl.c
index 3ac9069..eef6f8e 100644 (file)
@@ -192,14 +192,14 @@ static PyObject *
 vserver_setsched(PyObject *self, PyObject *args)
 {
   xid_t  ctx;
+  uint32_t  cpu_min;
   uint32_t  cpu_share;
-  uint32_t  cpu_sched_flags = VC_VXF_SCHED_FLAGS;
 
-  if (!PyArg_ParseTuple(args, "II|I", &ctx, &cpu_share, &cpu_sched_flags))
+  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_share, cpu_sched_flags) &&
+  if (pl_setsched(ctx, cpu_min, cpu_share) &&
       errno != ESRCH)
     return PyErr_SetFromErrno(PyExc_OSError);
 
@@ -430,7 +430,7 @@ get_mask(struct vc_net_addr *addr)
     addr->vna_prefix = 64;
     break;
   default:
-    errno = -EINVAL;
+    errno = EINVAL;
     return -1;
   }
 
@@ -505,12 +505,13 @@ vserver_net_remove(PyObject *self, PyObject *args)
   else {
     if (convert_address(ip, &addr) == -1)
       return PyErr_Format(PyExc_ValueError, "%s is not a valid IP address", ip);
-    addr.vna_type |= VC_NXA_TYPE_ADDR;
-  }
 
-  switch (get_mask(&addr)) {
-  case -1:
-    return PyErr_SetFromErrno(PyExc_OSError);
+    switch (get_mask(&addr)) {
+    case -1:
+      return PyErr_SetFromErrno(PyExc_OSError);
+    }
+
+    addr.vna_type |= VC_NXA_TYPE_ADDR;
   }
 
   if (vc_net_remove(nid, &addr) == -1 && errno != ESRCH)
@@ -739,8 +740,4 @@ initvserverimpl(void)
   PyModule_AddIntConstant(mod, "VLIMIT_ANON", (int)VC_VLIMIT_ANON);
   PyModule_AddIntConstant(mod, "VLIMIT_SHMEM", (int)VC_VLIMIT_SHMEM);
 
-  /* scheduler flags */
-  PyModule_AddIntConstant(mod,
-                         "VS_SCHED_CPU_GUARANTEED",
-                         VS_SCHED_CPU_GUARANTEED);
 }