[libvirt] [PATCH]: Allow arbitrary paths to virStorageVolLookupByPath

Chris Lalancette clalance at redhat.com
Fri Oct 31 11:04:34 UTC 2008

In ovirt, we have to scan iSCSI LUN's for LVM storage when they are first added
to the database.  To do this, we do roughly the following:

iscsi_pool = libvirt.define_and_start_iscsi_pool("/dev/disk/by-id")

logical = conn.discover_storage_pool_sources("logical")
for each logical_volume_group in logical:
     for each device in logical_volume_group:

And then we use that information to associate an iSCSI LUN with this volume
group.  The problem is that there is an mis-match between how we define the
iscsi pool (with /dev/disk/by-id devices), and what data the
discover_storage_pool_sources() returns (/dev devices), so we can't easily
associate the two.

The following patch implements stable path naming when the
virStorageVolLookupByPath method is called.  Basically, it tries to convert
whatever path it is given (say /dev/sdc) into the form currently used by the
Pool (say /dev/disk/by-id).  It then goes and looks up the form in the pool, and
returns the storageVolume object as appropriate.  Note that it only tries to do
this for the Pool types where it makes sense, namely iSCSI and disk; all other
pool types stay exactly the same.

With this in place, we can solve the mis-match in the above code, and LVM
scanning seems to work in ovirt.

Signed-off-by: Chris Lalancette <clalance at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt-stable-path.patch
Type: text/x-patch
Size: 3516 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20081031/93a560c5/attachment-0001.bin>

More information about the libvir-list mailing list