[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCHv2 4/9] virNodeGetCPUMapFlags: Implement wire protocol.



- Defined the wire protocol format for virNodeGetCPUMapFlags and its
  arguments
- Implemented remote method invocation (remoteNodeGetCPUMapFlags)
- Implemented method dispacher (remoteDispatchNodeGetCPUMapFlags)

Signed-off-by: Viktor Mihajlovski <mihajlov linux vnet ibm com>
---
 daemon/remote.c              |   44 +++++++++++++++++++++++++++++++++++++
 src/remote/remote_driver.c   |   49 ++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x |   13 ++++++++++-
 src/remote_protocol-structs  |   12 ++++++++++
 4 files changed, 117 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index e7fe128..36291d1 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4544,6 +4544,50 @@ cleanup:
     return rv;
 }
 
+static int
+remoteDispatchNodeGetCPUMapFlags(virNetServerPtr server ATTRIBUTE_UNUSED,
+                                 virNetServerClientPtr client ATTRIBUTE_UNUSED,
+                                 virNetMessagePtr msg ATTRIBUTE_UNUSED,
+                                 virNetMessageErrorPtr rerr,
+                                 remote_node_get_cpu_map_flags_args *args,
+                                 remote_node_get_cpu_map_flags_ret *ret)
+{
+    unsigned char *cpumap;
+    unsigned int online;
+    unsigned int flags;
+    int cpunum;
+    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;
+
+    cpunum = virNodeGetCPUMapFlags(priv->conn, &cpumap, &online, flags);
+    if (cpunum < 0)
+        goto cleanup;
+
+    /* 'serialize' return cpumap */
+    ret->cpumap.cpumap_len = VIR_CPU_MAPLEN(cpunum);
+    ret->cpumap.cpumap_val = (char *) cpumap;
+    cpumap = NULL;
+
+    ret->online = online;
+    ret->ret = cpunum;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    VIR_FREE(cpumap);
+    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 fc4c696..7c89477 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5749,6 +5749,54 @@ done:
     return rv;
 }
 
+int
+remoteNodeGetCPUMapFlags(virConnectPtr conn,
+                         unsigned char **cpumap,
+                         unsigned int *online,
+                         unsigned int flags)
+{
+    int rv = -1;
+    remote_node_get_cpu_map_flags_args args;
+    remote_node_get_cpu_map_flags_ret ret;
+    struct private_data *priv = conn->privateData;
+
+    remoteDriverLock(priv);
+
+    /* IMPROVEME: send info about optional args */
+    args.flags = flags;
+
+    memset (&ret, 0, sizeof(ret));
+    if (call (conn, priv, 0, REMOTE_PROC_NODE_GET_CPU_MAP_FLAGS,
+              (xdrproc_t) xdr_remote_node_get_cpu_map_flags_args,
+              (char *) &args,
+              (xdrproc_t) xdr_remote_node_get_cpu_map_flags_ret,
+              (char *) &ret) == -1)
+        goto done;
+
+    if (ret.ret < 0)
+        goto cleanup;
+
+    if (cpumap) {
+        if (VIR_ALLOC_N(*cpumap, ret.cpumap.cpumap_len) < 0) {
+            virReportOOMError();
+            goto cleanup;
+        }
+        memcpy(*cpumap, ret.cpumap.cpumap_val, ret.cpumap.cpumap_len);
+    }
+
+    if (online)
+        *online = ret.online;
+
+    rv = ret.ret;
+
+cleanup:
+    xdr_free ((xdrproc_t) xdr_remote_node_get_cpu_map_flags_ret,
+              (char *) &ret);
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
 static void
 remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event)
 {
@@ -6063,6 +6111,7 @@ static virDriver remote_driver = {
     .domainGetHostname = remoteDomainGetHostname, /* 0.10.0 */
     .nodeSetMemoryParameters = remoteNodeSetMemoryParameters, /* 0.10.2 */
     .nodeGetMemoryParameters = remoteNodeGetMemoryParameters, /* 0.10.2 */
+    .nodeGetCPUMapFlags = remoteNodeGetCPUMapFlags, /* 1.0.0 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index b0b530c..bc5e70f 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2666,6 +2666,16 @@ struct remote_node_get_memory_parameters_ret {
     int nparams;
 };
 
+struct remote_node_get_cpu_map_flags_args {
+    unsigned int flags;
+};
+
+struct remote_node_get_cpu_map_flags_ret {
+    opaque cpumap<REMOTE_CPUMAP_MAX>;
+    unsigned int online;
+    int ret;
+};
+
 /*----- Protocol. -----*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -3008,7 +3018,8 @@ enum remote_procedure {
     REMOTE_PROC_NODE_GET_MEMORY_PARAMETERS = 289, /* skipgen skipgen */
     REMOTE_PROC_DOMAIN_BLOCK_COMMIT = 290, /* autogen autogen */
 
-    REMOTE_PROC_NETWORK_UPDATE = 291 /* autogen autogen priority:high */
+    REMOTE_PROC_NETWORK_UPDATE = 291, /* autogen autogen priority:high */
+    REMOTE_PROC_NODE_GET_CPU_MAP_FLAGS = 292 /* 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 4d2627a..8f1e678 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2123,6 +2123,17 @@ struct remote_node_get_memory_parameters_ret {
         } params;
         int                        nparams;
 };
+struct remote_node_get_cpu_map_flags_args {
+        u_int                      flags;
+};
+struct remote_node_get_cpu_map_flags_ret {
+        struct {
+                u_int              cpumap_len;
+                char *             cpumap_val;
+        } cpumap;
+        u_int                      online;
+        int                        ret;
+};
 enum remote_procedure {
         REMOTE_PROC_OPEN = 1,
         REMOTE_PROC_CLOSE = 2,
@@ -2415,4 +2426,5 @@ enum remote_procedure {
         REMOTE_PROC_NODE_GET_MEMORY_PARAMETERS = 289,
         REMOTE_PROC_DOMAIN_BLOCK_COMMIT = 290,
         REMOTE_PROC_NETWORK_UPDATE = 291,
+        REMOTE_PROC_NODE_GET_CPU_MAP_FLAGS = 292,
 };
-- 
1.7.0.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]