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 remoteDispatchConnectListAllInterfaces.
* src/remote/remote_driver.c:
Add remote driver handler remoteConnectListAllInterfaces.
* src/remote/remote_protocol.x:
New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES and
structs to represent the args and ret for it.
* src/remote_protocol-structs: Likewise.
---
daemon/remote.c | 54 +++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 64 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_protocol.x | 13 ++++++++-
src/remote_protocol-structs | 12 ++++++++
4 files changed, 142 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index d5c4b90..aec7b3c 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4118,6 +4118,60 @@ cleanup:
return rv;
}
+static int
+remoteDispatchConnectListAllInterfaces(virNetServerPtr server ATTRIBUTE_UNUSED,
+ virNetServerClientPtr client,
+ virNetMessagePtr msg ATTRIBUTE_UNUSED,
+ virNetMessageErrorPtr rerr,
+ remote_connect_list_all_interfaces_args *args,
+ remote_connect_list_all_interfaces_ret *ret)
+{
+ virInterfacePtr *ifaces = NULL;
+ int nifaces = 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 ((nifaces = virConnectListAllInterfaces(priv->conn,
+ args->need_results ? &ifaces :
NULL,
+ args->flags)) < 0)
+ goto cleanup;
+
+ if (ifaces && nifaces) {
+ if (VIR_ALLOC_N(ret->ifaces.ifaces_val, nifaces) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ ret->ifaces.ifaces_len = nifaces;
+
+ for (i = 0; i < nifaces; i++)
+ make_nonnull_interface(ret->ifaces.ifaces_val + i, ifaces[i]);
+ } else {
+ ret->ifaces.ifaces_len = 0;
+ ret->ifaces.ifaces_val = NULL;
+ }
+
+ ret->ret = nifaces;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ virNetMessageSaveError(rerr);
+ if (ifaces) {
+ for (i = 0; i < nifaces; i++)
+ virInterfaceFree(ifaces[i]);
+ VIR_FREE(ifaces);
+ }
+ return rv;
+}
+
/*----- Helpers. -----*/
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index afe6e60..2b7c05e 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2842,6 +2842,69 @@ done:
return rv;
}
+static int
+remoteConnectListAllInterfaces(virConnectPtr conn,
+ virInterfacePtr **ifaces,
+ unsigned int flags)
+{
+ int rv = -1;
+ int i;
+ virInterfacePtr *tmp_ifaces = NULL;
+ remote_connect_list_all_interfaces_args args;
+ remote_connect_list_all_interfaces_ret ret;
+
+ struct private_data *priv = conn->privateData;
+
+ remoteDriverLock(priv);
+
+ args.need_results = !!ifaces;
+ args.flags = flags;
+
+ memset(&ret, 0, sizeof(ret));
+ if (call(conn,
+ priv,
+ 0,
+ REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES,
+ (xdrproc_t) xdr_remote_connect_list_all_interfaces_args,
+ (char *) &args,
+ (xdrproc_t) xdr_remote_connect_list_all_interfaces_ret,
+ (char *) &ret) == -1)
+ goto done;
+
+ if (ifaces) {
+ if (VIR_ALLOC_N(tmp_ifaces, ret.ifaces.ifaces_len + 1) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ for (i = 0; i < ret.ifaces.ifaces_len; i++) {
+ tmp_ifaces[i] = get_nonnull_interface (conn, ret.ifaces.ifaces_val[i]);
+ if (!tmp_ifaces[i]) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+ *ifaces = tmp_ifaces;
+ tmp_ifaces = NULL;
+ }
+
+ rv = ret.ret;
+
+cleanup:
+ if (tmp_ifaces) {
+ for (i = 0; i < ret.ifaces.ifaces_len; i++)
+ if (tmp_ifaces[i])
+ virInterfaceFree(tmp_ifaces[i]);
+ VIR_FREE(tmp_ifaces);
+ }
+
+ xdr_free((xdrproc_t) xdr_remote_connect_list_all_interfaces_ret, (char *) &ret);
+
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
/*----------------------------------------------------------------------*/
@@ -5572,6 +5635,7 @@ static virInterfaceDriver interface_driver = {
.listInterfaces = remoteListInterfaces, /* 0.7.2 */
.numOfDefinedInterfaces = remoteNumOfDefinedInterfaces, /* 0.7.2 */
.listDefinedInterfaces = remoteListDefinedInterfaces, /* 0.7.2 */
+ .listAllInterfaces = remoteConnectListAllInterfaces, /* 0.9.14 */
.interfaceLookupByName = remoteInterfaceLookupByName, /* 0.7.2 */
.interfaceLookupByMACString = remoteInterfaceLookupByMACString, /* 0.7.2 */
.interfaceGetXMLDesc = remoteInterfaceGetXMLDesc, /* 0.7.2 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 897775c..e4f0d62 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1409,6 +1409,16 @@ struct remote_list_defined_interfaces_ret {
remote_nonnull_string names<REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX>; /*
insert@1 */
};
+struct remote_connect_list_all_interfaces_args {
+ int need_results;
+ unsigned int flags;
+};
+
+struct remote_connect_list_all_interfaces_ret {
+ remote_nonnull_interface ifaces<>;
+ unsigned int ret;
+};
+
struct remote_interface_lookup_by_name_args {
remote_nonnull_string name;
};
@@ -2875,7 +2885,8 @@ enum remote_procedure {
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_CONNECT_LIST_ALL_NETWORKS = 279 /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 279, /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 280 /* 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 315ec7f..2640fd1 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1036,6 +1036,17 @@ struct remote_list_defined_interfaces_ret {
remote_nonnull_string * names_val;
} names;
};
+struct remote_connect_list_all_interfaces_args {
+ int need_results;
+ u_int flags;
+};
+struct remote_connect_list_all_interfaces_ret {
+ struct {
+ u_int ifaces_len;
+ remote_nonnull_interface * ifaces_val;
+ } pools;
+ u_int ret;
+};
struct remote_interface_lookup_by_name_args {
remote_nonnull_string name;
};
@@ -2288,4 +2299,5 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 277,
REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 278,
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 279,
+ REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 280,
};
--
1.7.7.3