[libvirt] [PATCH]: Export the 'label' on block devices

Chris Lalancette clalance at redhat.com
Thu Oct 16 07:43:58 UTC 2008


To support LVM partitioning in oVirt, one of the things we need is the ability
to tell what kind of label is currently on a block device.  Here, a 'label' is
used in the same sense that it is used in parted; namely, it defines which kind
of partition table is on the disk, whether it be DOS, LVM2, SUN, BSD, etc.  Note
that this is different than the partition type; those are things like Linux,
FAT16, FAT32, etc.

This actually turns out to be fairly easy to implement; there are really only a
few labels that are in common use, and they all have an easy signature to
recognize (but see comments in the code about pc98).  This patch implements
label detection on block devices in virStorageBackendUpdateVolInfoFD, and hooks
it up to the iSCSI backend so it works there.

To keep code duplication down, I moved some of the enum's from
storage_backend_disk.c into a common place.  Note, however, that there is a
slight semantic change because of this.  Previously, if no label was found on a
disk in storage_backend_disk.c, it would always return "dos" as the label type.
 That's not actually true, though; if it's a completely zeroed disk, for
instance, it really just has label type of 'unknown'.  This patch changes to the
new semantic of 'unknown' for label types we don't understand.  I don't think
this will be a huge issue for compatibility, but there could be something I'm
missing.

Otherwise, this patch has been tested by me to work, and now when you do:

# virsh vol-dumpxml --pool iscsitest lun-1

you'll get:

<volume>
...
  <target>
      ...
      <format type='dos' />

Which should be sufficient for oVirt to do it's detection.

Signed-off-by: Chris Lalancette <clalance at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt-iscsi-vol-label-v3.patch
Type: text/x-patch
Size: 10504 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20081016/f13eda22/attachment-0001.bin>


More information about the libvir-list mailing list