Skip to content

Instantly share code, notes, and snippets.

@utkuozdemir
Created July 6, 2022 17:09
Show Gist options
  • Save utkuozdemir/d8bbb59789ef65112193c709dd1df99a to your computer and use it in GitHub Desktop.
Save utkuozdemir/d8bbb59789ef65112193c709dd1df99a to your computer and use it in GitHub Desktop.
Clear all KVM machines
#!/usr/bin/env bash
set -euo pipefail
virsh list --all | \
awk '{print $2}' | \
xargs -L1 -I {} virsh destroy {} || true
virsh list --all | \
awk '{print $2}' | \
xargs -L1 -I {} virsh undefine {} || true
virsh vol-list --pool default | \
awk '{ print $1 }' | \
xargs -L1 -I {} virsh vol-delete --pool default {} || true
virsh net-list | \
awk '{print $1}' | \
xargs -L1 -I {} virsh net-destroy {} || true
vagrant global-status --prune || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment