* src/rpc/gendispatch.pl: (virNodeSetSharedMemoryParameters 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 virDomainGetSharedMemoryParameters) * src/remote/remote_driver.c: (Implement the client side handler for virDomainGetSharedMemoryParameters) * 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 | 61 ++++++++++++++++++++++++++++++++++++++++++ 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, 157 insertions(+), 1 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index f86f7ec..c746c0b 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -4213,6 +4213,67 @@ cleanup: return rv; } +static int +remoteDispatchNodeGetSharedMemoryParameters(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client ATTRIBUTE_UNUSED, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_node_get_shared_memory_parameters_args *args, + remote_node_get_shared_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_SHARED_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 (virNodeGetSharedMemoryParameters(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 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 130d8e2..c7ccaee 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2718,6 +2718,54 @@ done: return rv; } +static int +remoteNodeGetSharedMemoryParameters (virConnectPtr conn, + virTypedParameterPtr params, + int *nparams, + unsigned int flags) +{ + int rv = -1; + remote_node_get_shared_memory_parameters_args args; + remote_node_get_shared_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_SHARED_MEMORY_PARAMETERS, + (xdrproc_t) xdr_remote_node_get_shared_memory_parameters_args, (char *) &args, + (xdrproc_t) xdr_remote_node_get_shared_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_SHARED_MEMORY_PARAMETERS_MAX, + params, + nparams) < 0) + goto cleanup; + + rv = 0; + +cleanup: + xdr_free ((xdrproc_t) xdr_remote_node_get_shared_memory_parameters_ret, + (char *) &ret); +done: + remoteDriverUnlock(priv); + return rv; +} + /*----------------------------------------------------------------------*/ @@ -5686,6 +5734,8 @@ static virDriver remote_driver = { .domainSetMetadata = remoteDomainSetMetadata, /* 0.9.10 */ .domainGetMetadata = remoteDomainGetMetadata, /* 0.9.10 */ .domainGetHostname = remoteDomainGetHostname, /* 0.10.0 */ + .nodeSetSharedMemoryParameters = remoteNodeSetSharedMemoryParameters, /* 0.10.2 */ + .nodeGetSharedMemoryParameters = remoteNodeGetSharedMemoryParameters, /* 0.10.2 */ }; static virNetworkDriver network_driver = { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index e540167..214931c 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 shared memory parameters + */ +const REMOTE_NODE_SHARED_MEMORY_PARAMETERS_MAX = 16; + /* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */ typedef opaque remote_uuid[VIR_UUID_BUFLEN]; @@ -2579,6 +2584,21 @@ struct remote_storage_pool_list_all_volumes_ret { unsigned int ret; }; +struct remote_node_set_shared_memory_parameters_args { + remote_typed_param params<REMOTE_NODE_SHARED_MEMORY_PARAMETERS_MAX>; + unsigned int flags; +}; + +struct remote_node_get_shared_memory_parameters_args { + int nparams; + unsigned int flags; +}; + +struct remote_node_get_shared_memory_parameters_ret { + remote_typed_param params<REMOTE_NODE_SHARED_MEMORY_PARAMETERS_MAX>; + int nparams; +}; + /*----- Protocol. -----*/ /* Define the program number, protocol version and procedure numbers here. */ @@ -2911,7 +2931,9 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_GET_EMULATOR_PIN_INFO = 280, /* skipgen skipgen */ 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_STORAGE_POOL_LIST_ALL_VOLUMES = 282, /* skipgen skipgen priority:high */ + REMOTE_PROC_NODE_SET_SHARED_MEMORY_PARAMETERS = 283, /* autogen autogen */ + REMOTE_PROC_NODE_GET_SHARED_MEMORY_PARAMETERS = 284 /* 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 cef62e8..88eeeee 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2034,6 +2034,24 @@ struct remote_storage_pool_list_all_volumes_ret { } vols; u_int ret; }; +struct remote_node_set_shared_memory_parameters_args { + struct { + u_int params_len; + remote_typed_param * params_val; + } params; + u_int flags; +}; +struct remote_node_get_shared_memory_parameters_args { + int nparams; + u_int flags; +}; +struct remote_node_get_shared_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, @@ -2317,4 +2335,6 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_GET_EMULATOR_PIN_INFO = 280, REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 281, REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 282, + REMOTE_PROC_NODE_SET_SHARED_MEMORY_PARAMETERS = 283, + REMOTE_PROC_NODE_GET_SHARED_MEMORY_PARAMETERS = 284, }; diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 12023e9..8122de1 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 "NodeSetSharedMemoryParameters") { + 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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list