summaryrefslogtreecommitdiffstats
path: root/recipes-containers/lxc
diff options
context:
space:
mode:
authorJim Somerville <Jim.Somerville@windriver.com>2015-09-29 16:25:18 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2015-10-02 08:52:48 -0400
commit49e29c7f838039c268b3fc8646e4d221c6d4baa9 (patch)
tree9ad3b2358adaa36c3e880bf475046ba9ae17d460 /recipes-containers/lxc
parenta7841b85605ff1645675cab77569ff7576af9530 (diff)
downloadmeta-virtualization-49e29c7f838039c268b3fc8646e4d221c6d4baa9.tar.gz
lxc: logs: use base filenames when reporting src files
Problem: Logs are nice in that they report the source file, routine, and line number where an issue occurs. But the file is printed as the absolute filename. Users do not need to see a long spew of path directory names where the package just happened to have been built on some host somewhere. It can be confusing to anyone other than the developer. Solution: Introduce a configure option to chop off all leading directories so that just the source filename ie. basename is printed. [ Upstream status: Not needed. These absolute filenames are a consequence of poky/bitbake feeding the absolute filenames to the compiler. If you build lxc outside of poky/bitbake, just the basenames are fed to the compiler. ] Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'recipes-containers/lxc')
-rw-r--r--recipes-containers/lxc/files/logs-optionally-use-base-filenames-to-report-src-fil.patch70
-rw-r--r--recipes-containers/lxc/lxc_1.1.3.bb3
2 files changed, 73 insertions, 0 deletions
diff --git a/recipes-containers/lxc/files/logs-optionally-use-base-filenames-to-report-src-fil.patch b/recipes-containers/lxc/files/logs-optionally-use-base-filenames-to-report-src-fil.patch
new file mode 100644
index 00000000..583b6f1c
--- /dev/null
+++ b/recipes-containers/lxc/files/logs-optionally-use-base-filenames-to-report-src-fil.patch
@@ -0,0 +1,70 @@
1From 4729d0f4c4d1dacd150ddfd7061dda875eb94e34 Mon Sep 17 00:00:00 2001
2Message-Id: <4729d0f4c4d1dacd150ddfd7061dda875eb94e34.1443216870.git.Jim.Somerville@windriver.com>
3From: Jim Somerville <Jim.Somerville@windriver.com>
4Date: Fri, 25 Sep 2015 15:08:17 -0400
5Subject: [PATCH 1/1] logs: optionally use base filenames to report src files
6
7Problem: Logs are nice in that they report the source file,
8routine, and line number where an issue occurs. But the
9file is printed as the absolute filename. Users do not
10need to see a long spew of path directory names where the package
11was built. It just confuses things.
12
13Solution: Optionally chop off all leading directories so that just
14the source filename ie. basename is printed. This is done by
15setting a #ifdef LXC_LOG_USE_BASENAME check in the code. That
16define is done via the optional --enable-log-src-basename provided
17at configure time.
18
19Using __BASE_FILE__ instead of __FILE__ did not work. It
20refers to the file name as presented to the compile
21machinery, and that may still be the absolute pathname to
22the file.
23
24Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
25---
26 configure.ac | 9 +++++++++
27 src/lxc/log.h | 5 +++++
28 2 files changed, 14 insertions(+)
29
30diff --git a/configure.ac b/configure.ac
31index deba90b..c1ed67b 100644
32--- a/configure.ac
33+++ b/configure.ac
34@@ -357,6 +357,15 @@ AM_COND_IF([ENABLE_PYTHON],
35 PKG_CHECK_MODULES([PYTHONDEV], [python3 >= 3.2],[],[AC_MSG_ERROR([You must install python3-dev])])
36 AC_DEFINE_UNQUOTED([ENABLE_PYTHON], 1, [Python3 is available])])
37
38+# Enable basenames in the logs for source files
39+AC_ARG_ENABLE([log-src-basename],
40+ [AC_HELP_STRING([--enable-log-src-basename], [Use the shorter source file basename in the logs [default=no]])],
41+ [], [enable_log_src_basename=no])
42+
43+if test "x$enable_log_src_basename" = "xyes"; then
44+ AC_DEFINE([LXC_LOG_USE_BASENAME], 1, [Enabling shorter src filenames in the logs])
45+fi
46+
47 # Enable dumping stack traces
48 AC_ARG_ENABLE([mutex-debugging],
49 [AC_HELP_STRING([--enable-mutex-debugging], [Makes mutexes to report error and provide stack trace [default=no]])],
50diff --git a/src/lxc/log.h b/src/lxc/log.h
51index 76bd4df..4365977 100644
52--- a/src/lxc/log.h
53+++ b/src/lxc/log.h
54@@ -74,8 +74,13 @@ struct lxc_log_locinfo {
55 int line;
56 };
57
58+#ifdef LXC_LOG_USE_BASENAME
59+#define LXC_LOG_LOCINFO_INIT \
60+ { .file = (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), .func = __func__, .line = __LINE__ }
61+#else
62 #define LXC_LOG_LOCINFO_INIT \
63 { .file = __FILE__, .func = __func__, .line = __LINE__ }
64+#endif
65
66 /* brief logging event object */
67 struct lxc_log_event {
68--
691.8.3.2
70
diff --git a/recipes-containers/lxc/lxc_1.1.3.bb b/recipes-containers/lxc/lxc_1.1.3.bb
index d1e80c46..e61aa6d0 100644
--- a/recipes-containers/lxc/lxc_1.1.3.bb
+++ b/recipes-containers/lxc/lxc_1.1.3.bb
@@ -33,6 +33,7 @@ SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \
33 file://lxc-busybox-add-OpenSSH-support.patch \ 33 file://lxc-busybox-add-OpenSSH-support.patch \
34 file://make-some-OpenSSH-tools-optional.patch \ 34 file://make-some-OpenSSH-tools-optional.patch \
35 file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \ 35 file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \
36 file://logs-optionally-use-base-filenames-to-report-src-fil.patch \
36 " 37 "
37 38
38SRC_URI[md5sum] = "197abb5a28ab0b689c737eb1951023fb" 39SRC_URI[md5sum] = "197abb5a28ab0b689c737eb1951023fb"
@@ -49,6 +50,8 @@ EXTRA_OECONF += "--with-init-script=\
49${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'sysvinit,', '', d)}\ 50${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'sysvinit,', '', d)}\
50${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}" 51${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
51 52
53EXTRA_OECONF += "--enable-log-src-basename"
54
52PACKAGECONFIG ??= "templates \ 55PACKAGECONFIG ??= "templates \
53 ${@base_contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \ 56 ${@base_contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \
54" 57"