Message ID | 20171109111349.95800-5-roger.pau@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Nov 09, 2017 at 11:13:44AM +0000, Roger Pau Monne wrote: > 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> > --- > Changes since v1: > - Constify cov_ops. > - Introduce a local coverage.h provate header and place the > definition of cov_sysctl_ops there. > --- > xen/common/coverage/coverage.h | 12 ++++++++++++ > xen/common/coverage/gcov.c | 13 ++++++++++--- > 2 files changed, 22 insertions(+), 3 deletions(-) > create mode 100644 xen/common/coverage/coverage.h > > diff --git a/xen/common/coverage/coverage.h b/xen/common/coverage/coverage.h > new file mode 100644 > index 0000000000..4613d5e6c1 > --- /dev/null > +++ b/xen/common/coverage/coverage.h > @@ -0,0 +1,12 @@ > +#ifndef _XEN_COV_PRIV_H > +#define _XEN_COV_PRIV_H > + > +#include <xen/types.h> > + > +struct cov_sysctl_ops { > + uint32_t (*get_size)(void); > + void (*reset_counters)(void); > + int (*dump)(XEN_GUEST_HANDLE_PARAM(char), uint32_t *); > +}; > + > +#endif Perhaps add the editor configuration block?
diff --git a/xen/common/coverage/coverage.h b/xen/common/coverage/coverage.h new file mode 100644 index 0000000000..4613d5e6c1 --- /dev/null +++ b/xen/common/coverage/coverage.h @@ -0,0 +1,12 @@ +#ifndef _XEN_COV_PRIV_H +#define _XEN_COV_PRIV_H + +#include <xen/types.h> + +struct cov_sysctl_ops { + uint32_t (*get_size)(void); + void (*reset_counters)(void); + int (*dump)(XEN_GUEST_HANDLE_PARAM(char), uint32_t *); +}; + +#endif diff --git a/xen/common/coverage/gcov.c b/xen/common/coverage/gcov.c index 798032cbbb..8627ef3355 100644 --- a/xen/common/coverage/gcov.c +++ b/xen/common/coverage/gcov.c @@ -22,6 +22,7 @@ #include <public/sysctl.h> +#include "coverage.h" #include "gcov.h" /** @@ -209,6 +210,12 @@ static int gcov_dump_all(XEN_GUEST_HANDLE_PARAM(char) buffer, return ret; } +static const 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_coverage_op *op) { int ret; @@ -216,7 +223,7 @@ int sysctl_cov_op(struct xen_sysctl_coverage_op *op) switch ( op->cmd ) { case XEN_SYSCTL_COVERAGE_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_coverage_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_COVERAGE_reset: - gcov_reset_all_counters(); + cov_ops.reset_counters(); ret = 0; break;
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> --- Changes since v1: - Constify cov_ops. - Introduce a local coverage.h provate header and place the definition of cov_sysctl_ops there. --- xen/common/coverage/coverage.h | 12 ++++++++++++ xen/common/coverage/gcov.c | 13 ++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 xen/common/coverage/coverage.h