Libvirt Snapshot Question

Elias Mobery eliasmobery at gmail.com
Thu Dec 2 15:27:00 UTC 2021


OK, so I tried both ways. (The VM image is in the read-only squashfs.)

1.) Editing VM domain XML:
    <disk>

    <transient/>
    </disk>

Error:  Internal Error - Could not open
/var/lib/libvirt/images/vm.snapshot1 : Permission Denied

I chowned everything to libvirt but no changes. Maybe a read-only conflict?

2.) Adding second disk to VM domain XML
(shortened )

 <disk>
    source /var/lib..../images/vm.qcow2
    target dev=vda
 </disk>


 <disk>
     source /var/lib...../images/vm.qcow2
     target dev=vdb
    <transient/>
 </disk>

Error: unsupported configuration: cannot create external snapshot for disk
vdb - collision with disk vdb.

After googling I found that a lot of people get permission denied errors
using transient. I will keep looking, really not sure.

On Thu, Dec 2, 2021, 9:30 AM Peter Krempa <pkrempa at redhat.com> wrote:

> On Wed, Dec 01, 2021 at 18:35:44 +0100, Elias Mobery wrote:
> > Hey man, I tried both suggestions, thanks again.
> >
> > Option 1.) Create/attach a second qcow2 disk & unplug when wiping.
> > This did not work unfortunately. After wiping the overlay filesystem on
> the
> > host (where the snapshots are sitting), I cannot create another
> snapshot, a
> > similar error message like before appears.
>
> Okay, that's weird. Could you please post your exact steps?
>
> Additionally if you have a new enough libvirt you can actually possibly
> even try using a disk with <transient/>. This transparently creates a
> overlay (in the same path as the image though, not sure if it suits your
> setup) and automatically discards it when unplugging or shutting down
> the VM.
>
> In such case you could simply unplug and replug the disk, but note that
> this feature was implemented only this year IIRC, so you need a fairly
> recent libvirt to do so.
>
> >
> > Option 2.) Enabling Discard
> >
> > Now I think this worked, but I'm not sure. I read all the docs, and
> enabled
> > discard like so on the VM domain:
> >
> > <driver name='qemu' type='qcow2' discard='unmap'>
>
> This is the correct setting. Unmap means that the qcow2 image should
> unmap the blocks which were discarded.
>
> >
> > I tried both discard=unmap and discard=on (same thing)
> >
> > Then I enabled fstrim in the guest like this:
> > (Not entirely sure if I am missing smth)
> >
> > sudo fstrim -av
> >
> > Or permanently
> >
> > sudo systemctl enable --now fstrim.timer
>
> Yup, both should do fine. Now if you delete something in the VM (which
> would result in freeing blocks in the overlay; deleting something from
> the base image won't help obviously) the overlay image should shrink.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20211202/3f7885ee/attachment.htm>


More information about the libvirt-users mailing list