mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
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
This commit is contained in:
parent
12ad7435de
commit
00792722fd
@ -4483,6 +4483,66 @@ 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. -----*/
|
||||
|
||||
/* get_nonnull_domain and get_nonnull_network turn an on-wire
|
||||
|
@ -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 = {
|
||||
|
@ -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 ?
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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" .
|
||||
|
Loading…
Reference in New Issue
Block a user