Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-24965

deleting volume after a snapshot breaks VM, can't be cleaned up any more

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • rhel-9.4
    • libvirt
    • None
    • None
    • rhel-sst-virtualization
    • ssg_virtualization
    • 5
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • None

      This is the CLI version of https://issues.redhat.com/browse/RHEL-24797.

      What were you trying to do that didn't work?

      Deleting a storage volume on a domain with snapshots.

      Please provide the package NVR for which bug is seen:

      libvirt-daemon-9.10.0-1.el9.x86_64

      How reproducible:

      Always

      Steps to reproduce

      Create a VM, attach a disk, snapshot it, detach the disk again, and delete it:

      virt-install --memory 50 --pxe --virt-type qemu --os-variant alpinelinux3.8 --wait 0 --name test1
      virsh vol-create-as default attic --capacity 100M
      virsh attach-disk test1 /var/lib/libvirt/images/attic vdb
      virsh snapshot-create-as test1 --name test1snap1 --memspec /var/lib/libvirt/images/test1-snap1-mem
      virsh detach-disk --live test1 vdb
      sleep 5
      virsh vol-delete attic --pool default
      

      Actual results

      This is a bad situation: You can't revert the snapshot or delete it because the image is gone:

      # virsh snapshot-revert test1 test1snap1
      error: Failed to revert snapshot test1snap1
      error: unsupported configuration: source for disk 'vdb' is not a regular file; refusing to generate external snapshot name
      
      # virsh snapshot-delete test1 test1snap1
      error: Failed to delete snapshot test1snap1
      error: invalid argument: disk 'vdb' not found in domain
      

      But you also can't delete the VM as there is an existing snapshot:

      # virsh destroy test1
      error: Failed to destroy domain 'test1'
      error: Requested operation is not valid: domain is not running
      
      # virsh undefine test1
      error: Failed to undefine domain 'test1'
      error: Requested operation is not valid: cannot delete inactive domain with 1 snapshots
      

      So there's no way to clean this up.

      Expected results

      Libvirt seems to make backups/copies of storage volumes during snapshots, e.g. it copies/renames my /var/lib/libvirt/images/attic to /var/lib/libvirt/images/attic.1707479237 .

      If that is meant to work, then both snapshot-revert and snapshot-delete should succeed and restore the volume.

      If it isn't supported, then virsh vol-delete attic should fail with something like "this volume is referenced in snapshot test1snap1".

              phrdina@redhat.com Pavel Hrdina
              rhn-engineering-mpitt Martin Pitt
              Pavel Hrdina
              Pavel Hrdina Pavel Hrdina
              Meina Li Meina Li
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated: