This is to list the network fitler objects. No flags are supported include/libvirt/libvirt.h.in: Declare enum virConnectListAllNWFilterFlags and virConnectListAllNWFilters. python/generator.py: Skip auto-generating src/driver.h: (virDrvConnectListAllNWFilters) src/libvirt.c: Implement the public API src/libvirt_public.syms: Export the symbol to public --- include/libvirt/libvirt.h.in | 4 ++- python/generator.py | 1 + src/driver.h | 5 ++++ src/libvirt.c | 50 ++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 5 files changed, 60 insertions(+), 1 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index fcade4d..2b542b8 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -4085,7 +4085,9 @@ int virConnectNumOfNWFilters (virConnectPtr conn); int virConnectListNWFilters (virConnectPtr conn, char **const names, int maxnames); - +int virConnectListAllNWFilters(virConnectPtr conn, + virNWFilterPtr **filters, + unsigned int flags); /* * Lookup nwfilter by name or uuid */ diff --git a/python/generator.py b/python/generator.py index f63730b..af657af 100755 --- a/python/generator.py +++ b/python/generator.py @@ -463,6 +463,7 @@ skip_function = ( 'virConnectListAllNetworks', # overridden in virConnect.py 'virConnectListAllInterfaces', # overridden in virConnect.py 'virConnectListAllNodeDevices', # overridden in virConnect.py + 'virConnectListAllNWFilters', # overridden in virConnect.py 'virStreamRecvAll', # Pure python libvirt-override-virStream.py 'virStreamSendAll', # Pure python libvirt-override-virStream.py diff --git a/src/driver.h b/src/driver.h index 3cfd499..933d994 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1618,6 +1618,10 @@ typedef int (*virDrvConnectListNWFilters) (virConnectPtr conn, char **const names, int maxnames); +typedef int + (*virDrvConnectListAllNWFilters) (virConnectPtr conn, + virNWFilterPtr **filters, + unsigned int flags); typedef virNWFilterPtr (*virDrvNWFilterLookupByName) (virConnectPtr conn, const char *name); @@ -1655,6 +1659,7 @@ struct _virNWFilterDriver { virDrvConnectNumOfNWFilters numOfNWFilters; virDrvConnectListNWFilters listNWFilters; + virDrvConnectListAllNWFilters listAllNWFilters; virDrvNWFilterLookupByName nwfilterLookupByName; virDrvNWFilterLookupByUUID nwfilterLookupByUUID; virDrvNWFilterDefineXML defineXML; diff --git a/src/libvirt.c b/src/libvirt.c index 9fa76f3..2f90202 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -15955,6 +15955,56 @@ error: return -1; } +/** + * virConnectListAllNWFilters: + * @conn: Pointer to the hypervisor connection. + * @filters: Pointer to a variable to store the array containing the network + * filter objects or NULL if the list is not required (just returns + * number of network filters). + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Collect the list of network filters, and allocate an array to store those + * objects. + * + * Returns the number of network filters found or -1 and sets @filters to NULL + * in case of error. On success, the array stored into @filters is guaranteed to + * have an extra allocated element set to NULL but not included in the return count, + * to make iteration easier. The caller is responsible for calling + * virNWFilterFree() on each array element, then calling free() on @filters. + */ +int +virConnectListAllNWFilters(virConnectPtr conn, + virNWFilterPtr **filters, + unsigned int flags) +{ + VIR_DEBUG("conn=%p, filters=%p, flags=%x", conn, filters, flags); + + virResetLastError(); + + if (filters) + *filters = NULL; + + if (!VIR_IS_CONNECT(conn)) { + virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); + virDispatchError(NULL); + return -1; + } + + if (conn->nwfilterDriver && + conn->nwfilterDriver->listAllNWFilters) { + int ret; + ret = conn->nwfilterDriver->listAllNWFilters(conn, filters, flags); + if (ret < 0) + goto error; + return ret; + } + + virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + virDispatchError(conn); + return -1; +} /** * virConnectListNWFilters: diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 05b32ee..4ef311f 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -554,6 +554,7 @@ LIBVIRT_0.10.0 { virConnectListAllNetworks; virConnectListAllInterfaces; virConnectListAllNodeDevices; + virConnectListAllNWFilters; } LIBVIRT_0.9.13; # .... define new API here using predicted next version number .... -- 1.7.7.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list