- struct vc_ctx_caps caps;
- struct vc_ctx_flags flags;
- xid_t ctx, xid;
-
- caps.ccaps = ~vc_get_insecureccaps();
- caps.cmask = ~0ull;
- caps.bcaps = ~vc_get_insecurebcaps();
- caps.bmask = ~0ull;
-
- flags.flagword = VC_VXF_INFO_LOCK;
- flags.mask = VC_VXF_STATE_SETUP | VC_VXF_INFO_LOCK;
-
- if (!PyArg_ParseTuple(args, "I", &ctx))
- return NULL;
-
- xid = vc_ctx_create(ctx);
- if (xid == VC_NOCTX && errno != EEXIST) {
- return PyErr_SetFromErrno(PyExc_OSError);
- }
-
- if (vc_set_ccaps(ctx, &caps) == -1) {
- return PyErr_SetFromErrno(PyExc_OSError);
- }
-
- if (vc_set_cflags(ctx, &flags) == -1) {
- return PyErr_SetFromErrno(PyExc_OSError);
- }
+ xid_t ctx;
+ uint32_t flags = 0;
+ 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, &PyDict_Type, &resources, &flags))
+ return NULL;
+ if ((cpu_share = PyMapping_GetItemString(resources, "nm_cpu_share")) &&
+ (cpu_share = PyNumber_Int(cpu_share)))
+ rspec.cpu_share = PyInt_AsLong(cpu_share);