aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOsier Yang <jyang@redhat.com>2012-09-14 22:42:15 +0800
committerOsier Yang <jyang@redhat.com>2012-09-17 13:54:57 +0800
commit00792722fddeca2ac828a581ef2077fb767f69ff (patch)
treeed1718a006f683b01dd6a15e011824b105788706 /src
parentnode_memory: Define the APIs to get/set memory parameters (diff)
downloadlibvirt-00792722fddeca2ac828a581ef2077fb767f69ff.tar.gz
libvirt-00792722fddeca2ac828a581ef2077fb767f69ff.tar.bz2
libvirt-00792722fddeca2ac828a581ef2077fb767f69ff.zip
node_memory: Wire up the RPC protocol
* 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
Diffstat (limited to 'src')
-rw-r--r--src/remote/remote_driver.c50
-rw-r--r--src/remote/remote_protocol.x24
-rw-r--r--src/remote_protocol-structs20
-rwxr-xr-xsrc/rpc/gendispatch.pl3
4 files changed, 96 insertions, 1 deletions
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index ee2cd509e..8f3895de8 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5698,6 +5698,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)
{
@@ -6009,6 +6057,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 1fc7f2553..6201ff758 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 = 64;
+
/* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */
typedef opaque remote_uuid[VIR_UUID_BUFLEN];
@@ -2629,6 +2634,21 @@ struct remote_connect_list_all_secrets_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. */
@@ -2966,7 +2986,9 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284, /* skipgen skipgen priority:high */
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285, /* skipgen skipgen priority:high */
REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 286, /* skipgen skipgen priority:high */
- REMOTE_PROC_CONNECT_LIST_ALL_SECRETS = 287 /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_SECRETS = 287, /* skipgen skipgen priority:high */
+ REMOTE_PROC_NODE_SET_MEMORY_PARAMETERS = 288, /* autogen autogen */
+ REMOTE_PROC_NODE_GET_MEMORY_PARAMETERS = 289 /* 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 f39934b5c..0130570f0 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2089,6 +2089,24 @@ struct remote_list_all_secrets_ret {
} secrets;
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,
@@ -2377,4 +2395,6 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285,
REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 286,
REMOTE_PROC_CONNECT_LIST_ALL_SECRETS = 287,
+ REMOTE_PROC_NODE_SET_MEMORY_PARAMETERS = 288,
+ REMOTE_PROC_NODE_GET_MEMORY_PARAMETERS = 289,
};
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 12023e98c..774977de9 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" .