The RPC generator doesn't support returning list of object, this patch
do the work manually.
* daemon/remote.c:
Implemente the server side handler remoteDispatchConnectListAllNetworks.
* src/remote/remote_driver.c:
Add remote driver handler remoteConnectListAllNetworks.
* src/remote/remote_protocol.x:
New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS and
structs to represent the args and ret for it.
* src/remote_protocol-structs: Likewise.
---
daemon/remote.c | 55 ++++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 64 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_protocol.x | 13 ++++++++-
src/remote_protocol-structs | 12 ++++++++
4 files changed, 143 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index c1e30c0..d5c4b90 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4064,6 +4064,61 @@ cleanup:
return rv;
}
+static int
+remoteDispatchConnectListAllNetworks(virNetServerPtr server ATTRIBUTE_UNUSED,
+ virNetServerClientPtr client,
+ virNetMessagePtr msg ATTRIBUTE_UNUSED,
+ virNetMessageErrorPtr rerr,
+ remote_connect_list_all_networks_args *args,
+ remote_connect_list_all_networks_ret *ret)
+{
+ virNetworkPtr *nets = NULL;
+ int nnets = 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 ((nnets = virConnectListAllNetworks(priv->conn,
+ args->need_results ? &nets : NULL,
+ args->flags)) < 0)
+ goto cleanup;
+
+ if (nets && nnets) {
+ if (VIR_ALLOC_N(ret->nets.nets_val, nnets) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ ret->nets.nets_len = nnets;
+
+ for (i = 0; i < nnets; i++)
+ make_nonnull_network(ret->nets.nets_val + i, nets[i]);
+ } else {
+ ret->nets.nets_len = 0;
+ ret->nets.nets_val = NULL;
+ }
+
+ ret->ret = nnets;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ virNetMessageSaveError(rerr);
+ if (nets) {
+ for (i = 0; i < nnets; i++)
+ virNetworkFree(nets[i]);
+ VIR_FREE(nets);
+ }
+ 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 179e7af..afe6e60 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2779,6 +2779,69 @@ done:
return rv;
}
+static int
+remoteConnectListAllNetworks(virConnectPtr conn,
+ virNetworkPtr **nets,
+ unsigned int flags)
+{
+ int rv = -1;
+ int i;
+ virNetworkPtr *tmp_nets = NULL;
+ remote_connect_list_all_networks_args args;
+ remote_connect_list_all_networks_ret ret;
+
+ struct private_data *priv = conn->privateData;
+
+ remoteDriverLock(priv);
+
+ args.need_results = !!nets;
+ args.flags = flags;
+
+ memset(&ret, 0, sizeof(ret));
+ if (call(conn,
+ priv,
+ 0,
+ REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS,
+ (xdrproc_t) xdr_remote_connect_list_all_networks_args,
+ (char *) &args,
+ (xdrproc_t) xdr_remote_connect_list_all_networks_ret,
+ (char *) &ret) == -1)
+ goto done;
+
+ if (nets) {
+ if (VIR_ALLOC_N(tmp_nets, ret.nets.nets_len + 1) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ for (i = 0; i < ret.nets.nets_len; i++) {
+ tmp_nets[i] = get_nonnull_network (conn, ret.nets.nets_val[i]);
+ if (!tmp_nets[i]) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+ *nets = tmp_nets;
+ tmp_nets = NULL;
+ }
+
+ rv = ret.ret;
+
+cleanup:
+ if (tmp_nets) {
+ for (i = 0; i < ret.nets.nets_len; i++)
+ if (tmp_nets[i])
+ virNetworkFree(tmp_nets[i]);
+ VIR_FREE(tmp_nets);
+ }
+
+ xdr_free((xdrproc_t) xdr_remote_connect_list_all_networks_ret, (char *) &ret);
+
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
/*----------------------------------------------------------------------*/
@@ -5485,6 +5548,7 @@ static virNetworkDriver network_driver = {
.listNetworks = remoteListNetworks, /* 0.3.0 */
.numOfDefinedNetworks = remoteNumOfDefinedNetworks, /* 0.3.0 */
.listDefinedNetworks = remoteListDefinedNetworks, /* 0.3.0 */
+ .listAllNetworks = remoteConnectListAllNetworks, /* 0.9.14 */
.networkLookupByUUID = remoteNetworkLookupByUUID, /* 0.3.0 */
.networkLookupByName = remoteNetworkLookupByName, /* 0.3.0 */
.networkCreateXML = remoteNetworkCreateXML, /* 0.3.0 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index d090705..897775c 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1247,6 +1247,16 @@ struct remote_list_defined_networks_ret {
remote_nonnull_string names<REMOTE_NETWORK_NAME_LIST_MAX>; /* insert@1 */
};
+struct remote_connect_list_all_networks_args {
+ int need_results;
+ unsigned int flags;
+};
+
+struct remote_connect_list_all_networks_ret {
+ remote_nonnull_network nets<>;
+ unsigned int ret;
+};
+
struct remote_network_lookup_by_uuid_args {
remote_uuid uuid;
};
@@ -2864,7 +2874,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275, /* skipgen skipgen priority:high
*/
REMOTE_PROC_DOMAIN_EVENT_BALLOON_CHANGE = 276, /* autogen autogen */
REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 277, /* skipgen skipgen priority:high
*/
- REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 278 /* skipgen skipgen priority:high */
+ REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 278, /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 279 /* 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 9d81ad0..315ec7f 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -632,6 +632,17 @@ struct remote_list_defined_domains_ret {
remote_nonnull_string * names_val;
} names;
};
+struct remote_list_all_networks_args {
+ int need_results;
+ u_int flags;
+};
+struct remote_list_all_networks_ret {
+ struct {
+ u_int nets_len;
+ remote_nonnull_network * nets_val;
+ } nets;
+ u_int ret;
+};
struct remote_num_of_defined_domains_ret {
int num;
};
@@ -2276,4 +2287,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_BALLOON_CHANGE = 276,
REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 277,
REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 278,
+ REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 279,
};
--
1.7.7.3