All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Prof. Dr. Michael Schefczyk" <michael@schefczyk.net>,
	Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] "File too large" error from "qemu-img snapshot" (was Re: AW: Bug Repoting Directions Request)
Date: Wed, 19 Nov 2014 11:13:27 -0700	[thread overview]
Message-ID: <546CDDC7.2070805@redhat.com> (raw)
In-Reply-To: <2A6E6B95B6E5C146ACE8440760E58185BDC32099@EXCHANGESERVER.schefczyk.local>

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

On 11/19/2014 10:32 AM, Prof. Dr. Michael Schefczyk wrote:
> Dear Eric, dear all,
> 
> Again, thank you very much. I now gather that I took the wrong path towards nightly backups of running VM. I remain surprised that I did work for a relatively long time.

[can you convince your mailer to wrap long lines?  also, we tend to
frown on top-posting on technical lists]

Yeah, you were just getting lucky that two different processes weren't
both trying to allocate a cluster for different purposes at the same
time.  When the collision finally did happen, it had catastrophic
results on your image.

> 
> A major book on KVM in German language by Kofler & Spenneberg recommends the following approach for online backups (with and without "--disk-only"):
> 
> virsh snapshot-create-as vm XXX --disk-only
> qemu-img convert -f qcow2 -s XXX -O qcow2 XXX.img /backup/YYY.img
> virsh snapshot-delete vm XXX

Yes, virsh is using QMP commands under the hood, so this method is safe.
 One slight issue is that this sequence is incomplete (it does not
shrink the backing file chain after the copy is complete), so if you
keep repeating it, you will eventually cause reduced performance when
you have a really long chain of multiple qcow2 overlays, or even cause
qemu to run into fd exhaustion.  Also, this command does not show that
unless you clean things up, then the second time you run this you do not
want to copy XXX.img into backup, but instead the qcow2 wrapper file
that was created by the first snapshot (and which itself wrapped by the
second snapshot).

With new enough libvirt and qemu, you can shrink the chain back down
with an active commit, as in:

virsh blockcommit vm XXX --verbose --active --pivot

Also, the use of --disk-only means that your disks have a snapshot taken
as if at a point in time when you yank the power cord; reverting to such
a backup may require fsck, and may suffer from other problems from
anything that was depending on I/O that had not yet been flushed to
disk.  If you add the --quiesce option (which implies that you set up
your guest to use qemu-guest-agent, and told libvirt to manage the
agent), then you can guarantee that your guest has flushed and frozen
all filesystems prior to the point in time where the snapshot is
created; and you can even install hooks in the guest to extend that
stability to things like databases.  Then your backups are much easier
to use.  If you omit --disk-only, and take a full snapshot, then you
have the guest memory state that is necessary to restore all pending
I/O, and don't need to worry about freezing the guest file systems; but
then you have to remember to back up the memory state in addition to
your disk state.

> 
> Would this be any better than my script, because it uses virsh snapshot-create-as instead of qemu-img snapshot? The second command is still qemu-img convert which may be problematical.

No, remember what I said.  qemu-img may not be used on any image that is
opened read-write by qemu, but is perfectly safe to do read-only
operations on any image that is opened read-only by qemu.  That sequence
of commands goes from the initial:

disk.img [read-write]

then the snapshot-create command causes libvirt to issue a QMP command
to switch qemu to:

disk.img [read-only] <- overlay.qcow2 [read-write]

at which point you can do anything read-only to disk.img (whether
'qemu-img convert' or 'cp' or any other command that doesn't alter the
contents of the file)

finally, the 'virsh blockcommit' command would take you back to:

disk.img [read-write]

> 
> The problem I am facing is that the documentation is not easy to understand for the average user/administrator who is not among the kvm developers and experts. I have of course tried to read section 14.2.3 of RHEL 7 Virtualization Deployment and Administration Guide on backups, but I found that too cryptic for someone like myself to draw practical consequences from it.

If you are using libvirt to manage your guests, then yes, the qemu
documentation is cryptic, but that shouldn't matter - you should be
asking the libvirt community how to accomplish a job.  And yes, libvirt
could probably do a better job of advertising and documenting its level
of support for live backups, but that is more a question for the
libvirt-users@redhat.com mailing list (the archive of that list show
that questions like this come up very regularly; you are not the first
to ask about live backups, so perusing those archives may give you some
ideas on what works).

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

  reply	other threads:[~2014-11-19 18:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19 10:36 Bug Repoting Directions Request Prof. Dr. Michael Schefczyk
2014-11-19 10:59 ` Paolo Bonzini
     [not found]   ` <2A6E6B95B6E5C146ACE8440760E58185BDC31C30@EXCHANGESERVER.schefczyk.local>
2014-11-19 11:41     ` [Qemu-devel] "File too large" error from "qemu-img snapshot" (was Re: AW: Bug Repoting Directions Request) Paolo Bonzini
2014-11-19 11:48       ` Prof. Dr. Michael Schefczyk
2014-11-19 11:53         ` Paolo Bonzini
2014-11-19 12:07           ` Prof. Dr. Michael Schefczyk
2014-11-19 14:54             ` Paolo Bonzini
2014-11-19 15:43               ` Eric Blake
2014-11-19 17:32                 ` Prof. Dr. Michael Schefczyk
2014-11-19 18:13                   ` Eric Blake [this message]
2014-11-22 17:02                     ` Prof. Dr. Michael Schefczyk
2014-11-24 11:52                       ` Paolo Bonzini
2014-11-25 11:34                       ` Kevin Wolf
2014-11-25 11:49                         ` Prof. Dr. Michael Schefczyk
2014-11-24 10:32                     ` Kashyap Chamarthy
2014-11-19 14:05       ` Max Reitz

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=546CDDC7.2070805@redhat.com \
    --to=eblake@redhat.com \
    --cc=michael@schefczyk.net \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.