From: Mathieu Desnoyers Date: Mon, 20 Oct 2014 22:50:33 +0000 (-0400) Subject: Use lttng-modules ABI version ioctl X-Git-Tag: v2.6.0-rc2~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=084cb5fec17c87a391c7ee7596caf5adfd7d3766;p=lttng-tools.git Use lttng-modules ABI version ioctl Check compatibility between lttng-modules and tools using a version numbering specifically for the ABI, rather than relying on the major version of lttng-modules per se. This takes into account that we sometimes depend on lock-step updates of the toolchain, including tools and modules. Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 2aeef263d..00bfbbc2b 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -26,6 +26,7 @@ #include #include +#include #include #include "consumer.h" @@ -698,6 +699,7 @@ int kernel_validate_version(int tracer_fd) { int ret; struct lttng_kernel_tracer_version version; + struct lttng_kernel_tracer_abi_version abi_version; ret = kernctl_tracer_version(tracer_fd, &version); if (ret < 0) { @@ -706,17 +708,28 @@ int kernel_validate_version(int tracer_fd) } /* Validate version */ - if (version.major != KERN_MODULES_PRE_MAJOR - && version.major != KERN_MODULES_MAJOR) { + if (version.major != VERSION_MAJOR) { + ERR("Kernel tracer major version (%d) is not compatible with lttng-tools major version (%d)", + version.major, VERSION_MAJOR); goto error_version; } - - DBG2("Kernel tracer version validated (major version %d)", version.major); + ret = kernctl_tracer_abi_version(tracer_fd, &abi_version); + if (ret < 0) { + ERR("Failed at getting lttng-modules ABI version"); + goto error; + } + if (abi_version.major != LTTNG_MODULES_ABI_MAJOR_VERSION) { + ERR("Kernel tracer ABI version (%d.%d) is not compatible with expected ABI major version (%d.*)", + abi_version.major, abi_version.minor, + LTTNG_MODULES_ABI_MAJOR_VERSION); + goto error; + } + DBG2("Kernel tracer version validated (%d.%d, ABI %d.%d)", + version.major, version.minor, + abi_version.major, abi_version.minor); return 0; error_version: - ERR("Kernel major version %d is not compatible (supporting <= %d)", - version.major, KERN_MODULES_MAJOR) ret = -1; error: diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c index a387b93bf..f3ef93d3f 100644 --- a/src/common/kernel-ctl/kernel-ctl.c +++ b/src/common/kernel-ctl/kernel-ctl.c @@ -346,6 +346,12 @@ end: return ret; } +int kernctl_tracer_abi_version(int fd, + struct lttng_kernel_tracer_abi_version *v) +{ + return ioctl(fd, LTTNG_KERNEL_TRACER_ABI_VERSION, v); +} + int kernctl_wait_quiescent(int fd) { return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_WAIT_QUIESCENT, diff --git a/src/common/kernel-ctl/kernel-ctl.h b/src/common/kernel-ctl/kernel-ctl.h index 4ef1b8795..d9e6c54a4 100644 --- a/src/common/kernel-ctl/kernel-ctl.h +++ b/src/common/kernel-ctl/kernel-ctl.h @@ -38,6 +38,7 @@ int kernctl_stop_session(int fd); int kernctl_tracepoint_list(int fd); int kernctl_syscall_list(int fd); int kernctl_tracer_version(int fd, struct lttng_kernel_tracer_version *v); +int kernctl_tracer_abi_version(int fd, struct lttng_kernel_tracer_abi_version *v); int kernctl_wait_quiescent(int fd); int kernctl_calibrate(int fd, struct lttng_kernel_calibrate *calibrate); diff --git a/src/common/kernel-ctl/kernel-ioctl.h b/src/common/kernel-ctl/kernel-ioctl.h index 475a066c3..927de6fd6 100644 --- a/src/common/kernel-ctl/kernel-ioctl.h +++ b/src/common/kernel-ctl/kernel-ioctl.h @@ -19,6 +19,9 @@ #ifndef _LTT_KERNEL_IOCTL_H #define _LTT_KERNEL_IOCTL_H +#define LTTNG_MODULES_ABI_MAJOR_VERSION 1 +#define LTTNG_MODULES_ABI_MINOR_VERSION 0 + /* Get a snapshot of the current ring buffer producer and consumer positions */ #define RING_BUFFER_SNAPSHOT _IO(0xF6, 0x00) /* Get the consumer position (iteration start) */ @@ -104,6 +107,8 @@ #define LTTNG_KERNEL_CALIBRATE \ _IOWR(0xF6, 0x49, struct lttng_kernel_calibrate) #define LTTNG_KERNEL_SYSCALL_LIST _IO(0xF6, 0x4A) +#define LTTNG_KERNEL_TRACER_ABI_VERSION \ + _IOR(0xF6, 0x4B, struct lttng_kernel_tracer_abi_version) /* Session FD ioctl */ #define LTTNG_KERNEL_METADATA \ diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index 4df324005..abd22c99b 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -124,6 +124,11 @@ struct lttng_kernel_tracer_version { uint32_t patchlevel; } LTTNG_PACKED; +struct lttng_kernel_tracer_abi_version { + uint32_t major; + uint32_t minor; +} LTTNG_PACKED; + enum lttng_kernel_calibrate_type { LTTNG_KERNEL_CALIBRATE_KRETPROBE, };