Tuesday, July 7, 2015

virsh script to enumerate all disks

and this is useful.
 #!/bin/bash  
   
 for name in `virsh list --all | grep -i -e running -e shut |  
 awk '{ print $2 }'`  
   
 do  
  virsh dumpxml $name | grep -i -e "source file" -e "source dev" |  
  grep -v .iso |  
  sed -e 's/source file=//g' |  
  sed -e 's/source dev=//g' |  
  sed -e "s/'//g" |  
  sed -e "s/<//g" | sed -e "s/\/>//g" | while read -r result; do  
  echo $name $result  
  done  
 done  
   

No comments: