Bug 1297424 - Add warning about running qemu-img on active VMs to its manpage
Add warning about running qemu-img on active VMs to its manpage
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
6.7
Unspecified Linux
high Severity high
: rc
: ---
Assigned To: Kevin Wolf
Virtualization Bugs
Jiri Herrmann
:
Depends On:
Blocks: 1277167
  Show dependency treegraph
 
Reported: 2016-01-11 08:34 EST by Ademar Reis
Modified: 2016-05-10 17:02 EDT (History)
13 users (show)

See Also:
Fixed In Version: qemu-kvm-0.12.1.2-2.484.el6
Doc Type: Known Issue
Doc Text:
Using qemu-img to modify an image that is in use can corrupt the image Opening a QEMU disk image from multiple processes at the same time, for example by attempting to take a snapshot of a QEMU image while the guest is running, in some cases corrupts the image. To avoid this problem, never use the qemu-img utility to modify images in use by a running virtual machine or any other process. In addition, be aware that querying an image that is being modified by another process may trigger an inconsistent state error. This update also adds an admonition about the mentioned problem to the qemu-img(1) man page.
Story Points: ---
Clone Of: 1277167
Environment:
Last Closed: 2016-05-10 17:02:31 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ademar Reis 2016-01-11 08:34:16 EST
This should be a backport of 

commit 48467328c6dccc9c7be6628ed0ef0810f83be2a9
Author: Kevin Wolf <kwolf@redhat.com>
Date:   Thu Aug 16 10:56:35 2012 +0200

    Documentation: Warn against qemu-img on active image
    
    People have repeatedly expected that you can do things like snapshotting
    an image with qemu-img while a qemu instance is running. Maybe we need
    to consider locking the files while they are in use, but having a
    warning in the qemu-img manpage is doable for 1.2 and can't hurt anyway.
    
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>


+++ This bug was initially created as a clone of Bug #1277167 +++

--- Additional comment from Ademar Reis on 2016-01-11 11:29:58 BRST ---

(In reply to Frank DeLorey from comment #0)
> 
> Before this problem happened, customer took a snapshot when the vm was
> running:
> 
> # /usr/bin/qemu-img snapshot -c snapshot-test-20151019
> /var/lib/libvirt/images/kpd-dbw.qcow2
> 
> When trying to delete the snapshot, customer sees the same error message.
> 
> # /usr/bin/qemu-img snapshot -l /var/lib/libvirt/images/kpd-dbw.qcow2
> Could not open '/var/lib/libvirt/images/kpd-dbw.qcow2': File too large
> 
> # /usr/bin/qemu-img snapshot -d snapshot-test-20151029
> /var/lib/libvirt/images/kpd-dbw.qcow2
> Could not open '/var/lib/libvirt/images/kpd-dbw.qcow2': File too large
> 

This will lead to image corruption for sure, so this is expected. One should never use qemu-img snapshot on a running VM. You can see a more complete explanation in the upstream bug you've mentioned (https://bugs.launchpad.net/qemu/+bug/1354167/comments/12):

"[...] it turned out that qemu-img snapshot was used on the image while the VM is running. This was likely the root cause of the corruption. So if you're reading this, it's probably already too late, but I want to spell it out anyway:

WARNING: Never open the same disk image from two processes at the same time, except if both are read-only! If your VM is running, use the qemu monitor of that VM (or libvirt functionality, which will do the same internally) to do operations on the image. Use qemu-img only for images of shut down VMs."

If the customer followed some of our documentation when doing it, then it should be fixed. There are recent and recurrent upstream discussions about adding some sort of locking to qemu and qemu-img, but there's no consensus, as this would add complexity and require cleanups in case of crashes.

You can see more details about a recent discussion here:
https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg04279.html

Anyway, we should at least backport to RHEL6 the warning which was added to qemu-img's manpage back in 2012. I'll open a new BZ to track that.
Comment 1 Jeff Nelson 2016-01-18 16:52:00 EST
Fix included in qemu-kvm-0.12.1.2-2.484.el6
Comment 3 Qianqian Zhu 2016-01-27 03:45:52 EST
Verified with:
qemu-kvm-0.12.1.2-2.484.el6.x86_64
qemu-img-0.12.1.2-2.484.el6.x86_64

Warning added to manpage in DESCRIPTION part.

# man qemu-img
QEMU-IMG(1)                                                        QEMU-IMG(1)

NAME
       qemu-img - QEMU disk image utility

SYNOPSIS
       usage: qemu-img command [command options]

DESCRIPTION
       qemu-img allows you to create, convert and modify images offline. It can handle all image formats supported by QEMU.

       Warning: Never use qemu-img to modify images in use by a running virtual machine or any other process; this may destroy the
       image. Also, be aware that querying an image that is being modified by another process may encounter inconsistent state.
Comment 6 errata-xmlrpc 2016-05-10 17:02:31 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-0815.html

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