Bug 1330183

Summary: TOTEM logging doesn't work if corosync is built out-of-tree
Product: Red Hat Enterprise Linux 7 Reporter: Christine Caulfield <ccaulfie>
Component: corosyncAssignee: Christine Caulfield <ccaulfie>
Status: CLOSED UPSTREAM QA Contact: cluster-qe <cluster-qe>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.3CC: ccaulfie, cluster-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-24 13:48:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Christine Caulfield 2016-04-25 14:42:59 UTC
Description of problem:
If corosync is built out-of-tree (using --srcdir to configure) then TOTEM logging doesn't print anything.

Version-Release number of selected component (if applicable):


How reproducible:
Every time

Steps to Reproduce:
1. configure corosync to build in a directory other than the source directory. eg:
   cd ..
   mkdir build
   cd build
   ../corosync/configure --srcdir==../corosync
2. build and install corosync
3. enable logging in corosync.conf eg DEBUG logging (easier to spot)
4. run corosync

Actual results:
All normal logging appears but there are no TOTEM messages

Expected results:
TOTEM messages should appear, as they do if corosync is built inside the source tree


Additional info:
This is caused by the source filenames (from __FILE__ at compilation time) having the configured path in them - in this example ../corosync/exec/totemudp.c etc. The list of totem source filenames passed to libqb loggin facility only has the basenames so the filenames never match up as libqb does an exact string match.

I looked into fixing this in libqb but it causes a regression. We can't simply basename() the __FILE__ as it's common also to use __FILE__ to generate the logging source, and using basename() on both removes the distinction between similarly named files from different directories which could be a requirement.

So I think this will need fixing in corosync. It's quite simple.

Comment 1 Christine Caulfield 2016-04-25 14:59:29 UTC
diff --git a/exec/main.c b/exec/main.c
index 0ca5634..5fe2c4a 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -939,7 +939,7 @@ _logsys_log_printf(int level, int subsys,
        va_list ap;
 
        va_start(ap, format);
-       qb_log_from_external_source_va(function_name, file_name,
+       qb_log_from_external_source_va(function_name, basename(file_name),
                                    format, level, file_line,
                                    subsys, ap);
        va_end(ap);

Comment 3 Christine Caulfield 2016-04-26 12:34:04 UTC
commit d245831d65d16f39ef2fb800c66233dfddf475e3
Author: Christine Caulfield <ccaulfie>
Date:   Tue Apr 26 09:49:53 2016 +0100

    logsys: fix TOTEM logging when corosync built out of tree

Comment 4 Christine Caulfield 2016-05-13 08:51:42 UTC
An improved patch for this:

commit 1e2de52ef18c86140892766e97e06e5bf005e5f7
Author: Christine Caulfield <ccaulfie>
Date:   Tue May 3 11:05:02 2016 +0100

    logging: Use our own version of basename
    
    basename() function has some potentially odd issues on
    other platforms.
    
    So, to be safe, here's an internal version.
    
    Signed-off-by: Christine Caulfield <ccaulfie>
    Reviewed-by: Jan Friesse <jfriesse>

Comment 5 Christine Caulfield 2016-05-24 13:48:17 UTC
Closing this 'UPSTREAM' as the patch is upstream and there is no point it in going into RHEL