* src/rpc/gendispatch.pl: (virNodeSetMemoryParameters is the
the special one which needs a connection object as the first
argument, improve the generator to support it).
* daemon/remote.c: (Implement the server side handler for
virDomainGetMemoryParameters)
* src/remote/remote_driver.c: (Implement the client side handler
for virDomainGetMemoryParameters)
* src/remote/remote_protocol.x: (New RPC procedures for the two
new APIs and structs to represent the args and ret for it)
* src/remote_protocol-structs: Likewise
---
daemon/remote.c | 59 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 50 +++++++++++++++++++++++++++++++++++
src/remote/remote_protocol.x | 24 ++++++++++++++++-
src/remote_protocol-structs | 20 ++++++++++++++
src/rpc/gendispatch.pl | 3 ++
5 files changed, 155 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 12cd25c..337acd8 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4321,6 +4321,65 @@ cleanup:
return rv;
}
+static int
+remoteDispatchNodeGetMemoryParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
+ virNetServerClientPtr client ATTRIBUTE_UNUSED,
+ virNetMessagePtr msg ATTRIBUTE_UNUSED,
+ virNetMessageErrorPtr rerr,
+ remote_node_get_memory_parameters_args *args,
+ remote_node_get_memory_parameters_ret *ret)
+{
+ virTypedParameterPtr params = NULL;
+ int nparams = args->nparams;
+ unsigned int flags;
+ int rv = -1;
+ struct daemonClientPrivate *priv =
+ virNetServerClientGetPrivateData(client);
+
+ if (!priv->conn) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ goto cleanup;
+ }
+
+ flags = args->flags;
+
+ if (nparams > REMOTE_NODE_MEMORY_PARAMETERS_MAX) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too
large"));
+ goto cleanup;
+ }
+ if (nparams && VIR_ALLOC_N(params, nparams) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+
+ if (virNodeGetMemoryParameters(priv->conn, params, &nparams, flags) < 0)
+ goto cleanup;
+
+ /* In this case, we need to send back the number of parameters
+ * supported
+ */
+ if (args->nparams == 0) {
+ ret->nparams = nparams;
+ goto success;
+ }
+
+ if (remoteSerializeTypedParameters(params, nparams,
+ &ret->params.params_val,
+ &ret->params.params_len,
+ args->flags) < 0)
+ goto cleanup;
+
+success:
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ virNetMessageSaveError(rerr);
+ virTypedParameterArrayClear(params, nparams);
+ VIR_FREE(params);
+ return rv;
+}
/*----- Helpers. -----*/
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f47b06c..c16fc4a 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5510,6 +5510,54 @@ done:
return rv;
}
+static int
+remoteNodeGetMemoryParameters(virConnectPtr conn,
+ virTypedParameterPtr params,
+ int *nparams,
+ unsigned int flags)
+{
+ int rv = -1;
+ remote_node_get_memory_parameters_args args;
+ remote_node_get_memory_parameters_ret ret;
+ struct private_data *priv = conn->privateData;
+
+ remoteDriverLock(priv);
+
+ args.nparams = *nparams;
+ args.flags = flags;
+
+ memset (&ret, 0, sizeof(ret));
+ if (call (conn, priv, 0, REMOTE_PROC_NODE_GET_MEMORY_PARAMETERS,
+ (xdrproc_t) xdr_remote_node_get_memory_parameters_args, (char *)
&args,
+ (xdrproc_t) xdr_remote_node_get_memory_parameters_ret, (char *) &ret)
== -1)
+ goto done;
+
+ /* Handle the case when the caller does not know the number of parameters
+ * and is asking for the number of parameters supported
+ */
+ if (*nparams == 0) {
+ *nparams = ret.nparams;
+ rv = 0;
+ goto cleanup;
+ }
+
+ if (remoteDeserializeTypedParameters(ret.params.params_val,
+ ret.params.params_len,
+ REMOTE_NODE_MEMORY_PARAMETERS_MAX,
+ params,
+ nparams) < 0)
+ goto cleanup;
+
+ rv = 0;
+
+cleanup:
+ xdr_free ((xdrproc_t) xdr_remote_node_get_memory_parameters_ret,
+ (char *) &ret);
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
static void
remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event)
{
@@ -5821,6 +5869,8 @@ static virDriver remote_driver = {
.domainSetMetadata = remoteDomainSetMetadata, /* 0.9.10 */
.domainGetMetadata = remoteDomainGetMetadata, /* 0.9.10 */
.domainGetHostname = remoteDomainGetHostname, /* 0.10.0 */
+ .nodeSetMemoryParameters = remoteNodeSetMemoryParameters, /* 0.10.2 */
+ .nodeGetMemoryParameters = remoteNodeGetMemoryParameters, /* 0.10.2 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 54054af..c640f2f 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -229,6 +229,11 @@ const REMOTE_DOMAIN_GET_CPU_STATS_MAX = 2048;
*/
const REMOTE_DOMAIN_DISK_ERRORS_MAX = 256;
+/*
+ * Upper limit on number of memory parameters
+ */
+const REMOTE_NODE_MEMORY_PARAMETERS_MAX = 16;
+
/* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */
typedef opaque remote_uuid[VIR_UUID_BUFLEN];
@@ -2599,6 +2604,21 @@ struct remote_connect_list_all_interfaces_ret {
unsigned int ret;
};
+struct remote_node_set_memory_parameters_args {
+ remote_typed_param params<REMOTE_NODE_MEMORY_PARAMETERS_MAX>;
+ unsigned int flags;
+};
+
+struct remote_node_get_memory_parameters_args {
+ int nparams;
+ unsigned int flags;
+};
+
+struct remote_node_get_memory_parameters_ret {
+ remote_typed_param params<REMOTE_NODE_MEMORY_PARAMETERS_MAX>;
+ int nparams;
+};
+
/*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */
@@ -2933,7 +2953,9 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 281, /* skipgen skipgen priority:high
*/
REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 282, /* skipgen skipgen priority:high */
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 283, /* skipgen skipgen priority:high */
- REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284 /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284, /* skipgen skipgen priority:high */
+ REMOTE_PROC_NODE_SET_MEMORY_PARAMETERS = 285, /* autogen autogen */
+ REMOTE_PROC_NODE_GET_MEMORY_PARAMETERS = 286 /* skipgen skipgen */
/*
* Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 2a33039..7fc3e25 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2056,6 +2056,24 @@ struct remote_connect_list_all_interfaces_ret {
} ifaces;
u_int ret;
};
+struct remote_node_set_memory_parameters_args {
+ struct {
+ u_int params_len;
+ remote_typed_param * params_val;
+ } params;
+ u_int flags;
+};
+struct remote_node_get_memory_parameters_args {
+ int nparams;
+ u_int flags;
+};
+struct remote_node_get_memory_parameters_ret {
+ struct {
+ u_int params_len;
+ remote_typed_param * params_val;
+ } params;
+ int nparams;
+};
enum remote_procedure {
REMOTE_PROC_OPEN = 1,
REMOTE_PROC_CLOSE = 2,
@@ -2341,4 +2359,6 @@ enum remote_procedure {
REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 282,
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 283,
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284,
+ REMOTE_PROC_NODE_SET_MEMORY_PARAMETERS = 285,
+ REMOTE_PROC_NODE_GET_MEMORY_PARAMETERS = 286,
};
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 12023e9..774977d 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -478,6 +478,9 @@ elsif ($opt_b) {
} elsif ($args_member =~ m/^remote_typed_param (\S+)<(\S+)>;/) {
push(@vars_list, "virTypedParameterPtr $1 = NULL");
push(@vars_list, "int n$1");
+ if ($call->{ProcName} eq "NodeSetMemoryParameters") {
+ push(@args_list, "priv->conn");
+ }
push(@args_list, "$1");
push(@args_list, "n$1");
push(@getters_list, " if (($1 =
remoteDeserializeTypedParameters(args->$1.$1_val,\n" .
--
1.7.7.3