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

📄 xc.c

📁 xen虚拟机源代码安装包
💻 C
📖 第 1 页 / 共 5 页
字号:
                                         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_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;}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"      " cpumap [list, []]: list of usable CPUs.\n\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "domain_sethandle",       (PyCFunction)pyxc_domain_sethandle,      METH_VARARGS, "\n"      "Set domain's opaque handle.\n"      " dom [int]:            Identifier of domain.\n"      " handle [list of 16 ints]: New opaque handle.\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "domain_getinfo",       (PyCFunction)pyxc_domain_getinfo,       METH_VARARGS | METH_KEYWORDS, "\n"      "Get information regarding a set of domains, in increasing id order.\n"      " first_dom [int, 0]:    First domain to retrieve info about.\n"      " max_doms  [int, 1024]: Maximum number of domains to retrieve info"      " about.\n\n"      "Returns: [list of dicts] if list length is less than 'max_doms'\n"      "         parameter then there was an error, or the end of the\n"      "         domain-id space was reached.\n"      " dom      [int]: Identifier of domain to which this info pertains\n"      " cpu      [int]:  CPU to which this domain is bound\n"      " vcpus    [int]:  Number of Virtual CPUS in this domain\n"      " dying    [int]:  Bool - is the domain dying?\n"      " crashed  [int]:  Bool - has the domain crashed?\n"      " shutdown [int]:  Bool - has the domain shut itself down?\n"      " paused   [int]:  Bool - is the domain paused by control software?\n"      " blocked  [int]:  Bool - is the domain blocked waiting for an event?\n"      " running  [int]:  Bool - is the domain currently running?\n"      " mem_kb   [int]:  Memory reservation, in kilobytes\n"      " maxmem_kb [int]: Maximum memory limit, in kilobytes\n"      " cpu_time [long]: CPU time consumed, in nanoseconds\n"      " shutdown_reason [int]: Numeric code from guest OS, explaining "      "reason why it shut itself down.\n" },    { "vcpu_getinfo",       (PyCFunction)pyxc_vcpu_getinfo,       METH_VARARGS | METH_KEYWORDS, "\n"      "Get information regarding a VCPU.\n"      " dom  [int]:    Domain to retrieve info about.\n"      " vcpu [int, 0]: VCPU to retrieve info about.\n\n"      "Returns: [dict]\n"      " online   [int]:  Bool - Is this VCPU currently online?\n"      " blocked  [int]:  Bool - Is this VCPU blocked waiting for an event?\n"      " running  [int]:  Bool - Is this VCPU currently running on a CPU?\n"      " cpu_time [long]: CPU time consumed, in nanoseconds\n"      " cpumap   [int]:  Bitmap of CPUs this VCPU can run on\n"      " cpu      [int]:  CPU that this VCPU is currently bound to\n" },    { "linux_build",       (PyCFunction)pyxc_linux_build,       METH_VARARGS | METH_KEYWORDS, "\n"      "Build a new Linux guest OS.\n"      " dom     [int]:      Identifier of domain to build into.\n"      " image   [str]:      Name of kernel image file. May be gzipped.\n"      " ramdisk [str, n/a]: Name of ramdisk file, if any.\n"      " cmdline [str, n/a]: Kernel parameters, if any.\n\n"      " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "hvm_build",       (PyCFunction)pyxc_hvm_build,       METH_VARARGS | METH_KEYWORDS, "\n"      "Build a new HVM guest OS.\n"      " dom     [int]:      Identifier of domain to build into.\n"      " image   [str]:      Name of HVM loader image file.\n"      " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"      "Returns: [int] 0 on success; -1 on error.\n" },    { "hvm_get_param",       (PyCFunction)pyxc_get_hvm_param,       METH_VARARGS | METH_KEYWORDS, "\n"      "get a parameter of HVM guest OS.\n"      " dom     [int]:      Identifier of domain to build into.\n"      " param   [int]:      No. of HVM param.\n"      "Returns: [long] value of the param.\n" },    { "hvm_set_param",       (PyCFunction)pyxc_set_hvm_param,       METH_VARARGS | METH_KEYWORDS, "\n"      "set a parameter of HVM guest OS.\n"

⌨️ 快捷键说明

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