Bug 1592644

Summary: The default log_outputs should be journald
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Fangge Jin <fjin>
Component: libvirtAssignee: Erik Skultety <eskultet>
Status: CLOSED CURRENTRELEASE QA Contact: Yanqiu Zhang <yanqzhan>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: jdenemar, lmen, xuzhang, yanqzhan
Target Milestone: rcKeywords: TestOnly
Target Release: 8.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-5.0.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-11 22:29:07 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:
Embargoed:

Description Fangge Jin 2018-06-19 03:40:05 UTC
Description of problem:
The default log_outputs should be syslog

Version-Release number of selected component (if applicable):
libvirt-4.4.0-2.virtcov.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Start libvirtd with default configuration

2.Check log outputs by virt-admin:
# virt-admin daemon-log-outputs 
 Logging outputs: 3:stderr

3.Confirm that journal socket exists:
# file /run/systemd/journal/socket
/run/systemd/journal/socket: socket

Actual results:
The default log output is stderr

Expected results:
The default log output should be syslog

Additional info:

Comment 2 Erik Skultety 2019-01-08 09:05:36 UTC
Fixed upstream by:
commit 30727583aed2e4655985916556418d8e44c5d2a9
Refs: v4.10.0-152-g30727583ae
Author:     Erik Skultety <eskultet>
AuthorDate: Thu Jan 3 14:32:36 2019 +0100
Commit:     Erik Skultety <eskultet>
CommitDate: Tue Jan 8 10:01:54 2019 +0100

    util: Fix the default log output to 'journald' when running under systemd

    Essentially, bring back the old behaviour as of commit eba36a38 which
    was later changed by commit ae06048bf5d. Even though all the stderr
    messages will eventually end up in the journal, we're not making use of
    the fields journald provides.

    https://bugzilla.redhat.com/show_bug.cgi?id=1592644

    Signed-off-by: Erik Skultety <eskultet>
    Acked-by: Michal Privoznik <mprivozn>

Comment 4 Yanqiu Zhang 2019-07-10 09:04:14 UTC
Verify this bug with:
libvirt-daemon-5.0.0-11.module+el8.0.1+3459+e357ef2f.x86_64
qemu-kvm-3.1.0-27.module+el8.0.1+3253+c5371cb3.x86_64

Steps:
1. godaemon, have_journald:
#  ls /run/systemd/journal/socket
/run/systemd/journal/socket

# systemctl restart libvirtd

# virt-admin daemon-log-outputs 
 Logging outputs: 3:journald

Can see 'journal' warn+error log msgs in syslog:
# cat /var/log/messages|grep journal
Jul 10 04:24:51 lenovo-*** journal[9322]: libvirt version: 5.0.0, package: 11.module+el8.0.1+3459+e357ef2f (Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>, 2019-06-21-11:49:46, )
Jul 10 04:24:51 lenovo-*** journal[9322]: hostname: lenovo-***
Jul 10 04:24:51 lenovo-*** journal[9322]: Ignoring incomplete managed state /var/lib/libvirt/qemu/save/yqz-7.7.save
Jul 10 04:24:51 lenovo-*** journal[9322]: Cannot access storage file '/s3-qe-team/yanqzhan/V-7.7.qcow2' (as uid:107, gid:107): No such file or directory

2. godaemon, !have_journald:
#  ls /run/systemd/journal/socket
ls: cannot access '/run/systemd/journal/socket': No such file or directory

# systemctl restart libvirtd

# virt-admin daemon-log-outputs 
 Logging outputs: 3:stderr

Can see 'libvirtd' warn+error log msgs in syslog came from stderr:
# tail -f /var/log/messages|grep libvirtd
Jul 10 03:28:21 lenovo-*** libvirtd[10327]: 2019-07-10 07:28:21.116+0000: 10331: info : libvirt version: 5.0.0, package: 11.module+el8.0.1+3459+e357ef2f (Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>, 2019-06-21-11:49:46, )
Jul 10 03:28:21 lenovo-*** libvirtd[10327]: 2019-07-10 07:28:21.116+0000: 10331: info : hostname: lenovo-***
Jul 10 03:28:21 lenovo-*** libvirtd[10327]: 2019-07-10 07:28:21.116+0000: 10331: error : virStorageFileReportBrokenChain:4770 : Cannot access storage file '/s3-qe-team/yanqzhan/V-7.7.qcow2' (as uid:107, gid:107): No such file or directory
Jul 10 03:28:56 lenovo-*** libvirtd[10327]: 2019-07-10 07:28:56.513+0000: 10329: warning : qemuDomainObjStart:7566 : Ignoring incomplete managed state /var/lib/libvirt/qemu/save/avocado-vt-vm1.save

