How to solve:

```bash
virsh snapshot-delete LineageOS_trust My_snapshot
```
```
error: Failed to delete snapshot My_snapshot
error: internal error: unable to execute QEMU command 'block-dirty-bitmap-remove': Dirty bitmap 'libvirt-tmp-activewrite' not found
```

?
Jul 12, 9:46pm

The error you're encountering:

text
error: Failed to delete snapshot My_snapshot
error: internal error: unable to execute QEMU command 'block-dirty-bitmap-remove': Dirty bitmap 'libvirt-tmp-activewrite' not found

means that libvirt is trying to remove a dirty bitmap (a QEMU feature used for tracking disk changes) associated with the snapshot, but the bitmap named libvirt-tmp-activewrite no longer exists in QEMU. This is a common issue when snapshots are not cleaned up properly, or when QEMU or libvirt was restarted or crashed.


How to Fix It

1. Try Deleting the Snapshot with --metadata Only

Sometimes, the snapshot metadata exists in libvirt, but the actual QEMU bitmap is missing. You can try deleting only the metadata:

bash
virsh snapshot-delete LineageOS_trust My_snapshot --metadata

This removes the snapshot reference from libvirt without touching QEMU.


2. Manually Remove the Snapshot Metadata

If the above fails, you can manually edit the domain's XML to remove the snapshot metadata.

Steps:

  1. Dump the domain XML:
    bash
    virsh dumpxml LineageOS_trust > lineageos_trust.xml
  2. Open the XML file and look for the <snapshot> section corresponding to My_snapshot.
  3. Delete the entire <snapshot> block for My_snapshot.
  4. Define the domain again:
    bash
    virsh define lineageos_trust.xml

3. Use virsh snapshot-list to Confirm

Check if the snapshot still appears:

bash
virsh snapshot-list LineageOS_trust

If it's gone, the issue is resolved.


4. If the Snapshot Still Exists in QEMU

If the snapshot is still present in QEMU (e.g., as a disk image), you may need to manually remove it using qemu-img or by editing the disk file directly. However, this is advanced and risky—only do this if you're comfortable with QEMU internals.


5. Restart libvirtd (Last Resort)

If the issue persists, try restarting the libvirt daemon:

bash
sudo systemctl restart libvirtd

Then retry the snapshot deletion.


Preventing This in the Future

  • Always shut down the VM before deleting snapshots.
  • Avoid hard reboots of the host while VMs are running.
  • Use --metadata if you only want to remove the snapshot reference.

Question: Have you tried the --metadata flag yet, or do you need help with the XML editing step?

Jul 12, 9:46pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more