mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
[XEND] Add more API implementations, add sched_id_get to xc.
Signed-off-by: Alastair Tse <atse@xensource.com>
This commit is contained in:
1 parent
4ed8357baa
commit
a5f7c42094
4 files changed
+35
-6
No files matched your search
@@ -647,6 +647,15 @@ static PyObject *pyxc_shadow_mem_control(PyObject *self,
|
||||
return Py_BuildValue("i", mbarg);
|
||||
}
|
||||
|
||||
static PyObject *pyxc_sched_id_get(XcObject *self) {
|
||||
|
||||
int sched_id;
|
||||
if (xc_sched_id(self->xc_handle, &sched_id) != 0)
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
return Py_BuildValue("i", sched_id);
|
||||
}
|
||||
|
||||
static PyObject *pyxc_sched_credit_domain_set(XcObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
@@ -976,6 +985,12 @@ static PyMethodDef pyxc_methods[] = {
|
||||
" vcpus [int, 1]: Number of Virtual CPUS in domain.\n\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "sched_id_get",
|
||||
(PyCFunction)pyxc_sched_id_get,
|
||||
METH_NOARGS, "\n"
|
||||
"Get the current scheduler type in use.\n"
|
||||
"Returns: [int] sched_id.\n" },
|
||||
|
||||
{ "sedf_domain_set",
|
||||
(PyCFunction)pyxc_sedf_domain_set,
|
||||
METH_KEYWORDS, "\n"
|
||||
@@ -1242,6 +1257,11 @@ PyMODINIT_FUNC initxc(void)
|
||||
|
||||
Py_INCREF(xc_error);
|
||||
PyModule_AddObject(m, "Error", xc_error);
|
||||
|
||||
/* Expose some libxc constants to Python */
|
||||
PyModule_AddIntConstant(m, "XEN_SCHEDULER_SEDF", XEN_SCHEDULER_SEDF);
|
||||
PyModule_AddIntConstant(m, "XEN_SCHEDULER_CREDIT", XEN_SCHEDULER_CREDIT);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -701,23 +701,23 @@ class XendAPI:
|
||||
|
||||
def vm_get_actions_after_shutdown(self, session, vm_ref):
|
||||
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
|
||||
return xen_api_success('')
|
||||
return xen_api_success(dom.get_on_shutdown())
|
||||
|
||||
def vm_get_actions_after_reboot(self, session, vm_ref):
|
||||
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
|
||||
return xen_api_success('')
|
||||
return xen_api_success(dom.get_on_reboot())
|
||||
|
||||
def vm_get_actions_after_suspend(self, session, vm_ref):
|
||||
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
|
||||
return xen_api_success('')
|
||||
return xen_api_success(dom.get_on_suspend())
|
||||
|
||||
def vm_get_actions_after_crash(self, session, vm_ref):
|
||||
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
|
||||
return xen_api_success('')
|
||||
return xen_api_success(dom.get_on_crash())
|
||||
|
||||
def vm_get_bios_boot(self, session, vm_ref):
|
||||
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
|
||||
return xen_api_success('')
|
||||
return xen_api_success(dom.get_bios_boot())
|
||||
|
||||
def vm_get_platform_std_vga(self, session, vm_ref):
|
||||
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
|
||||
|
||||
@@ -1655,7 +1655,13 @@ class XendDomainInfo:
|
||||
def get_memory_static_min(self):
|
||||
return self.info['memory']
|
||||
def get_vcpus_policy(self):
|
||||
return '' # TODO
|
||||
sched_id = xc.sched_id_get()
|
||||
if sched_id == xen.lowlevel.xc.XEN_SCHEDULER_SEDF:
|
||||
return 'sedf'
|
||||
elif sched_id == xen.lowlevel.xc.XEN_SCHEDULER_CREDIT:
|
||||
return 'credit'
|
||||
else:
|
||||
return 'unknown'
|
||||
def get_vcpus_params(self):
|
||||
return '' # TODO
|
||||
def get_power_state(self):
|
||||
|
||||
@@ -100,6 +100,7 @@ class XendStorageRepository:
|
||||
"""
|
||||
self.lock.acquire()
|
||||
try:
|
||||
# create directory if /var/lib/xend/storage does not exist
|
||||
if not os.path.exists(XEND_STORAGE_DIR):
|
||||
os.makedirs(XEND_STORAGE_DIR)
|
||||
os.chmod(XEND_STORAGE_DIR, 0700)
|
||||
@@ -111,6 +112,8 @@ class XendStorageRepository:
|
||||
if filename[-5:] == XEND_STORAGE_QCOW_FILENAME[-5:]:
|
||||
image_uuid = filename[:-5]
|
||||
seen_images.append(image_uuid)
|
||||
|
||||
# add this image if we haven't seen it before
|
||||
if image_uuid not in self.images:
|
||||
qcow_file = XEND_STORAGE_QCOW_FILENAME % image_uuid
|
||||
cfg_file = XEND_STORAGE_VDICFG_FILENAME % image_uuid
|
||||
|
||||