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

Daniel Veillard veillard at redhat.com
Thu Oct 16 09:26:23 UTC 2008

On Thu, Oct 16, 2008 at 09:43:58AM +0200, Chris Lalancette wrote:
> 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:

  Patch looks fine to me +1
  I wonder what happens when you hit a block device which had no label
or  partition table, and has a raw file system on it directly. I
sometimes do that by mistake on USB devices but the kernel still manage
to handle them ... sometimes.


Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

More information about the libvir-list mailing list