3.!godaemon, !isatty(STDIN_FILENO) && have_journald:
# ls /run/systemd/journal/socket
/run/systemd/journal/socket

# nohup libvirtd
nohup: ignoring input and appending output to 'nohup.out'

# virt-admin daemon-log-outputs 
 Logging outputs: 3:journald

Can see no stderr msg in nohup.out, and 'journal' warn+error log msgs are in syslog.
# cat /root/nohup.out 
# 
# tail -f /var/log/messages|grep journal
Jul 10 04:27:14 lenovo-*** journal[9555]: libvirt version: 5.0.0, package: 11.module+el8.0.1+3459+e357ef2f (Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>, 2019-06-21-11:49:46, )
Jul 10 04:27:14 lenovo-*** journal[9555]: hostname: lenovo-***
Jul 10 04:27:14 lenovo-*** journal[9555]: Ignoring incomplete managed state /var/lib/libvirt/qemu/save/yqz-7.7.save
Jul 10 04:27:14 lenovo-*** journal[9555]: Cannot access storage file '/s3-qe-team/yanqzhan/V-7.7.qcow2' (as uid:107, gid:107): No such file or directory

4. !godaemon, isatty(STDIN_FILENO):
# ls /run/systemd/journal/socket
/run/systemd/journal/socket

# libvirtd

# virt-admin daemon-log-outputs 
 Logging outputs: 3:stderr

Can see warn+error log msgs are in stderr under 'libvirtd' cmd:
# libvirtd
2019-07-10 08:08:17.287+0000: 8842: info : libvirt version: 5.0.0, package: 11.module+el8.0.1+3459+e357ef2f (Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>, 2019-06-21-11:49:46, )
2019-07-10 08:08:17.287+0000: 8842: info : hostname: lenovo-***
2019-07-10 08:08:17.287+0000: 8842: warning : qemuDomainObjStart:7566 : Ignoring incomplete managed state /var/lib/libvirt/qemu/save/yqz-7.7.save
2019-07-10 08:08:17.449+0000: 8842: error : virStorageFileReportBrokenChain:4770 : Cannot access storage file '/s3-qe-team/yanqzhan/V-7.7.qcow2' (as uid:107, gid:107): No such file or directory

5.!godaemon,!have_journald:
# ls /run/systemd/journal/socket
ls: cannot access '/run/systemd/journal/socket': No such file or directory

# nohup libvirtd
nohup: ignoring input and appending output to 'nohup.out'

# virt-admin daemon-log-outputs 
 Logging outputs: 3:stderr

Can see warn+error log msgs are in stderr redirected in nohup.out:
# tail -f /root/nohup.out 
2019-07-10 07:37:52.766+0000: 11290: info : libvirt version: 5.0.0, package: 11.module+el8.0.1+3459+e357ef2f (Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>, 2019-06-21-11:49:46, )
2019-07-10 07:37:52.766+0000: 11290: info : hostname: lenovo-***
2019-07-10 07:37:52.766+0000: 11290: warning : qemuDomainObjStart:7566 : Ignoring incomplete managed state /var/lib/libvirt/qemu/save/yqz-7.7.save
2019-07-10 07:37:52.816+0000: 11290: error : virStorageFileReportBrokenChain:4770 : Cannot access storage file '/s3-qe-team/yanqzhan/V-7.7.qcow2' (as uid:107, gid:107): No such file or directory

Since all the results are as expected, mark this bug as verified.

Comment 5 Jeff Nelson 2020-03-11 22:29:07 UTC
This work was completed and shipped long ago. Closing the bug.