KVM – listing VMs with their memory allocation

i needed to list all VMs on given KVM server and sort them by amount of RAM allocated to each.

(for vm in $(virsh list --all --name|grep -v -e '^$'); do echo -n "$vm " ; virsh dumpxml "$vm" | grep "memory unit"|awk -F '(>|<)' '{print $3}';   done) | sort -k2 -n

ugly but does the trick.

Leave a Reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)