Bug 1151409 - libvirtd breaks if configuration file does not end with \n character
Summary: libvirtd breaks if configuration file does not end with \n character
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-10 10:32 UTC by Richard W.M. Jones
Modified: 2016-04-26 19:32 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-04-26 19:32:06 UTC
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2014-10-10 10:32:03 UTC
Description of problem:

Try this:

$ echo -n 'log_level=1' > ~/.config/libvirt/libvirtd.conf
$ libvirtd --timeout=10
2014-10-10 10:30:56.394+0000: 6626: info : libvirt version: 1.1.3.6, package: 1.fc20 (Fedora Project, 2014-09-08-17:50:42, buildvm-05.phx2.fedoraproject.org)
2014-10-10 10:30:56.394+0000: 6626: error : main:1261 : Can't load config file: configuration file syntax error: /home/rjones/.config/libvirt/libvirtd.conf:1: expecting a value: /home/rjones/.config/libvirt/libvirtd.conf

Note that libvirtd fails to start because of a trivial problem
(lack of \n) in the configuration file.

Using echo instead of echo -n "fixes" this, but libvirtd should
be tolerant of such errors in the configuration file.

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

libvirt-1.1.3.6-1.fc20.x86_64

How reproducible:

100%

Steps to Reproduce:
1. As above.

Comment 1 Eric Blake 2014-10-10 14:48:10 UTC
(In reply to Richard W.M. Jones from comment #0)
> Description of problem:
> 
> Try this:
> 
> $ echo -n 'log_level=1' > ~/.config/libvirt/libvirtd.conf

You DO know that 'echo -n' is non-portable, and that you should use 'printf' instead, right?

> Note that libvirtd fails to start because of a trivial problem
> (lack of \n) in the configuration file.

POSIX says that a non-empty file lacking a trailing newline is not a text file.  Configuration files should be text files.  That said, yeah, we should really be more tolerant of this situation.

Comment 2 Cole Robinson 2016-04-21 00:28:07 UTC
I sent a patch upstream:

http://www.redhat.com/archives/libvir-list/2016-April/msg01367.html

Comment 3 Cole Robinson 2016-04-26 19:32:06 UTC
Fixed upstream:

commit 3cc2a9e0d412776a07780b090cf286cc603cea84
Author: Cole Robinson <crobinso>
Date:   Wed Apr 20 20:25:31 2016 -0400

    virconf: Handle conf file without ending newline


Note You need to log in before you can comment on or make changes to this bug.