A note about error: “cannot delete inactive domain with snapshots”
You cannot delete a VM with snapshots. For example:# virsh undefine --domain openbsd
Sample outputs:
error: Failed to undefine domain openbsd error: Requested operation is not valid: cannot delete inactive domain with 2 snapshots
To list snapshots, enter:# virsh snapshot-list --domain VM_NAME
# virsh snapshot-list --domain openbsd
Sample outputs:
Name Creation Time State ------------------------------------------------------------ 3sep2016 2016-09-02 13:38:18 -0500 shutoff 3sep2016u1 2016-09-02 15:04:50 -0500 shutoff
The syntax is as follows to delete snapshot:# virsh snapshot-delete --domain VM_NAME --snapshotname SNAPSHOT_NAME
To delete both snapshots, enter:# virsh snapshot-delete --domain openbsd --snapshotname 3sep2016
Domain snapshot 3sep2016 deleted
# virsh snapshot-delete --domain openbsd --snapshotname 3sep2016u1
Domain snapshot 3sep2016u1 deleted
Verify it:# virsh snapshot-list --domain openbsd
Name Creation Time State
------------------------------------------------------------
Now delete the vm:# virsh undefine --domain openbsd
Domain openbsd has been undefined
# rm -f /nfswheel/kvm/openbsd.qcow2
参考文章:https://www.cyberciti.biz/faq/howto-linux-delete-a-running-vm-guest-on-kvm/