Andrew Martin
2014-May-22 22:31 UTC
[libvirt-users] Live snapshots of a single block device
Hello, I am working on a script to automatically create live snapshots of running VMs using qemu-kvm 1.4.0 and libvirt 1.0.2. If a VM has multiple disks, I'd like to back them up individually with separate calls to snapshot-create-as, so I can more easily manage the disk images. The code I have now is essentially as follows: virsh snapshot-create-as --domain "vmname" --name "snapshotname" --description "snapshot description" --disk-only --atomic --no-metadata --diskspec "vda" I run this command for each block device (e.g vda, vdb, etc). However, after running the above command (to only backup vda), I see that a snapshot has also been created for vdb. I tried running it with --print-xml, which gives this output: <domainsnapshot> <name>05-22-14_17-09-25</name> <description>05-22-14_17-09-25</description> <disks> <disk name='vda'/> </disks> </domainsnapshot> What am I doing wrong - how can I tell snapshot-create-as to create an external snapshot for a specific block device only (not all block devices)? Also, while looking at the manpage, does the --live option do anything different if used with the above command? Thanks, Andrew Martin
Eric Blake
2014-May-22 22:44 UTC
Re: [libvirt-users] Live snapshots of a single block device
On 05/22/2014 04:31 PM, Andrew Martin wrote:> Hello, >[Can you convince your mailer to wrap long lines?]> I am working on a script to automatically create live snapshots of > running VMs using qemu-kvm 1.4.0 and libvirt 1.0.2. If a VM hasAny reason you aren't upgrading to newer versions? Although these seem sufficient for what you are trying.> multiple disks, I'd like to back them up individually with separate > calls to snapshot-create-as, so I can more easily manage the disk > images. The code I have now is essentially as follows:> virsh snapshot-create-as --domain "vmname" --name "snapshotname" --description "snapshot description" --disk-only --atomic --no-metadata --diskspec "vda" > > I run this command for each block device (e.g vda, vdb, etc). However, after running the above command (to only backup vda), I see that a snapshot has also been created for vdb. I tried running it with --print-xml, which gives this output: > <domainsnapshot> > <name>05-22-14_17-09-25</name> > <description>05-22-14_17-09-25</description> > <disks> > <disk name='vda'/> > </disks>The problem you are facing is that the snapshot code MUST have an action for every disk; and if you don't specify the action directly in your <domainsnapshot> xml, then the action chosen is inherited from the <domain> xml (if you used <disk snapshot='no'>) or ultimately from the type of snapshot you are creating (here, since you didn't use <disk snapshot='no'> in the domain xml, and didn't specify vdb in the <domainsnapshot>, libvirt assumes from --disk-only that you want vdb to have an external snapshot taken).> </domainsnapshot> > > What am I doing wrong - how can I tell snapshot-create-as to create an external snapshot for a specific block device only (not all block devices)?Use: --diskspec vda --diskspec vdb,snapshot=no which produces this subset of xml: <disks> <disk name='vda'/> <disk name='vdb' snapshot='no'/> </disks>> > Also, while looking at the manpage, does the --live option do anything different if used with the above command?--live only makes sense when mixed with memory snapshots (with --memspec); but as you are doing a --disk-only snapshot, it doesn't help (I'm not sure if it will error out as mutually exclusive or just be silently ignored, without reading the code). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Andrew Martin
2014-May-23 14:41 UTC
Re: [libvirt-users] Live snapshots of a single block device
----- Original Message -----> From: "Eric Blake" <eblake@redhat.com> To: "Andrew Martin" > <amartin@xes-inc.com>, libvirt-users@redhat.com Sent: Thursday, May 22, 2014 > 5:44:54 PM Subject: Re: [libvirt-users] Live snapshots of a single block > device > > On 05/22/2014 04:31 PM, Andrew Martin wrote: > > Hello, > > > > [Can you convince your mailer to wrap long lines?]Sorry, my client won't auto-wrap and I forgot to run my post through vim before sending. Will do now :)> > > I am working on a script to automatically create live snapshots of running > > VMs using qemu-kvm 1.4.0 and libvirt 1.0.2. If a VM has > > Any reason you aren't upgrading to newer versions? Although these seem > sufficient for what you are trying.The VM hosts I'm using all run Ubuntu 12.04 and I haven't had time to backport and test newer versions yet. I've published the latest versions I built in this PPA: https://launchpad.net/~xespackages/+archive/virtualization The main functionality I need is live snapshotting with snapshot-create-as and blockpull, so I haven't had a good reason to invest time to upgrade.> > The problem you are facing is that the snapshot code MUST have an action for > every disk; and if you don't specify the action directly in your > <domainsnapshot> xml, then the action chosen is inherited from the <domain> > xml (if you used <disk snapshot='no'>) or ultimately from the type of snapshot > you are creating (here, since you didn't use <disk snapshot='no'> in the> domain xml, and didn't specify vdb in the <domainsnapshot>, libvirt > assumes from --disk-only that you want vdb to have an external > snapshot taken).> > > </domainsnapshot> > > > > What am I doing wrong - how can I tell snapshot-create-as to create an > > external snapshot for a specific block device only (not all block devices)? > > Use: --diskspec vda --diskspec vdb,snapshot=no > > which produces this subset of xml: > > <disks> <disk name='vda'/> <disk name='vdb' snapshot='no'/> </disks> >Ah, that makes sense, thanks so much for clearing this up!> > > > Also, while looking at the manpage, does the --live option do anything > > different if used with the above command? > > --live only makes sense when mixed with memory snapshots (with --memspec); but > as you are doing a --disk-only snapshot, it doesn't help (I'm not sure if it > will error out as mutually exclusive or just be silently ignored, > without reading the code).I'm using this code in a script for creating live backups of VMs - would it make sense to include --memspec to capture the memory state so that an fsck on boot isn't necessary? I remember you explained --quiese awhile back: https://www.redhat.com/archives/libvirt-users/2013-February/msg00020.html However I don't have qemu-guest-agent installed on the guests, so would using --memspec instead of --disk-only produce a snapshot that is consistent (since it would "resume" with the same memory state) or would this not be ideal for backups (e.g easy to restore/recover)? Can the memory image be written to the same image file (qcow2) as the disk snapshot? Thanks, Andrew
Maybe Matching Threads
- Re: Live snapshots of a single block device
- About libvirt domain snapshot problem(for single disk snapshot)
- Re: Live snapshots of a single block device
- Re: Help with understanding and solving snapshot problem
- Re: snapshot-create-as for a single disk not all disks