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 5a16dbe..9de0629 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4226,6 +4226,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) {
+ virNetError(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 22aad2f..ee6caf4 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2968,6 +2968,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;
+}
/*----------------------------------------------------------------------*/
@@ -5801,6 +5863,7 @@ static virNWFilterDriver nwfilter_driver = {
.undefine = remoteNWFilterUndefine, /* 0.8.0 */
.numOfNWFilters = remoteNumOfNWFilters, /* 0.8.0 */
.listNWFilters = remoteListNWFilters, /* 0.8.0 */
+ .listAllNWFilters = remoteConnectListAllNWFilters, /* 0.9.14 */
};
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index d25e22c..4b8b8b1 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1345,6 +1345,16 @@ struct remote_list_nwfilters_ret {
remote_nonnull_string names<REMOTE_NWFILTER_NAME_LIST_MAX>; /* insert@1 */
};
+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;
+};
+
struct remote_nwfilter_lookup_by_uuid_args {
remote_uuid uuid;
};
@@ -2898,7 +2908,8 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 279, /* skipgen skipgen priority:high */
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 280, /* skipgen skipgen priority:high */
- REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 281 /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 281, /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 282 /* 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 545186d..56004ab 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -984,6 +984,17 @@ struct remote_list_nwfilters_ret {
remote_nonnull_string * names_val;
} names;
};
+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;
+};
struct remote_nwfilter_lookup_by_uuid_args {
remote_uuid uuid;
};
@@ -2312,4 +2323,5 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 279,
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 280,
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 281,
+ REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 282,
};
--
1.7.7.3