[libvirt-users] [libvirt] vm live storage migration with snapshots

Eric Blake eblake at redhat.com
Wed Feb 11 23:09:24 UTC 2015


[dropping multiple lists; let's just use libvirt-users]

On 02/11/2015 02:45 PM, Edward Young wrote:

> I perform a simple test, but failed.
> 
> In the source, I create:   base <- mid <- active (2 snapshots, the active
> one is the current one)
> In order to migrate this vm to the destination, I manually copy both base
> and mid to the destination, and put them in the sam e directory
> /var/lib/libvirt/images/
> Then I call the following commands:
> 'sudo virsh migrate --live --unsafe --verbose --copy-storage-inc vm1
> qemu+ssh://192.168.1.3/system tcp://192.168.1.3'
> 
> The error I got is:
> error: Requested operation is not valid: cannot migrate domain with 2
> snapshots.
> 
> I do not know the reason for this.

That's because libvirt is not (yet) able to migrate snapshots in a way
that the destination can revert to them.  It is possible to work around
this in a couple of ways:

1. Manually dump all the snapshot XML configurations on the source side
(virsh snapshot-list, then virsh snapshot-dumpxml in a loop), then
delete the snapshot tracking (virsh snapshot-delete --metadata in a
loop), then do the migration, then manually recreate the snapshot
configuration on the destination (virsh snapshot-create --redefine in a
loop for each of the xml files you saved earlier).

If you don't plan to revert to snapshots on the destination, then you
can skip the snapshot-dumpxml loop, as well as the snapshot-create
--redefine loop.  But if that's the case, then you can take a shortcut:

2. Don't track external snapshot data in libvirt in the first place
(virsh snapshot-create --no-metadata when taking external snapshots).
Instead, the backing chain is sufficient to know that external snapshot
data was saved.

> 
> 
>> In fact, modern
>> libvirt/qemu does this for you by setting up an NBD server on the
>> destination, doing a data mirror from the source into the destination
>> (so that you DO have shared storage, at least for the duration of the
>> migration), then doing the live migration, then tearing down the NBD
>> mirroring link.
>>
> 
> Sounds interesting! Can you provide me an example or point me to a link
> about how to use this function?

It's all done under the hood as part of the implementation of 'virsh
migrate --copy-source-*', if done as part of migration.  But if you want
to manually recreate the steps, the source code in
src/qemu/qemu_migration.c shows the QMP commands used to set up the NBD
server on the destination, then the mirroring is done with equivalent of
the 'virsh blockcopy' command pointing to the NBD server as the destination.

> 
> Sorry to take you so much time to answer my questions. I appreciate it
> deeply. After I solve this issue, I will write a blog and share these
> knowledge with other people.

The libvirt-users list archives has a lot of questions and posts from
other users on the same topic; it may also help if you peruse the archives.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20150211/a9627b59/attachment.sig>


More information about the libvirt-users mailing list