Red Hat Bugzilla – Bug 619793
[RFE] Need a way to determine if a particular block device is a logical volume
Last modified: 2010-09-22 05:33:28 EDT
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):
Patch posted upstream:
Matt, you'd better clone this bug for RHEL 6.