A few examples of using `xpath` to query the guest XML from the
command-line.
(1) CPU "mode": whether customer is using `host-model`,
`host-passthrough` or `custom`. You can find that as the value of
the "mode" attribute for the 'cpu' element. Or this `xpath`
one-liner on a libvirt guest XML will show it:
$> xpath -q -e '//cpu/@mode' el8-vm1.xml
mode="host-model"
Run the above on all your XML files (and output that into a file):
$> xpath -q -e '//cpu/@mode' *.xml |& tee Customer-CPU-mode.txt
[...]
(2) Entire guest CPU configuration. This will dump the entire guest CPU
config. So it would be the entire content between the 'cpu'
element: ... . Or run this `xpath` one-liner
on an XML file (and then on rest of them all):
$> xpath -q -e '//cpu/' el8-vm1.xml
[...]
(3) The 'disk' element: how many are using 'qcow2' vs 'raw'.
$> xpath -q -e '//disk/' el8-vm1.xml
[...]
But to get the format ('qcow2' or 'raw') of file:
$> xpath -q -e '//driver/@type' el8-vm1.xml
type="qcow2"
(4) The "machine type" in use:
hvm
Or a convenient `xpath` query to just extract the machine type:
$> xpath -q -e '//type/@machine' el8-vm1.xml
machine="pc-q35-2.11"
- - -
Querying the 'os'-related bits from getdomainCapabilities():
[...]
efi/usr/share/edk2/ovmf/OVMF_CODE.fdrompflashyesnono
[..]
And the `xpath` queries:
$> virsh domcapabilities --machine q35 | \
xpath -q -e "//os/@supported"
supported="yes"
$> virsh domcapabilities --machine q35 | \
xpath -q -e "//enum[@name='firmware']/value/text()"
efi
$> virsh domcapabilities --machine q35 | \
xpath -q -e "//loader/@supported"
supported="yes"
$> virsh domcapabilities --machine q35 | \
xpath -q -e "//loader/value/text()"
/usr/share/edk2/ovmf/OVMF_CODE.fd
$> virsh domcapabilities --machine q35 | \
xpath -q -e "//loader/enum[@name='type']/value/text()"
rom
pflash