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>
About these ads

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s