Bug 619793

Summary: [RFE] Need a way to determine if a particular block device is a logical volume
Product: [Community] Virtualization Tools Reporter: Matthew Booth <mbooth>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: low    
Version: unspecifiedCC: mbooth, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 619826 (view as bug list) Environment:
Last Closed: 2010-07-30 16:03:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 619826    

Description Matthew Booth 2010-07-30 14:46:54 UTC
Description of problem:
I need a robust, reliable way to determine if a particular block device is a logical volume when inspecting a guest. This rules out methods based on path name inspection, as these paths can be changed by configuration and vary between distributions.

My chosen solution to this problem is to stat every device returned by lvs(), and to stat the target device, and test if the major and minor numbers of the target appear in the list returned by lvs(). This avoid any issues relating to path names. However, it is complicated because stat() doesn't chroot, and therefore you can't stat a device node. I'm doing sh("stat...") to work round this, which is ugly.

I don't know what the best approach to this is. It could be a new is_lvm_device(dev), a change to the existing stat() api to work on device nodes, a new api to stat device nodes(), or something else.

However, I'm slightly concerned that this use case is quite esoteric. I can't think of any previous occasion using libguestfs or otherwise when I have been concerned to know whether or not a block device is a logical volume. The high-level api may be extremely under-used, meaning an implementation in virt-v2v is more appropriate.

Version-Release number of selected component (if applicable):
libguestfs-1.5.0-4.fc13.x86_64

Comment 1 Richard W.M. Jones 2010-07-30 15:40:48 UTC
Patch posted upstream:
https://www.redhat.com/archives/libguestfs/2010-July/msg00086.html

Comment 2 Richard W.M. Jones 2010-07-30 16:03:17 UTC
Pushed upstream:
http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=6280ac9b987c14f89749b4b4fdfec5a647567432

Matt, you'd better clone this bug for RHEL 6.