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

[libvirt] [PATCH 7/9] Wire protocol format and dispatcher for virConnectBaselineCPU



Signed-off-by: Jiri Denemark <jdenemar redhat com>
---
 daemon/remote.c                     |   25 +++++++++++++++++++++++++
 daemon/remote_dispatch_args.h       |    1 +
 daemon/remote_dispatch_prototypes.h |    8 ++++++++
 daemon/remote_dispatch_ret.h        |    1 +
 daemon/remote_dispatch_table.h      |    5 +++++
 src/remote/remote_protocol.c        |   24 +++++++++++++++++++++++-
 src/remote/remote_protocol.h        |   20 ++++++++++++++++++++
 src/remote/remote_protocol.x        |   18 +++++++++++++++++-
 8 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 299f971..0ac4ba6 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -5312,6 +5312,31 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
 }
 
 
+static int
+remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
+                          struct qemud_client *client ATTRIBUTE_UNUSED,
+                          virConnectPtr conn,
+                          remote_message_header *hdr ATTRIBUTE_UNUSED,
+                          remote_error *err,
+                          remote_cpu_baseline_args *args,
+                          remote_cpu_baseline_ret *ret)
+{
+    char *cpu;
+
+    cpu = virConnectBaselineCPU(conn,
+                                args->xmlCPUs.xmlCPUs_len,
+                                (const char **) args->xmlCPUs.xmlCPUs_val,
+                                args->flags);
+    if (cpu == NULL) {
+        remoteDispatchConnError(err, conn);
+        return -1;
+    }
+
+    ret->cpu = cpu;
+    return 0;
+}
+
+
 /*----- Helpers. -----*/
 
 /* get_nonnull_domain and get_nonnull_network turn an on-wire
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index c1801d0..bbf70ff 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -135,3 +135,4 @@
     remote_interface_is_active_args val_remote_interface_is_active_args;
     remote_cpu_compare_args val_remote_cpu_compare_args;
     remote_domain_memory_stats_args val_remote_domain_memory_stats_args;
+    remote_cpu_baseline_args val_remote_cpu_baseline_args;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index 1a0f8d8..99cf01c 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -50,6 +50,14 @@ static int remoteDispatchClose(
     remote_error *err,
     void *args,
     void *ret);
+static int remoteDispatchCpuBaseline(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_cpu_baseline_args *args,
+    remote_cpu_baseline_ret *ret);
 static int remoteDispatchCpuCompare(
     struct qemud_server *server,
     struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index d7811de..5c6a78f 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -117,3 +117,4 @@
     remote_get_lib_version_ret val_remote_get_lib_version_ret;
     remote_cpu_compare_ret val_remote_cpu_compare_ret;
     remote_domain_memory_stats_ret val_remote_domain_memory_stats_ret;
+    remote_cpu_baseline_ret val_remote_cpu_baseline_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index 09ebeee..51a897c 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -802,3 +802,8 @@
     .args_filter = (xdrproc_t) xdr_remote_domain_memory_stats_args,
     .ret_filter = (xdrproc_t) xdr_remote_domain_memory_stats_ret,
 },
+{   /* CpuBaseline => 160 */
+    .fn = (dispatch_fn) remoteDispatchCpuBaseline,
+    .args_filter = (xdrproc_t) xdr_remote_cpu_baseline_args,
+    .ret_filter = (xdrproc_t) xdr_remote_cpu_baseline_ret,
+},
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 834eb6b..4ff6217 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -4,7 +4,7 @@
  * It was generated using rpcgen.
  */
 
-#include "./remote/remote_protocol.h"
+#include "/home/jirka/work/libvirt/git/src/remote/remote_protocol.h"
 #include "internal.h"
 #include <arpa/inet.h>
 
@@ -2912,6 +2912,28 @@ xdr_remote_cpu_compare_ret (XDR *xdrs, remote_cpu_compare_ret *objp)
 }
 
 bool_t
