From 9c9de4e64d2cf1649ee498e3af2101d6e50cac77 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Sun, 20 May 2012 16:26:36 +0200 Subject: remote: implement remote protocol for virConnectListAllDomains() This patch wires up the RPC protocol handlers for virConnectListAllDomains(). The RPC generator has no support for the way how virConnectListAllDomains() returns the results so the handler code had to be done manually. The new api is handled by REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS, with number 273 and marked with high priority. --- daemon/remote.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'daemon') diff --git a/daemon/remote.c b/daemon/remote.c index a02c09b29..ac0f06824 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -995,6 +995,60 @@ no_memory: goto cleanup; } +static int +remoteDispatchConnectListAllDomains(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_connect_list_all_domains_args *args, + remote_connect_list_all_domains_ret *ret) +{ + virDomainPtr *doms = NULL; + int ndomains = 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 ((ndomains = virConnectListAllDomains(priv->conn, + args->need_results ? &doms : NULL, + args->flags)) < 0) + goto cleanup; + + if (doms && ndomains) { + if (VIR_ALLOC_N(ret->domains.domains_val, ndomains) < 0) { + virReportOOMError(); + goto cleanup; + } + + ret->domains.domains_len = ndomains; + + for (i = 0; i < ndomains; i++) + make_nonnull_domain(ret->domains.domains_val + i, doms[i]); + } else { + ret->domains.domains_len = 0; + ret->domains.domains_val = NULL; + } + + ret->ret = ndomains; + + rv = 0; + +cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + if (doms) { + for (i = 0; i < ndomains; i++) + virDomainFree(doms[i]); + VIR_FREE(doms); + } + return rv; +} + static int remoteDispatchDomainGetSchedulerParametersFlags(virNetServerPtr server ATTRIBUTE_UNUSED, virNetServerClientPtr client ATTRIBUTE_UNUSED, -- cgit v1.2.3-65-gdbad