Use libguestfs to view devices and filesystems in a VM

Here is a small C program (examples/to-xml.c) which uses libguestfs to examine a virtual machine and produce a little XML display of the partitions, LVM data and filesystems within the virtual machine.

This XML is fanciful. Is there a standard XML description for this sort of thing?

Example:

$ examples/to-xml RHEL52PV32-tmp.img | tidy -xml -i -q
<guestfs-system>
  <devices>
    <device dev="/dev/sda">
      <partitions>
        <partition dev="/dev/sda1">
          <fs type="ext3">
            <uuid>780a9d90-e0e4-45a4-9012-3e58eedb25be</uuid>
            <blocksize>1024</blocksize>
          </fs>
        </partition>
        <partition dev="/dev/sda2">
          <physvol />
        </partition>
      </partitions>
    </device>
  </devices>
  <volgroups>
    <volgroup name="VolGroup00">
      <logvol name="/dev/VolGroup00/LogVol00">
        <fs type="ext3">
          <uuid>2d3af696-15af-4f32-97ae-eeb0870c5a94</uuid>
          <blocksize>4096</blocksize>
        </fs>
      </logvol>
      <logvol name="/dev/VolGroup00/LogVol01">
        <linux-swap />
      </logvol>
    </volgroup>
  </volgroups>
</guestfs-system>

Leave a comment

Filed under Uncategorized

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.