Update disk usage info when get_disklimit called
[util-vserver.git] / python / vserverimpl.c
index 7a90cf0..6b1284c 100644 (file)
@@ -54,11 +54,17 @@ get_rspec(PyObject *resources, rspec_t *rspec)
       PyErr_SetString(PyExc_TypeError, "invalid rspec");
       return -1;
     }
-  if ((cpu_share = PyMapping_GetItemString(resources, "nm_cpu_share")) &&
-      (cpu_share = PyNumber_Int(cpu_share)))
-    rspec->cpu_share = PyInt_AsLong(cpu_share);
+  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 0;
+  return -1;
 }
 
 /*
@@ -145,7 +151,9 @@ vserver_setsched(PyObject *self, PyObject *args)
       get_rspec(resources, &rspec))
     return NULL;
 
-  if (pl_setsched(ctx, rspec.cpu_share, rspec.cpu_sched_flags))
+  /* ESRCH indicates that there are no processes in the context */
+  if (pl_setsched(ctx, rspec.cpu_share, rspec.cpu_sched_flags) &&
+      errno != ESRCH)
     return PyErr_SetFromErrno(PyExc_OSError);
 
   return Py_None;