diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml index 5f51fc7260..ab6f407126 100644 --- a/python/libvirt-override-api.xml +++ b/python/libvirt-override-api.xml @@ -416,6 +416,12 @@ + + returns list of all interfaces + + + + Computes the most feature-rich CPU which is compatible with all given host CPUs. diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py index 85db5fee90..ffa1a3cbd0 100644 --- a/python/libvirt-override-virConnect.py +++ b/python/libvirt-override-virConnect.py @@ -230,3 +230,15 @@ retlist.append(virNetwork(self, _obj=netptr)) return retlist + + def listAllInterfaces(self, flags): + """Returns a list of interface objects""" + ret = libvirtmod.virConnectListAllInterfaces(self._o, flags) + if ret is None: + raise libvirtError("virConnectListAllInterfaces() failed", conn=self) + + retlist = list() + for ifaceptr in ret: + retlist.append(virInterface(self, _obj=ifaceptr)) + + return retlist diff --git a/python/libvirt-override.c b/python/libvirt-override.c index 485ed28882..d07e7cb452 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -3827,6 +3827,53 @@ libvirt_virConnectListDefinedInterfaces(PyObject *self ATTRIBUTE_UNUSED, } +static PyObject * +libvirt_virConnectListAllInterfaces(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + PyObject *pyobj_conn; + PyObject *py_retval = NULL; + PyObject *tmp = NULL; + virConnectPtr conn; + virInterfacePtr *ifaces = NULL; + int c_retval = 0; + int i; + unsigned int flags; + + if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllInterfaces", + &pyobj_conn, &flags)) + return NULL; + conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn); + + LIBVIRT_BEGIN_ALLOW_THREADS; + c_retval = virConnectListAllInterfaces(conn, &ifaces, flags); + LIBVIRT_END_ALLOW_THREADS; + if (c_retval < 0) + return VIR_PY_NONE; + + if (!(py_retval = PyList_New(c_retval))) + goto cleanup; + + for (i = 0; i < c_retval; i++) { + if (!(tmp = libvirt_virInterfacePtrWrap(ifaces[i])) || + PyList_SetItem(py_retval, i, tmp) < 0) { + Py_XDECREF(tmp); + Py_DECREF(py_retval); + py_retval = NULL; + goto cleanup; + } + /* python steals the pointer */ + ifaces[i] = NULL; + } + +cleanup: + for (i = 0; i < c_retval; i++) + if (ifaces[i]) + virInterfaceFree(ifaces[i]); + VIR_FREE(ifaces); + return py_retval; +} + static PyObject * libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { @@ -6053,6 +6100,7 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virConnectListNWFilters", libvirt_virConnectListNWFilters, METH_VARARGS, NULL}, {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces, METH_VARARGS, NULL}, {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces, METH_VARARGS, NULL}, + {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces, METH_VARARGS, NULL}, {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU, METH_VARARGS, NULL}, {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo, METH_VARARGS, NULL}, {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames, METH_VARARGS, NULL},