The RPC generator doesn't support returning list of object yet, this patch
do the work manually.
* daemon/remote.c:
Implemente the server side handler remoteDispatchConnectListAllNWFilters.
* src/remote/remote_driver.c:
Add remote driver handler remoteConnectListAllNWFilters.
* src/remote/remote_protocol.x:
New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS and
structs to represent the args and ret for it.
* src/remote_protocol-structs: Likewise.
---
daemon/remote.c | 54 ++++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 63 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_protocol.x | 13 ++++++++-
src/remote_protocol-structs | 12 ++++++++
4 files changed, 141 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 17ddc2e..0cf3829 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4219,6 +4219,60 @@ cleanup:
return rv;
}
+static int
+remoteDispatchConnectListAllNWFilters(virNetServerPtr server ATTRIBUTE_UNUSED,
+ virNetServerClientPtr client,
+ virNetMessagePtr msg ATTRIBUTE_UNUSED,
+ virNetMessageErrorPtr rerr,
+ remote_connect_list_all_nwfilters_args *args,
+ remote_connect_list_all_nwfilters_ret *ret)
+{
+ virNWFilterPtr *filters = NULL;
+ int nfilters = 0;
+ int i;
+ int rv = -1;
+ struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
+
+ if (!priv->conn) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ goto cleanup;
+ }
+
+ if ((nfilters = virConnectListAllNWFilters(priv->conn,
+ args->need_results ? &filters :
NULL,
+ args->flags)) < 0)
+ goto cleanup;
+
+ if (filters && nfilters) {
+ if (VIR_ALLOC_N(ret->filters.filters_val, nfilters) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ ret->filters.filters_len = nfilters;
+
+ for (i = 0; i < nfilters; i++)
+ make_nonnull_nwfilter(ret->filters.filters_val + i, filters[i]);
+ } else {
+ ret->filters.filters_len = 0;
+ ret->filters.filters_val = NULL;
+ }
+
+ ret->ret = nfilters;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ virNetMessageSaveError(rerr);
+ if (filters) {
+ for (i = 0; i < nfilters; i++)
+ virNWFilterFree(filters[i]);
+ VIR_FREE(filters);
+ }
+ return rv;
+}
+
/*----- Helpers. -----*/
/* get_nonnull_domain and get_nonnull_network turn an on-wire
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index a0bdb32..cadd9b1 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2989,6 +2989,68 @@ done:
return rv;
}
+static int
+remoteConnectListAllNWFilters(virConnectPtr conn,
+ virNWFilterPtr **filters,
+ unsigned int flags)
+{
+ int rv = -1;
+ int i;
+ virNWFilterPtr *tmp_filters = NULL;
+ remote_connect_list_all_nwfilters_args args;
+ remote_connect_list_all_nwfilters_ret ret;
+
+ struct private_data *priv = conn->privateData;
+
+ remoteDriverLock(priv);
+
+ args.need_results = !!filters;
+ args.flags = flags;
+
+ memset(&ret, 0, sizeof(ret));
+ if (call(conn,
+ priv,
+ 0,
+ REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS,
+ (xdrproc_t) xdr_remote_connect_list_all_nwfilters_args,
+ (char *) &args,
+ (xdrproc_t) xdr_remote_connect_list_all_nwfilters_ret,
+ (char *) &ret) == -1)
+ goto done;
+
+ if (filters) {
+ if (VIR_ALLOC_N(tmp_filters, ret.filters.filters_len + 1) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ for (i = 0; i < ret.filters.filters_len; i++) {
+ tmp_filters[i] = get_nonnull_nwfilter (conn, ret.filters.filters_val[i]);
+ if (!tmp_filters[i]) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+ *filters = tmp_filters;
+ tmp_filters = NULL;
+ }
+
+ rv = ret.ret;
+
+cleanup:
+ if (tmp_filters) {
+ for (i = 0; i < ret.filters.filters_len; i++)
+ if (tmp_filters[i])
+ virNWFilterFree(tmp_filters[i]);
+ VIR_FREE(tmp_filters);
+ }
+
+ xdr_free((xdrproc_t) xdr_remote_connect_list_all_nwfilters_ret, (char *) &ret);
+
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
/*----------------------------------------------------------------------*/
@@ -5824,6 +5886,7 @@ static virNWFilterDriver nwfilter_driver = {
.undefine = remoteNWFilterUndefine, /* 0.8.0 */
.numOfNWFilters = remoteNumOfNWFilters, /* 0.8.0 */
.listNWFilters = remoteListNWFilters, /* 0.8.0 */
+ .listAllNWFilters = remoteConnectListAllNWFilters, /* 0.10.0 */
};
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 4a7116c..990e272 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2578,6 +2578,16 @@ struct remote_connect_list_all_node_devices_ret {
unsigned int ret;
};
+struct remote_connect_list_all_nwfilters_args {
+ int need_results;
+ unsigned int flags;
+};
+
+struct remote_connect_list_all_nwfilters_ret {
+ remote_nonnull_nwfilter filters<>;
+ unsigned int ret;
+};
+
/*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */
@@ -2910,7 +2920,8 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 280, /* skipgen skipgen priority:high */
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 281, /* skipgen skipgen priority:high */
- REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 282 /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 282, /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 283 /* skipgen skipgen priority:high */
/*
* Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index aae8652..34cc5ba 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2037,6 +2037,17 @@ struct remote_connect_list_all_node_devices_ret {
} devices;
u_int ret;
};
+struct remote_connect_list_all_nwfilters_args {
+ int need_results;
+ u_int flags;
+};
+struct remote_connect_list_all_nwfilters_ret {
+ struct {
+ u_int filters_len;
+ remote_nonnull_nwfilter * filters_val;
+ } filters;
+ u_int ret;
+};
enum remote_procedure {
REMOTE_PROC_OPEN = 1,
REMOTE_PROC_CLOSE = 2,
@@ -2320,4 +2331,5 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 280,
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 281,
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 282,
+ REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 283,
};
--
1.7.7.3