0

I have multiple (KVM) VM's being managed under virsh in different servers (ubuntu precise and up). I need to check if any of those have qcow disks attached non persistently.

Was hoping for something like this to help me out:

virsh domblklist domain --details

Is there something similar that can provide information on the storage attachment method?

edit: (not 100% sure) I could do an xml dump and then grep for the contents of the aforementioned command for each VM. If I cannot find the content in the domain's xml then I could assume that it is set as non persistent.. I dislike this method and would like to avoid it.

1 Answers1

0

You can try with virsh domblklist domain --inactive --details

From virsh man page:

domblklist domain [--inactive] [--details] Print a table showing the brief information of all block devices associated with domain. If --inactive is specified, query the block devices that will be used on the next boot, rather than those currently in use by a running domain. If --details is specified, disk type and device value will also be printed. Other contexts that require a block device name (such as domblkinfo or snapshot-create for disk snapshots) will accept either target or unique source names printed by this command.

shodanshok
  • 47,711
  • 7
  • 111
  • 180
  • I ended up doing this: `for vm in \`virsh list | tail -n +3 | awk '{ print $2}'\`; do echo $vm; vcompare1=$(virsh domblklist $vm --inactive | tail -n +3 | awk '{print $1}' ); vcompare2=$(virsh domblklist $vm | tail -n +3 | awk '{ print $1}'); for i in \`echo $vcompare2\`; do grep -v $i <(echo $vcompare1) 2>&1 1>/dev/null && echo -e "\tfound: $i $(virsh domblklist $vm --inactive | grep $i)"; done; done` For some reason the $() inside the echo didn't always work, not sure why. --details was not necessary and incompatible with some virsh versions. – SpaceGaucho Aug 31 '17 at 22:03