qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: leijian <leijian@sangfor.com.cn>
To: Eric Blake <eblake@redhat.com>, kwolf <kwolf@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>, stefanha <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [Snapshot Bug?]Qcow2 meta data corruption
Date: Wed, 8 Apr 2015 09:31:53 +0800	[thread overview]
Message-ID: <201504080931526094179@sangfor.com.cn> (raw)
In-Reply-To: 5523F756.7020306@redhat.com

[-- Attachment #1: Type: text/plain, Size: 2514 bytes --]

I created/deleted the snapshot by using qmp command "snapshot_blkdev_internal"/"snapshot_delete_blkdev_internal", and for avoiding the case you mentioned above, I have added the flock() permission in the qemu_open().

Here is the test of doing qemu-img snapshot to a running vm:
Diskfile:/sf/data/36c81f660e38b3b001b183da50b477d89_f8bc123b3e74/images/host-f8bc123b3e74/4a8d8728fcdc/Devried30030.vm/vm-disk-1.qcow2 is used! errno=Resource temporarily unavailable

Does the two cluster entry happen to be the same because of the refcount of using cluster decrease to 0 unexpectedly and  is allocated again?

If it was not accessing the image from more than one process, any other exceptions I can test for?

Thanks




leijian

From: Eric Blake
Date: 2015-04-07 23:27
To: Kevin Wolf; leijian
CC: qemu-devel; stefanha
Subject: Re: [Qemu-devel] [Snapshot Bug?]Qcow2 meta data corruption
On 04/07/2015 03:33 AM, Kevin Wolf wrote:
> More specifically, did you take care to never access your image from
> more than one process (except if both are read-only)? It happens
> occasionally that people use 'qemu-img snapshot' while the VM is
> running. This is wrong and can corrupt the image.

Since this has been done by more than one person, I'm wondering if there
is something we can do in the qcow2 format itself to make it harder for
the casual user to cause corruption.  Maybe if we declare some bit or
extension header for an image open for writing, which other readers can
use as a warning ("this image is being actively modified; reading it may
fail"), and other writers can use to deny access ("another process is
already modifying this image"), where a writer should set that bit
before writing anything else in the file, then clear it on exit.  Of
course, you'd need a way to override the bit to actively clear it to
recover from the case of a writer dying unexpectedly without resetting
it normally.  And it won't help the case of a reader opening the file
first, followed by a writer, where the reader could still get thrown off
track.

Or maybe we could document in the qcow2 format that all readers and
writers should attempt to obtain the appropriate flock() permissions [or
other appropriate advisory locking scheme] over the file header, so that
cooperating processes that both use advisory locking will know when the
file is in use by another process.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[-- Attachment #2: Type: text/html, Size: 6155 bytes --]

  reply	other threads:[~2015-04-08  1:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-03 10:04 [Qemu-devel] [Snapshot Bug?]Qcow2 meta data corruption leijian
2015-04-07  9:33 ` Kevin Wolf
2015-04-07 15:27   ` Eric Blake
2015-04-08  1:31     ` leijian [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-04-03  9:22 leijian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201504080931526094179@sangfor.com.cn \
    --to=leijian@sangfor.com.cn \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).