Mostly for historical reasons Xen includes Python bindings for libxc. They have been used by xm/xend in the past but nowadays there is no user of any device related python binding left. Remove them.
Signed-off-by: Juergen Gross <jgr...@suse.com> --- tools/python/xen/lowlevel/xc/xc.c | 226 -------------------------------------- 1 file changed, 226 deletions(-) diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 7809fc6..e0f1d7f 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -466,197 +466,6 @@ static PyObject *pyxc_hvm_param_set(XcObject *self, return zero; } -static int token_value(char *token) -{ - token = strchr(token, 'x') + 1; - return strtol(token, NULL, 16); -} - -static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func) -{ - char *token; - - if ( !(*str) || !strchr(*str, ',') ) - return 0; - - token = *str; - *seg = token_value(token); - token = strchr(token, ',') + 1; - *bus = token_value(token); - token = strchr(token, ',') + 1; - *dev = token_value(token); - token = strchr(token, ',') + 1; - *func = token_value(token); - token = strchr(token, ','); - *str = token ? token + 1 : NULL; - - return 1; -} - -static PyObject *pyxc_test_assign_device(XcObject *self, - PyObject *args, - PyObject *kwds) -{ - uint32_t dom; - char *pci_str; - int32_t sbdf = 0; - int seg, bus, dev, func; - - static char *kwd_list[] = { "domid", "pci", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list, - &dom, &pci_str) ) - return NULL; - - while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) ) - { - sbdf = seg << 16; - sbdf |= (bus & 0xff) << 8; - sbdf |= (dev & 0x1f) << 3; - sbdf |= (func & 0x7); - - if ( xc_test_assign_device(self->xc_handle, dom, sbdf) != 0 ) - { - if (errno == ENOSYS) - sbdf = -1; - break; - } - sbdf = 0; - } - - return Py_BuildValue("i", sbdf); -} - -static PyObject *pyxc_assign_device(XcObject *self, - PyObject *args, - PyObject *kwds) -{ - uint32_t dom; - char *pci_str; - int32_t sbdf = 0; - int seg, bus, dev, func; - - static char *kwd_list[] = { "domid", "pci", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list, - &dom, &pci_str) ) - return NULL; - - while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) ) - { - sbdf = seg << 16; - sbdf |= (bus & 0xff) << 8; - sbdf |= (dev & 0x1f) << 3; - sbdf |= (func & 0x7); - - if ( xc_assign_device(self->xc_handle, dom, sbdf, 0) != 0 ) - { - if (errno == ENOSYS) - sbdf = -1; - break; - } - sbdf = 0; - } - - return Py_BuildValue("i", sbdf); -} - -static PyObject *pyxc_deassign_device(XcObject *self, - PyObject *args, - PyObject *kwds) -{ - uint32_t dom; - char *pci_str; - int32_t sbdf = 0; - int seg, bus, dev, func; - - static char *kwd_list[] = { "domid", "pci", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list, - &dom, &pci_str) ) - return NULL; - - while ( next_bdf(&pci_str, &seg, &bus, &dev, &func) ) - { - sbdf = seg << 16; - sbdf |= (bus & 0xff) << 8; - sbdf |= (dev & 0x1f) << 3; - sbdf |= (func & 0x7); - - if ( xc_deassign_device(self->xc_handle, dom, sbdf) != 0 ) - { - if (errno == ENOSYS) - sbdf = -1; - break; - } - sbdf = 0; - } - - return Py_BuildValue("i", sbdf); -} - -static PyObject *pyxc_get_device_group(XcObject *self, - PyObject *args) -{ - uint32_t sbdf; - uint32_t max_sdevs, num_sdevs; - int domid, seg, bus, dev, func, rc, i; - PyObject *Pystr; - char *group_str; - char dev_str[9]; - uint32_t *sdev_array; - - if ( !PyArg_ParseTuple(args, "iiiii", &domid, &seg, &bus, &dev, &func) ) - return NULL; - - /* Maximum allowed siblings device number per group */ - max_sdevs = 1024; - - sdev_array = calloc(max_sdevs, sizeof(*sdev_array)); - if (sdev_array == NULL) - return PyErr_NoMemory(); - - sbdf = seg << 16; - sbdf |= (bus & 0xff) << 8; - sbdf |= (dev & 0x1f) << 3; - sbdf |= (func & 0x7); - - rc = xc_get_device_group(self->xc_handle, - domid, sbdf, max_sdevs, &num_sdevs, sdev_array); - - if ( rc < 0 ) - { - free(sdev_array); - return pyxc_error_to_exception(self->xc_handle); - } - - if ( !num_sdevs ) - { - free(sdev_array); - return Py_BuildValue("s", ""); - } - - group_str = calloc(num_sdevs, sizeof(dev_str)); - if (group_str == NULL) - { - free(sdev_array); - return PyErr_NoMemory(); - } - - for ( i = 0; i < num_sdevs; i++ ) - { - bus = (sdev_array[i] >> 16) & 0xff; - dev = (sdev_array[i] >> 11) & 0x1f; - func = (sdev_array[i] >> 8) & 0x7; - snprintf(dev_str, sizeof(dev_str), "%02x:%02x.%x,", bus, dev, func); - strcat(group_str, dev_str); - } - - Pystr = Py_BuildValue("s", group_str); - - free(sdev_array); - free(group_str); - - return Pystr; -} - #if defined(__i386__) || defined(__x86_64__) static PyObject *pyxc_dom_set_machine_address_size(XcObject *self, PyObject *args, @@ -1736,41 +1545,6 @@ static PyMethodDef pyxc_methods[] = { " value [long]: Value of param.\n" "Returns: [int] 0 on success.\n" }, - { "get_device_group", - (PyCFunction)pyxc_get_device_group, - METH_VARARGS, "\n" - "get sibling devices infomation.\n" - " dom [int]: Domain to assign device to.\n" - " seg [int]: PCI segment.\n" - " bus [int]: PCI bus.\n" - " dev [int]: PCI dev.\n" - " func [int]: PCI func.\n" - "Returns: [string]: Sibling devices \n" }, - - { "test_assign_device", - (PyCFunction)pyxc_test_assign_device, - METH_VARARGS | METH_KEYWORDS, "\n" - "test device assignment with VT-d.\n" - " dom [int]: Identifier of domain to build into.\n" - " pci_str [str]: PCI devices.\n" - "Returns: [int] 0 on success, or device bdf that can't be assigned.\n" }, - - { "assign_device", - (PyCFunction)pyxc_assign_device, - METH_VARARGS | METH_KEYWORDS, "\n" - "Assign device to IOMMU domain.\n" - " dom [int]: Domain to assign device to.\n" - " pci_str [str]: PCI devices.\n" - "Returns: [int] 0 on success, or device bdf that can't be assigned.\n" }, - - { "deassign_device", - (PyCFunction)pyxc_deassign_device, - METH_VARARGS | METH_KEYWORDS, "\n" - "Deassign device from IOMMU domain.\n" - " dom [int]: Domain to deassign device from.\n" - " pci_str [str]: PCI devices.\n" - "Returns: [int] 0 on success, or device bdf that can't be deassigned.\n" }, - { "sched_id_get", (PyCFunction)pyxc_sched_id_get, METH_NOARGS, "\n" -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel