Erwan Gallen
Erwan Gallen

Apr 7, 2018 1 min read

Libvirt snapshot delete cascade

thumbnail for this post

When you want to delete/undefine a VM with libvirt, you must clean all the snapshots. You can make a bash loop or just the “--children” parameter:

[erwan@host1 ~]# virsh snapshot-list compute18
 Name                 Creation Time             State
------------------------------------------------------------
 20180225-1-fedora-clean      2018-02-25 23:40:24 +0100 shutoff
 20180226-1-ansible-app       2018-02-26 00:16:01 +0100 shutoff
 20180304-1-ansible-app       2018-03-04 22:30:01 +0100 shutoff
 20180305-1-resync            2018-03-05 21:45:55 +0100 shutoff

[erwan@host1 ~]$ sudo virsh snapshot-delete --children compute18 20180225-1-fedora-clean
Domain snapshot 20180225-1-fedora-clean deleted

[erwan@host1 ~]$ sudo virsh snapshot-list compute18
 Name                 Creation Time             State
------------------------------------------------------------

Photo by Jakob Owens on Unsplash