diff mbox

[for-next,4/9] gcov: introduce hooks for the sysctl

Message ID 20171026091938.59247-5-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné Oct. 26, 2017, 9:19 a.m. UTC
So that other implementations of the sysctl can be added.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 xen/common/coverage/gcov.c | 13 ++++++++++---
 xen/include/xen/coverage.h |  7 +++++++
 2 files changed, 17 insertions(+), 3 deletions(-)

Comments

Andrew Cooper Oct. 26, 2017, 10:23 a.m. UTC | #1
On 26/10/17 10:19, Roger Pau Monne wrote:
> @@ -209,6 +210,12 @@ static int gcov_dump_all(XEN_GUEST_HANDLE_PARAM(char) buffer,
>      return ret;
>  }
>  
> +static struct cov_sysctl_ops cov_ops = {

static const.

~Andrew
diff mbox

Patch

diff --git a/xen/common/coverage/gcov.c b/xen/common/coverage/gcov.c
index b1735693be..66c4075f8a 100644
--- a/xen/common/coverage/gcov.c
+++ b/xen/common/coverage/gcov.c
@@ -19,6 +19,7 @@ 
 #include <xen/errno.h>
 #include <xen/guest_access.h>
 #include <xen/types.h>
+#include <xen/coverage.h>
 
 #include <public/sysctl.h>
 
@@ -209,6 +210,12 @@  static int gcov_dump_all(XEN_GUEST_HANDLE_PARAM(char) buffer,
     return ret;
 }
 
+static struct cov_sysctl_ops cov_ops = {
+    .get_size = gcov_get_size,
+    .reset_counters = gcov_reset_all_counters,
+    .dump = gcov_dump_all,
+};
+
 int sysctl_cov_op(struct xen_sysctl_cov_op *op)
 {
     int ret;
@@ -216,7 +223,7 @@  int sysctl_cov_op(struct xen_sysctl_cov_op *op)
     switch ( op->cmd )
     {
     case XEN_SYSCTL_COV_get_size:
-        op->size = gcov_get_size();
+        op->size = cov_ops.get_size();
         ret = 0;
         break;
 
@@ -227,14 +234,14 @@  int sysctl_cov_op(struct xen_sysctl_cov_op *op)
 
         buf = guest_handle_cast(op->buffer, char);
 
-        ret = gcov_dump_all(buf, &size);
+        ret = cov_ops.dump(buf, &size);
         op->size = size;
 
         break;
     }
 
     case XEN_SYSCTL_COV_reset:
-        gcov_reset_all_counters();
+        cov_ops.reset_counters();
         ret = 0;
         break;
 
diff --git a/xen/include/xen/coverage.h b/xen/include/xen/coverage.h
index bdfd29d3bb..9078330109 100644
--- a/xen/include/xen/coverage.h
+++ b/xen/include/xen/coverage.h
@@ -3,6 +3,13 @@ 
 
 #ifdef CONFIG_GCOV
 #include <public/sysctl.h>
+
+struct cov_sysctl_ops {
+    uint32_t (*get_size)(void);
+    void     (*reset_counters)(void);
+    int      (*dump)(XEN_GUEST_HANDLE_PARAM(char), uint32_t *);
+};
+
 int sysctl_cov_op(struct xen_sysctl_cov_op *op);
 #endif