diff options
author | Osier Yang <jyang@redhat.com> | 2012-09-05 00:10:16 +0800 |
---|---|---|
committer | Osier Yang <jyang@redhat.com> | 2012-09-12 15:36:56 +0800 |
commit | 65741d84edeb36f6337cc4f246923f9b7a6ed6c1 (patch) | |
tree | 3b189de37a003d72badf5b309ce34fafc91251d9 /daemon | |
parent | list: Define new API virConnectListAllInterfaces (diff) | |
download | libvirt-65741d84edeb36f6337cc4f246923f9b7a6ed6c1.tar.gz libvirt-65741d84edeb36f6337cc4f246923f9b7a6ed6c1.tar.bz2 libvirt-65741d84edeb36f6337cc4f246923f9b7a6ed6c1.zip |
list: Implemente RPC calls for virConnectListAllInterfaces
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.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/remote.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/daemon/remote.c b/daemon/remote.c index 552b57219..12cd25cbb 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -4267,6 +4267,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) { + virReportError(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. -----*/ |