+xdr_remote_cpu_baseline_args (XDR *xdrs, remote_cpu_baseline_args *objp)
+{
+        char **objp_cpp0 = (char **) (void *) &objp->xmlCPUs.xmlCPUs_val;
+
+         if (!xdr_array (xdrs, objp_cpp0, (u_int *) &objp->xmlCPUs.xmlCPUs_len, REMOTE_CPU_BASELINE_MAX,
+                sizeof (remote_nonnull_string), (xdrproc_t) xdr_remote_nonnull_string))
+                 return FALSE;
+         if (!xdr_u_int (xdrs, &objp->flags))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
+xdr_remote_cpu_baseline_ret (XDR *xdrs, remote_cpu_baseline_ret *objp)
+{
+
+         if (!xdr_remote_nonnull_string (xdrs, &objp->cpu))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
 xdr_remote_procedure (XDR *xdrs, remote_procedure *objp)
 {
 
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index 3f3b520..9c1b341 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -48,6 +48,7 @@ typedef remote_nonnull_string *remote_string;
 #define REMOTE_SECURITY_DOI_MAX VIR_SECURITY_DOI_BUFLEN
 #define REMOTE_SECRET_VALUE_MAX 65536
 #define REMOTE_SECRET_UUID_LIST_MAX 16384
+#define REMOTE_CPU_BASELINE_MAX 256
 
 typedef char remote_uuid[VIR_UUID_BUFLEN];
 
@@ -1649,6 +1650,20 @@ struct remote_cpu_compare_ret {
         int result;
 };
 typedef struct remote_cpu_compare_ret remote_cpu_compare_ret;
+
+struct remote_cpu_baseline_args {
+        struct {
+                u_int xmlCPUs_len;
+                remote_nonnull_string *xmlCPUs_val;
+        } xmlCPUs;
+        u_int flags;
+};
+typedef struct remote_cpu_baseline_args remote_cpu_baseline_args;
+
+struct remote_cpu_baseline_ret {
+        remote_nonnull_string cpu;
+};
+typedef struct remote_cpu_baseline_ret remote_cpu_baseline_ret;
 #define REMOTE_PROGRAM 0x20008086
 #define REMOTE_PROTOCOL_VERSION 1
 
@@ -1812,6 +1827,7 @@ enum remote_procedure {
         REMOTE_PROC_GET_LIB_VERSION = 157,
         REMOTE_PROC_CPU_COMPARE = 158,
         REMOTE_PROC_DOMAIN_MEMORY_STATS = 159,
+        REMOTE_PROC_CPU_BASELINE = 160,
 };
 typedef enum remote_procedure remote_procedure;
 
@@ -2114,6 +2130,8 @@ extern  bool_t xdr_remote_interface_is_active_args (XDR *, remote_interface_is_a
 extern  bool_t xdr_remote_interface_is_active_ret (XDR *, remote_interface_is_active_ret*);
 extern  bool_t xdr_remote_cpu_compare_args (XDR *, remote_cpu_compare_args*);
 extern  bool_t xdr_remote_cpu_compare_ret (XDR *, remote_cpu_compare_ret*);
+extern  bool_t xdr_remote_cpu_baseline_args (XDR *, remote_cpu_baseline_args*);
+extern  bool_t xdr_remote_cpu_baseline_ret (XDR *, remote_cpu_baseline_ret*);
 extern  bool_t xdr_remote_procedure (XDR *, remote_procedure*);
 extern  bool_t xdr_remote_message_type (XDR *, remote_message_type*);
 extern  bool_t xdr_remote_message_status (XDR *, remote_message_status*);
@@ -2390,6 +2408,8 @@ extern bool_t xdr_remote_interface_is_active_args ();
 extern bool_t xdr_remote_interface_is_active_ret ();
 extern bool_t xdr_remote_cpu_compare_args ();
 extern bool_t xdr_remote_cpu_compare_ret ();
+extern bool_t xdr_remote_cpu_baseline_args ();
+extern bool_t xdr_remote_cpu_baseline_ret ();
 extern bool_t xdr_remote_procedure ();
 extern bool_t xdr_remote_message_type ();
 extern bool_t xdr_remote_message_status ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index bed3940..1e9053b 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -155,6 +155,11 @@ const REMOTE_SECRET_VALUE_MAX = 65536;
  */
 const REMOTE_SECRET_UUID_LIST_MAX = 16384;
 
+/*
+ * Upper limit on list of CPUs accepted when computing a baseline CPU.
+ */
+const REMOTE_CPU_BASELINE_MAX = 256;
+
 /* UUID.  VIR_UUID_BUFLEN definition comes from libvirt.h */
 typedef opaque remote_uuid[VIR_UUID_BUFLEN];
 
@@ -1461,6 +1466,16 @@ struct remote_cpu_compare_ret {
 };
 
 
+struct remote_cpu_baseline_args {
+    remote_nonnull_string xmlCPUs<REMOTE_CPU_BASELINE_MAX>;
+    unsigned flags;
+};
+
+struct remote_cpu_baseline_ret {
+    remote_nonnull_string cpu;
+};
+
+
 /*----- Protocol. -----*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -1641,7 +1656,8 @@ enum remote_procedure {
     REMOTE_PROC_INTERFACE_IS_ACTIVE = 156,
     REMOTE_PROC_GET_LIB_VERSION = 157,
     REMOTE_PROC_CPU_COMPARE = 158,
-    REMOTE_PROC_DOMAIN_MEMORY_STATS = 159
+    REMOTE_PROC_DOMAIN_MEMORY_STATS = 159,
+    REMOTE_PROC_CPU_BASELINE = 160
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
-- 
1.6.6.1


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