Bug 489946 - libvirt does not do safe replacement of guest/storage pool/network config files
Summary: libvirt does not do safe replacement of guest/storage pool/network config files
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Daniel Veillard
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-03-12 16:32 UTC by Daniel Berrangé
Modified: 2012-03-30 20:53 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-03-30 20:53:25 UTC
Embargoed:


Attachments (Terms of Use)

Description Daniel Berrangé 2009-03-12 16:32:41 UTC
Description of problem:
When defining a new guest/storage pool/network config file, libvirt simply opens the config file, truncating existing content and then writes the new one. This is not safe against a wide variety of errors. If the write() or close() step fails, the user is potentially left with a zero length config file. If host crashes, the new config may not have been flushed to disk again leaving a zero length file, or corrupted file. It needs to implement a much more robust method for writing out new config files. 

cf this preso for guide on how to write safely http://www.flamingspork.com/talks/2007/06/eat_my_data.odp


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

How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Bug Zapper 2009-06-09 12:10:47 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 2 Eric Blake 2012-03-30 20:53:25 UTC
Fixed in 0.9.7 with:
commit 559644ddd2fd7065220331d11197bf54f6484231
Author: Jiri Denemark <jdenemar>
Date:   Thu Oct 13 12:17:12 2011 +0200

    Introduce virFileRewrite for safe file rewrite
    
    When saving config files we just overwrite old content of the file. In
    case something fails during that process (e.g. disk gets full) we lose
    both old and new content. This patch makes the process more robust by
    writing the new content into a separate file and only if that succeeds
    the original file is atomically replaced with the new one.


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