Bug 1151409

Summary: libvirtd breaks if configuration file does not end with \n character
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: crobinso, eblake, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-26 19:32:06 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 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