ia64/xen-unstable

changeset 12145:df5431b2b519

[XEND] Add more API implementations, add sched_id_get to xc.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Oct 26 17:59:49 2006 +0100 (2006-10-26)
parents 1f790f5fcdbb
children f7f8f0038920
files tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/XendStorageRepository.py
line diff
     1.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Wed Nov 01 10:12:13 2006 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Thu Oct 26 17:59:49 2006 +0100
     1.3 @@ -647,6 +647,15 @@ static PyObject *pyxc_shadow_mem_control
     1.4      return Py_BuildValue("i", mbarg);
     1.5  }
     1.6  
     1.7 +static PyObject *pyxc_sched_id_get(XcObject *self) {
     1.8 +    
     1.9 +    int sched_id;
    1.10 +    if (xc_sched_id(self->xc_handle, &sched_id) != 0)
    1.11 +        return PyErr_SetFromErrno(xc_error);
    1.12 +
    1.13 +    return Py_BuildValue("i", sched_id);
    1.14 +}
    1.15 +
    1.16  static PyObject *pyxc_sched_credit_domain_set(XcObject *self,
    1.17                                                PyObject *args,
    1.18                                                PyObject *kwds)
    1.19 @@ -976,6 +985,12 @@ static PyMethodDef pyxc_methods[] = {
    1.20        " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
    1.21        "Returns: [int] 0 on success; -1 on error.\n" },
    1.22  
    1.23 +    { "sched_id_get",
    1.24 +      (PyCFunction)pyxc_sched_id_get,
    1.25 +      METH_NOARGS, "\n"
    1.26 +      "Get the current scheduler type in use.\n"
    1.27 +      "Returns: [int] sched_id.\n" },    
    1.28 +
    1.29      { "sedf_domain_set",
    1.30        (PyCFunction)pyxc_sedf_domain_set,
    1.31        METH_KEYWORDS, "\n"
    1.32 @@ -1242,6 +1257,11 @@ PyMODINIT_FUNC initxc(void)
    1.33  
    1.34      Py_INCREF(xc_error);
    1.35      PyModule_AddObject(m, "Error", xc_error);
    1.36 +
    1.37 +    /* Expose some libxc constants to Python */
    1.38 +    PyModule_AddIntConstant(m, "XEN_SCHEDULER_SEDF", XEN_SCHEDULER_SEDF);
    1.39 +    PyModule_AddIntConstant(m, "XEN_SCHEDULER_CREDIT", XEN_SCHEDULER_CREDIT);
    1.40 +
    1.41  }
    1.42  
    1.43  
     2.1 --- a/tools/python/xen/xend/XendAPI.py	Wed Nov 01 10:12:13 2006 +0000
     2.2 +++ b/tools/python/xen/xend/XendAPI.py	Thu Oct 26 17:59:49 2006 +0100
     2.3 @@ -701,23 +701,23 @@ class XendAPI:
     2.4      
     2.5      def vm_get_actions_after_shutdown(self, session, vm_ref):
     2.6          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
     2.7 -        return xen_api_success('')
     2.8 +        return xen_api_success(dom.get_on_shutdown())
     2.9      
    2.10      def vm_get_actions_after_reboot(self, session, vm_ref):
    2.11          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    2.12 -        return xen_api_success('')
    2.13 +        return xen_api_success(dom.get_on_reboot())
    2.14      
    2.15      def vm_get_actions_after_suspend(self, session, vm_ref):
    2.16          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    2.17 -        return xen_api_success('')
    2.18 +        return xen_api_success(dom.get_on_suspend())
    2.19      
    2.20      def vm_get_actions_after_crash(self, session, vm_ref):
    2.21          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    2.22 -        return xen_api_success('')
    2.23 +        return xen_api_success(dom.get_on_crash())
    2.24      
    2.25      def vm_get_bios_boot(self, session, vm_ref):
    2.26          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    2.27 -        return xen_api_success('')
    2.28 +        return xen_api_success(dom.get_bios_boot())
    2.29      
    2.30      def vm_get_platform_std_vga(self, session, vm_ref):
    2.31          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Nov 01 10:12:13 2006 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Oct 26 17:59:49 2006 +0100
     3.3 @@ -1655,7 +1655,13 @@ class XendDomainInfo:
     3.4      def get_memory_static_min(self):
     3.5          return self.info['memory']
     3.6      def get_vcpus_policy(self):
     3.7 -        return '' # TODO
     3.8 +        sched_id = xc.sched_id_get()
     3.9 +        if sched_id == xen.lowlevel.xc.XEN_SCHEDULER_SEDF:
    3.10 +            return 'sedf'
    3.11 +        elif sched_id == xen.lowlevel.xc.XEN_SCHEDULER_CREDIT:
    3.12 +            return 'credit'
    3.13 +        else:
    3.14 +            return 'unknown'
    3.15      def get_vcpus_params(self):
    3.16          return '' # TODO
    3.17      def get_power_state(self):
     4.1 --- a/tools/python/xen/xend/XendStorageRepository.py	Wed Nov 01 10:12:13 2006 +0000
     4.2 +++ b/tools/python/xen/xend/XendStorageRepository.py	Thu Oct 26 17:59:49 2006 +0100
     4.3 @@ -100,6 +100,7 @@ class XendStorageRepository:
     4.4          """
     4.5          self.lock.acquire()
     4.6          try:
     4.7 +            # create directory if /var/lib/xend/storage does not exist
     4.8              if not os.path.exists(XEND_STORAGE_DIR):
     4.9                  os.makedirs(XEND_STORAGE_DIR)
    4.10                  os.chmod(XEND_STORAGE_DIR, 0700)
    4.11 @@ -111,6 +112,8 @@ class XendStorageRepository:
    4.12                  if filename[-5:] == XEND_STORAGE_QCOW_FILENAME[-5:]:
    4.13                      image_uuid = filename[:-5]
    4.14                      seen_images.append(image_uuid)
    4.15 +                    
    4.16 +                    # add this image if we haven't seen it before
    4.17                      if image_uuid not in self.images:
    4.18                          qcow_file = XEND_STORAGE_QCOW_FILENAME % image_uuid
    4.19                          cfg_file = XEND_STORAGE_VDICFG_FILENAME % image_uuid