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")
iscsi_pool.add_luns_to_db
logical = conn.discover_storage_pool_sources("logical")
for each logical_volume_group in logical:
for each device in logical_volume_group:
iscsi_pool.lookup_vol_by_path(device.path)
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(a)redhat.com>