]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
node_memory: Wire up the RPC protocol
authorOsier Yang <jyang@redhat.com>
Fri, 14 Sep 2012 14:42:15 +0000 (22:42 +0800)
committerOsier Yang <jyang@redhat.com>
Mon, 17 Sep 2012 05:54:57 +0000 (13:54 +0800)
* 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
src/remote/remote_driver.c
src/remote/remote_protocol.x
src/remote_protocol-structs
src/rpc/gendispatch.pl

index 6f20761d56f87f9a272fbd5ec7b24b62afe519b4..a3eda9ce0800363c8f741fd44fb206b2fa93414b 100644 (file)
@@ -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
index ee2cd509e3ebe02a57b97460da17cb5dd69b20e7..8f3895de857bc3ed7c9c16e3c0a4c6eadaad5389 100644 (file)
@@ -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 = {
index 1fc7f25534c4ca84f72b6c96cb1ca392c578352d..6201ff758ec5a7689e980f91fdd7b877d2d277e4 100644 (file)
@@ -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 ?
index f39934b5c67a4d5e9c50b71c60274c4b1edce3c1..0130570f0e3f73b277bda5121390493b81303a69 100644 (file)
@@ -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,
 };
index 12023e98cf375a991456a62ca6c1f39096ccf462..774977de9b8fb1de14e10ed656d79cdfd5f8bf7e 100755 (executable)
@@ -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" .