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

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

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 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        |   22 ++++++++++++++++++++++
 src/remote/remote_protocol.h        |   20 ++++++++++++++++++++
 src/remote/remote_protocol.x        |   18 +++++++++++++++++-
 8 files changed, 99 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index ba3c670..eacc6f9 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -5365,6 +5365,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,
+                                (const char **) args->xmlCPUs.xmlCPUs_val,
+                                args->xmlCPUs.xmlCPUs_len,
+                                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 c098c8e..86a881e 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -137,3 +137,4 @@
     remote_domain_memory_stats_args val_remote_domain_memory_stats_args;
     remote_domain_attach_device_flags_args val_remote_domain_attach_device_flags_args;
     remote_domain_detach_device_flags_args val_remote_domain_detach_device_flags_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 4b6bd4c..be67f9a 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 89719f6..428057a 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -812,3 +812,8 @@
     .args_filter = (xdrproc_t) xdr_remote_domain_detach_device_flags_args,
     .ret_filter = (xdrproc_t) xdr_void,
 },
+{   /* CpuBaseline => 162 */
+    .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 90ecf09..164eca5 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -2938,6 +2938,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 db574a8..0344077 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];
 
@@ -1663,6 +1664,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
 
@@ -1828,6 +1843,7 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_MEMORY_STATS = 159,
         REMOTE_PROC_DOMAIN_ATTACH_DEVICE_FLAGS = 160,
         REMOTE_PROC_DOMAIN_DETACH_DEVICE_FLAGS = 161,
+        REMOTE_PROC_CPU_BASELINE = 162,
 };
 typedef enum remote_procedure remote_procedure;
 
@@ -2132,6 +2148,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*);
@@ -2410,6 +2428,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 98953a9..432359d 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];
 
@@ -1473,6 +1478,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. */
@@ -1656,7 +1671,8 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_MEMORY_STATS = 159,
     REMOTE_PROC_DOMAIN_ATTACH_DEVICE_FLAGS = 160,
 
-    REMOTE_PROC_DOMAIN_DETACH_DEVICE_FLAGS = 161
+    REMOTE_PROC_DOMAIN_DETACH_DEVICE_FLAGS = 161,
+    REMOTE_PROC_CPU_BASELINE = 162
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
-- 
1.6.6.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]