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 271 and marked with high priority.
---
daemon/remote.c | 50 +++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 66 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_protocol.x | 14 ++++++++-
src/remote_protocol-structs | 12 +++++++
4 files changed, 141 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 16a8a05..8ac0568 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -996,6 +996,56 @@ no_memory:
}
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,
+ &doms,
+ args->ndomains,
+ args->flags)) < 0)
+ goto cleanup;
+
+ if (doms) {
+ 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]);
+ }
+
+ rv = ndomains;
+
+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,
virNetMessagePtr msg ATTRIBUTE_UNUSED,
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 5c87561..4cd02ec 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1265,6 +1265,71 @@ done:
return rv;
}
+static int
+remoteConnectListAllDomains(virConnectPtr conn,
+ virDomainPtr **domains,
+ int ndomains,
+ unsigned int flags)
+{
+ int rv = -1;
+ int i;
+ virDomainPtr *doms = NULL;
+ remote_connect_list_all_domains_args args;
+ remote_connect_list_all_domains_ret ret;
+
+ struct private_data *priv = conn->privateData;
+
+ remoteDriverLock(priv);
+
+ if (domains)
+ *domains = NULL;
+
+ args.ndomains = ndomains;
+ args.flags = flags;
+
+ memset(&ret, 0, sizeof(ret));
+ if (call (conn,
+ priv,
+ 0,
+ REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS,
+ (xdrproc_t) xdr_remote_connect_list_all_domains_args,
+ (char *) &args,
+ (xdrproc_t) xdr_remote_connect_list_all_domains_ret,
+ (char *) &ret) == -1)
+ goto done;
+
+ if (domains) {
+ if (VIR_ALLOC_N(doms, ret.domains.domains_len) < 0)
+ goto no_memory;
+ for (i = 0; i < ret.domains.domains_len; i++) {
+ doms[i] = get_nonnull_domain(conn, ret.domains.domains_val[i]);
+ if (!doms[i])
+ goto no_memory;
+ }
+
+ *domains = doms;
+ doms = NULL;
+ }
+
+ rv = ret.domains.domains_len;
+
+cleanup:
+ xdr_free((xdrproc_t) xdr_remote_connect_list_all_domains_ret, (char *) &ret);
+
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+
+no_memory:
+ if (doms) {
+ for (i = 0; i < ret.domains.domains_len; i++)
+ virDomainFree(*domains[i]);
+ VIR_FREE(doms);
+ }
+ virReportOOMError();
+ goto cleanup;
+}
+
/* Helper to free typed parameters. */
static void
remoteFreeTypedParameters(remote_typed_param *args_params_val,
@@ -5111,6 +5176,7 @@ static virDriver remote_driver = {
.domainGetDiskErrors = remoteDomainGetDiskErrors, /* 0.9.10 */
.domainSetMetadata = remoteDomainSetMetadata, /* 0.9.10 */
.domainGetMetadata = remoteDomainGetMetadata, /* 0.9.10 */
+ .connectListAllDomains = remoteConnectListAllDomains, /* 0.9.13 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 2d57247..bc254bd 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2463,6 +2463,16 @@ struct remote_domain_get_disk_errors_ret {
int nerrors;
};
+struct remote_connect_list_all_domains_args {
+ int ndomains;
+ unsigned int flags;
+};
+
+struct remote_connect_list_all_domains_ret {
+ remote_nonnull_domain domains<>;
+ unsigned int ret;
+};
+
/*----- Protocol. -----*/
@@ -2782,7 +2792,9 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_PM_WAKEUP = 267, /* autogen autogen */
REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE = 268, /* autogen autogen */
REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP = 269, /* autogen autogen */
- REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270 /* autogen autogen */
+ REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270, /* autogen autogen */
+
+ REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 271 /* 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 9b2414f..322a0e1 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1921,6 +1921,17 @@ struct remote_domain_get_disk_errors_ret {
} errors;
int nerrors;
};
+struct remote_connect_list_all_domains_args {
+ int ndomains;
+ u_int flags;
+};
+struct remote_connect_list_all_domains_ret {
+ struct {
+ u_int domains_len;
+ remote_nonnull_domain * domains_val;
+ } domains;
+ u_int ret;
+};
enum remote_procedure {
REMOTE_PROC_OPEN = 1,
REMOTE_PROC_CLOSE = 2,
@@ -2192,4 +2203,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_TRAY_CHANGE = 268,
REMOTE_PROC_DOMAIN_EVENT_PMWAKEUP = 269,
REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270,
+ REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 271,
};
--
1.7.3.4