Simply returns the object list. No filtering. src/nwfilter/nwfilter_driver.c: Implement listAllNWFilters --- src/nwfilter/nwfilter_driver.c | 56 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 4fa73f8..9b0cf2c 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -338,6 +338,61 @@ nwfilterListNWFilters(virConnectPtr conn, } +static int +nwfilterListAllNWFilters(virConnectPtr conn, + virNWFilterPtr **filters, + unsigned int flags) { + virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData; + virNWFilterPtr *tmp_filters = NULL; + int nfilters = 0; + virNWFilterPtr filter = NULL; + virNWFilterObjPtr obj = NULL; + int i; + int ret = -1; + + virCheckFlags(0, -1); + + nwfilterDriverLock(driver); + + if (!filters) { + ret = driver->nwfilters.count; + goto cleanup; + } + + if (VIR_ALLOC_N(tmp_filters, driver->nwfilters.count + 1) < 0) { + virReportOOMError(); + goto cleanup; + } + + for (i = 0 ; i < driver->nwfilters.count; i++) { + obj = driver->nwfilters.objs[i]; + virNWFilterObjLock(obj); + if (!(filter = virGetNWFilter(conn, obj->def->name, + obj->def->uuid))) { + virNWFilterObjUnlock(obj); + goto cleanup; + } + virNWFilterObjUnlock(obj); + tmp_filters[nfilters++] = filter; + } + + *filters = tmp_filters; + tmp_filters = NULL; + ret = nfilters; + + cleanup: + nwfilterDriverUnlock(driver); + if (tmp_filters) { + for (i = 0; i < nfilters; i ++) { + if (tmp_filters[i]) + virNWFilterFree(tmp_filters[i]); + } + } + VIR_FREE(tmp_filters); + + return ret; +} + static virNWFilterPtr nwfilterDefine(virConnectPtr conn, const char *xml) @@ -473,6 +528,7 @@ static virNWFilterDriver nwfilterDriver = { .close = nwfilterClose, /* 0.8.0 */ .numOfNWFilters = nwfilterNumNWFilters, /* 0.8.0 */ .listNWFilters = nwfilterListNWFilters, /* 0.8.0 */ + .listAllNWFilters = nwfilterListAllNWFilters, /* 0.10.0 */ .nwfilterLookupByName = nwfilterLookupByName, /* 0.8.0 */ .nwfilterLookupByUUID = nwfilterLookupByUUID, /* 0.8.0 */ .defineXML = nwfilterDefine, /* 0.8.0 */ -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list