qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] "File too large" error from "qemu-img snapshot" (was Re


From: Kashyap Chamarthy
Subject: Re: [Qemu-devel] "File too large" error from "qemu-img snapshot" (was Re: AW: Bug Repoting Directions Request)
Date: Mon, 24 Nov 2014 11:32:25 +0100
User-agent: Mutt/1.5.22.1 (2013-10-16)

On Wed, Nov 19, 2014 at 11:13:27AM -0700, Eric Blake wrote:
> On 11/19/2014 10:32 AM, Prof. Dr. Michael Schefczyk wrote:

[. . .]

> > 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 address@hidden 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).

As an addendum to Eric's detailed notes above, below are some examples
for live disk backups and shortening disk image chains with libvirt's
'blockcommit '.

Applicable for: QEMU 2.1, libvirt-1.2.9 or newer.

Efficient live disk backup with active blockcommit: 

    http://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit

Merge an entire chain (including current active image) into its base
image:

    
http://wiki.libvirt.org/page/Live-merge-an-entire-disk-image-chain-including-current-active-disk
 

-- 
/kashyap



reply via email to

[Prev in Thread] Current Thread [Next in Thread]