⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xc.c

📁 xen 3.2.2 源码
💻 C
📖 第 1 页 / 共 4 页
字号:
static PyObject *pyxc_sedf_domain_set(XcObject *self,                                      PyObject *args,                                      PyObject *kwds){    uint32_t domid;    uint64_t period, slice, latency;    uint16_t extratime, weight;    static char *kwd_list[] = { "domid", "period", "slice",                                "latency", "extratime", "weight",NULL };        if( !PyArg_ParseTupleAndKeywords(args, kwds, "iLLLhh", kwd_list,                                      &domid, &period, &slice,                                     &latency, &extratime, &weight) )        return NULL;   if ( xc_sedf_domain_set(self->xc_handle, domid, period,                           slice, latency, extratime,weight) != 0 )        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}static PyObject *pyxc_sedf_domain_get(XcObject *self, PyObject *args){    uint32_t domid;    uint64_t period, slice,latency;    uint16_t weight, extratime;        if(!PyArg_ParseTuple(args, "i", &domid))        return NULL;        if (xc_sedf_domain_get(self->xc_handle, domid, &period,                           &slice,&latency,&extratime,&weight))        return pyxc_error_to_exception();    return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i,s:i}",                         "domid",    domid,                         "period",    period,                         "slice",     slice,                         "latency",   latency,                         "extratime", extratime,                         "weight",    weight);}static PyObject *pyxc_shadow_control(PyObject *self,                                     PyObject *args,                                     PyObject *kwds){    XcObject *xc = (XcObject *)self;    uint32_t dom;    int op=0;    static char *kwd_list[] = { "dom", "op", NULL };    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,                                       &dom, &op) )        return NULL;        if ( xc_shadow_control(xc->xc_handle, dom, op, NULL, 0, NULL, 0, NULL)          < 0 )        return pyxc_error_to_exception();        Py_INCREF(zero);    return zero;}static PyObject *pyxc_shadow_mem_control(PyObject *self,                                         PyObject *args,                                         PyObject *kwds){    XcObject *xc = (XcObject *)self;    int op;    uint32_t dom;    int mbarg = -1;    unsigned long mb;    static char *kwd_list[] = { "dom", "mb", NULL };    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,                                       &dom, &mbarg) )        return NULL;        if ( mbarg < 0 )         op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;    else     {        mb = mbarg;        op = XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION;    }    if ( xc_shadow_control(xc->xc_handle, dom, op, NULL, 0, &mb, 0, NULL) < 0 )        return pyxc_error_to_exception();        mbarg = mb;    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_obj);    return Py_BuildValue("i", sched_id);}static PyObject *pyxc_sched_credit_domain_set(XcObject *self,                                              PyObject *args,                                              PyObject *kwds){    uint32_t domid;    uint16_t weight;    uint16_t cap;    static char *kwd_list[] = { "domid", "weight", "cap", NULL };    static char kwd_type[] = "I|HH";    struct xen_domctl_sched_credit sdom;        weight = 0;    cap = (uint16_t)~0U;    if( !PyArg_ParseTupleAndKeywords(args, kwds, kwd_type, kwd_list,                                      &domid, &weight, &cap) )        return NULL;    sdom.weight = weight;    sdom.cap = cap;    if ( xc_sched_credit_domain_set(self->xc_handle, domid, &sdom) != 0 )        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}static PyObject *pyxc_sched_credit_domain_get(XcObject *self, PyObject *args){    uint32_t domid;    struct xen_domctl_sched_credit sdom;        if( !PyArg_ParseTuple(args, "I", &domid) )        return NULL;        if ( xc_sched_credit_domain_get(self->xc_handle, domid, &sdom) != 0 )        return pyxc_error_to_exception();    return Py_BuildValue("{s:H,s:H}",                         "weight",  sdom.weight,                         "cap",     sdom.cap);}static PyObject *pyxc_domain_setmaxmem(XcObject *self, PyObject *args){    uint32_t dom;    unsigned int maxmem_kb;    if (!PyArg_ParseTuple(args, "ii", &dom, &maxmem_kb))        return NULL;    if (xc_domain_setmaxmem(self->xc_handle, dom, maxmem_kb) != 0)        return pyxc_error_to_exception();        Py_INCREF(zero);    return zero;}static PyObject *pyxc_domain_set_memmap_limit(XcObject *self, PyObject *args){    uint32_t dom;    unsigned int maplimit_kb;    if ( !PyArg_ParseTuple(args, "ii", &dom, &maplimit_kb) )        return NULL;    if ( xc_domain_set_memmap_limit(self->xc_handle, dom, maplimit_kb) != 0 )        return pyxc_error_to_exception();        Py_INCREF(zero);    return zero;}static PyObject *pyxc_domain_memory_increase_reservation(XcObject *self,                                                         PyObject *args,                                                         PyObject *kwds){    uint32_t dom;    unsigned long mem_kb;    unsigned int extent_order = 0 , address_bits = 0;    unsigned long nr_extents;    static char *kwd_list[] = { "domid", "mem_kb", "extent_order", "address_bits", NULL };    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "il|ii", kwd_list,                                       &dom, &mem_kb, &extent_order, &address_bits) )        return NULL;    /* round down to nearest power of 2. Assume callers using extent_order>0       know what they are doing */    nr_extents = (mem_kb / (XC_PAGE_SIZE/1024)) >> extent_order;    if ( xc_domain_memory_increase_reservation(self->xc_handle, dom,                                                nr_extents, extent_order,                                                address_bits, NULL) )        return pyxc_error_to_exception();        Py_INCREF(zero);    return zero;}static PyObject *pyxc_domain_ioport_permission(XcObject *self,                                               PyObject *args,                                               PyObject *kwds){    uint32_t dom;    int first_port, nr_ports, allow_access, ret;    static char *kwd_list[] = { "domid", "first_port", "nr_ports", "allow_access", NULL };    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiii", kwd_list,                                       &dom, &first_port, &nr_ports, &allow_access) )        return NULL;    ret = xc_domain_ioport_permission(        self->xc_handle, dom, first_port, nr_ports, allow_access);    if ( ret != 0 )        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}static PyObject *pyxc_domain_irq_permission(PyObject *self,                                            PyObject *args,                                            PyObject *kwds){    XcObject *xc = (XcObject *)self;    uint32_t dom;    int pirq, allow_access, ret;    static char *kwd_list[] = { "domid", "pirq", "allow_access", NULL };    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list,                                       &dom, &pirq, &allow_access) )        return NULL;    ret = xc_domain_irq_permission(        xc->xc_handle, dom, pirq, allow_access);    if ( ret != 0 )        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}static PyObject *pyxc_domain_iomem_permission(PyObject *self,                                               PyObject *args,                                               PyObject *kwds){    XcObject *xc = (XcObject *)self;    uint32_t dom;    unsigned long first_pfn, nr_pfns, allow_access, ret;    static char *kwd_list[] = { "domid", "first_pfn", "nr_pfns", "allow_access", NULL };    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illi", kwd_list,                                       &dom, &first_pfn, &nr_pfns, &allow_access) )        return NULL;    ret = xc_domain_iomem_permission(        xc->xc_handle, dom, first_pfn, nr_pfns, allow_access);    if ( ret != 0 )        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}static PyObject *pyxc_domain_set_time_offset(XcObject *self, PyObject *args){    uint32_t dom;    int32_t offset;    if (!PyArg_ParseTuple(args, "ii", &dom, &offset))        return NULL;    if (xc_domain_set_time_offset(self->xc_handle, dom, offset) != 0)        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}static PyObject *pyxc_domain_send_trigger(XcObject *self,                                          PyObject *args,                                          PyObject *kwds){    uint32_t dom;    int trigger, vcpu = 0;    static char *kwd_list[] = { "domid", "trigger", "vcpu", NULL };    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|i", kwd_list,                                       &dom, &trigger, &vcpu) )        return NULL;    if (xc_domain_send_trigger(self->xc_handle, dom, trigger, vcpu) != 0)        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}static PyObject *pyxc_send_debug_keys(XcObject *self,                                      PyObject *args,                                      PyObject *kwds){    char *keys;    static char *kwd_list[] = { "keys", NULL };    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "s", kwd_list, &keys) )        return NULL;    if ( xc_send_debug_keys(self->xc_handle, keys) != 0 )        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}static PyObject *dom_op(XcObject *self, PyObject *args,                        int (*fn)(int, uint32_t)){    uint32_t dom;    if (!PyArg_ParseTuple(args, "i", &dom))        return NULL;    if (fn(self->xc_handle, dom) != 0)        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}#ifdef __powerpc__static PyObject *pyxc_alloc_real_mode_area(XcObject *self,                                           PyObject *args,                                           PyObject *kwds){    uint32_t dom;    unsigned int log;    static char *kwd_list[] = { "dom", "log", NULL };    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,                                       &dom, &log) )        return NULL;    if ( xc_alloc_real_mode_area(self->xc_handle, dom, log) )        return pyxc_error_to_exception();    Py_INCREF(zero);    return zero;}#endif /* powerpc */static PyMethodDef pyxc_methods[] = {    { "handle",      (PyCFunction)pyxc_handle,      METH_NOARGS, "\n"      "Query the xc control interface file descriptor.\n\n"      "Returns: [int] file descriptor\n" },    { "domain_create",       (PyCFunction)pyxc_domain_create,       METH_VARARGS | METH_KEYWORDS, "\n"      "Create a new domain.\n"      " dom    [int, 0]:        Domain identifier to use (allocated if zero).\n"      "Returns: [int] new domain identifier; -1 on error.\n" },    { "domain_max_vcpus",       (PyCFunction)pyxc_domain_max_vcpus,      METH_VARARGS, "\n"      "Set the maximum number of VCPUs a domain may create.\n"      " dom       [int, 0]:      Domain identifier to use.\n"      " max     [int, 0]:      New maximum number of VCPUs in domain.\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "domain_dumpcore",       (PyCFunction)pyxc_domain_dumpcore,       METH_VARARGS, "\n"      "Dump core of a domain.\n"      " dom [int]: Identifier of domain to dump core of.\n"      " corefile [string]: Name of corefile to be created.\n\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "domain_pause",       (PyCFunction)pyxc_domain_pause,       METH_VARARGS, "\n"      "Temporarily pause execution of a domain.\n"      " dom [int]: Identifier of domain to be paused.\n\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "domain_unpause",       (PyCFunction)pyxc_domain_unpause,       METH_VARARGS, "\n"      "(Re)start execution of a domain.\n"      " dom [int]: Identifier of domain to be unpaused.\n\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "domain_destroy",       (PyCFunction)pyxc_domain_destroy,       METH_VARARGS, "\n"      "Destroy a domain.\n"      " dom [int]:    Identifier of domain to be destroyed.\n\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "domain_destroy_hook",       (PyCFunction)pyxc_domain_destroy_hook,       METH_VARARGS, "\n"      "Add a hook for arch stuff before destroy a domain.\n"      " dom [int]:    Identifier of domain to be destroyed.\n\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "domain_resume",       (PyCFunction)pyxc_domain_resume,      METH_VARARGS, "\n"      "Resume execution of a suspended domain.\n"      " dom [int]: Identifier of domain to be resumed.\n"      " fast [int]: Use cooperative resume.\n\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "domain_shutdown",       (PyCFunction)pyxc_domain_shutdown,      METH_VARARGS, "\n"      "Shutdown a domain.\n"      " dom       [int, 0]:      Domain identifier to use.\n"      " reason     [int, 0]:      Reason for shutdown.\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "vcpu_setaffinity",       (PyCFunction)pyxc_vcpu_setaffinity,       METH_VARARGS | METH_KEYWORDS, "\n"      "Pin a VCPU to a specified set CPUs.\n"      " dom [int]:     Identifier of domain to which VCPU belongs.\n"      " vcpu [int, 0]: VCPU being pinned.\n"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -