Virsh + Bash - fast see vm quest disk destination

1111111111Rating 0.00 (0 Votes)
I have many vm quests in my KVM servers. Today I inventory my VM from migate to other server and I need to view a list of virtual machine disks and their location, you can quiclky see by using bash:
for i in $(virsh list | awk '{print $2}'); do echo -e "$i\n$(virsh dumpxml $i | grep file=)"; done
And see result:

server1
<source file='/path/to/file/server1.img'/>
server2
<source file='/path/to/file/server2.img'/>
<source file='/path/to/file/CentOS-7.0-1406-x86_64-NetInstall.iso'/>
server3
<source file='/path/to/file/vms/server3-flat.img'/>
<source file='/path/to/file/en_windows_7_enterprise_with_sp1_x64_dvd_620201.iso'/>
<source file='/path/to/file/vms/server3-test-data.img'/>
...

 

Add comment


Refresh
Security code

Вверх
Вниз