On 14. 08. 19 13:27, Peter Krempa wrote:
> On Tue, Aug 13, 2019 at 15:15:11 +0200, Petr Stodulka wrote:
>> Hi guys,
>> I had to move to the new laptop week ago and I screw migration of my virtual
>> machines. I recovered my virtual machines on the new laptop (virsh define)
>> using the backed up xml files, but I am missing any file with metadata about
>> snapshots. The original storage is cleaned so I cannot take these files
>> anymore.
>>
>> Using qemu-info I can see my snapshots inside the qcow images, but libvirt
>> doesn't know about them:
>> ###
>> # virsh snapshot-list rhlvm
>> Name Creation Time State
>> ---
>>
>> # qemu-img info rhlvm.qcow2
>> image: rhlvm.qcow2
>> file format: qcow2
>> virtual size: 25G (26843545600 bytes)
>> disk size: 2.9G
>> cluster_size: 65536
>> Snapshot list:
>> IDTAG VM SIZEDATE VM CLOCK
>> 1 prepared 0 2018-09-05 11:06:06 00:00:00.000
>> Format specific information:
>> compat: 1.1
>> lazy refcounts: true
>> refcount bits: 16
>> corrupt: false
>>
>>
>> ###
>>
>> Is there any nice way to regenerate snapshot metadata for libvirt from
>> the data inside qcow images? I have bunch of VMs so if there is nice way
>> how to recover those data, you will make me really happy :)
>
> Hi,
>
> libvirt unfortunately does not support metadata-less snapshots so you
> must recreate the metadata to be able to use them. If you didn't modify
> your configuration of the VM between the time you took the snapshot and
> the current point it should be fairly straightforward to recover them,
> but it will require some manual steps.
>
> The snapshot creation api has a _REDEFINE flag which allows to create
> the snapshot metadata without actually doing any disk changes. (virsh
> snapshot-create --redefine).
>
> For this to happen you must prepare a definition of the snapshot. I'll
> provide an example with anotations what to update:
>
>
> 1565701354 <--- this must be equal to the 'TAG' field in the
> qemu-img output
> running<--- state of the VM at snapshot, you'll probably
> need to use shutoff as the VM was not running
> 1565701354 <--- convert the "DATE" field to a
> unix timestamp
> <- your snapshot is internal so this is
> ok
>
> <--- entries here depend on your
> configuration, you need one line per disk, readonly disks must have 'no' as
> snapshot, others are internal
>
>
>
>
> <--- this is the domain definition XML obtained by
> running a virsh dumpxml --migratable --inactive --security-info
> upstream
> 841752b8-9452-4078-a62b-8fd9a9af011c
>
>[...] (trimmed irrelevant stuff but make sure to use full XML)
>
>
>
> /home/pipo/git/qemu.git/x86_64-softmmu/qemu-system-x86_64
>
>
>
>
>
>
>
>
>
> < these conform to the table
> above
>
>
>
> function='0x0'/>
>
>
>
>
>
> function='0x0'/>
>
>
>
>
>
> function='0x0'/>
>
>
>[...]
>
>
>
>
>
>
>
> Use a document which you create with:
>
> virsh snapshot-create $VMNAME --redefine --current
>
> Use --current only for the most recent snapshot.
>
Thanks! It works as you wrote. All my snapshots are recovered.
--
Petr Stodulka
Core Services (In-place upgrades and migrations)
Red Hat
___
libvirt-users mailing list
libvirt-users@redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-users