Resend: API for retrieving linux lvm information
Hi:
I have ask about this before, however, i didn't any response.
I would appreciate very much if anyone can answer my question.
1) Is there any api library for retrieve linux lvm configuration? I.e. querying for all the vg(s), pv(s), lv(s) on the system?
2) If yes, what license is the library release under?
Thanks,
Stanley
These answers are for LVM2.
Quoted 2 lines · Stanley Yue
1) Is there any api library for retrieve linux lvm configuration? I.e. querying for all the vg(s), pv(s), lv(s) on the system?
The commands: lvs, pvs, vgs with numerous cmdline flags. See lib/report/columns.h for field names
Access to cmds via library interface: configure --enable-cmdlib
include lvm2cmd.h
Example usage: doc/example_cmdlib.c
Recommend only manipulating one thing at once, so if it returns an error you don't have to work out which thing went wrong.
[May yet add an optional argc/argv-style entry point.]
Quoted 1 line
2) If yes, what license is the library release under?
The library API is intended to be LGPL.
It's effectively a wrapper around the command-line interface, but more efficient because it's able to cache some internal state between commands.
[I shall correct the copyright notices: the library entry-point got moved which messed up the original GPL/LGPL code split.]
liblvm.a does *not* provide a supported API and will sometimes change in subtle or incompatible ways without warning. Don't be tempted to link against it. The only interface supported is the one based on the command-line.
Alasdair
Signature · 1 line
[email protected]
Alasdair:
Thanks for your response.
Given your last comment, I think i'm going to just perform the parsing from cmd-line or through /proc/lvm instead if using the apis.
As far as the parsing goes, is it better (in terms of compatibility, output stability) to parse against the command line output (i.e. lvdisplay) or against the /proc/filesystems (i.e. /proc/lvm/VGs/vg00/LVs)?
Also, it is unclear to me what is the meaning of each fields/values by looking at the information stored in the /proc/* by itself.
[root@DAP-RHLNX1 LVs]# cat /proc/lvm/VGs/vg00/LVs/vol1
name: /dev/vg00/vol1 size: 409600 access: 3 status: 1 number: 0 open: 0 allocation: 0 device: 58:00
For example, what does it mean by "access: 3"?
Is all the information available from query apis (i.e. pvdisplay, lvdisplay) also available from the /proc/lvm subdirectories? How can we find out the meaning of each fields/value from the /proc/lvm information?
Thanks,
Stanley
Quoted 38 lines · Alasdair G Kergon
These answers are for LVM2.
Quoted 2 lines · Stanley Yue
1) Is there any api library for retrieve linux lvm configuration? I.e. querying for all the vg(s), pv(s), lv(s) on the system?
The commands: lvs, pvs, vgs with numerous cmdline flags. See
lib/report/columns.hfor field namesAccess to cmds via library interface: configure --enable-cmdlib
include
lvm2cmd.hExample usage:
doc/example_cmdlib.cRecommend only manipulating one thing at once, so if it returns an error you don't have to work out which thing went wrong.
[May yet add an optional argc/argv-style entry point.]
Quoted 1 line
2) If yes, what license is the library release under?
The library API is intended to be LGPL.
It's effectively a wrapper around the command-line interface, but more efficient because it's able to cache some internal state between commands.
[I shall correct the copyright notices: the library entry-point got moved which messed up the original GPL/LGPL code split.]liblvm.a does *not* provide a supported API and will sometimes change in subtle or incompatible ways without warning. Don't be tempted to link against it. The only interface supported is the one based on the command-line.
Alasdair
--
[email protected]
Quoted 4 lines · Stanley Yue
As far as the parsing goes, is it better (in terms of compatibility, output stability) to parse against the command line output (i.e. lvdisplay) or against the
/proc/filesystems(i.e./proc/lvm/VGs/vg00/LVs)?
My answer was for LVM2.
Looks like you're using LVM1.
To simplify your future upgrade you should consider using LVM2 tools lvs/pvs/vgs read-only even on an LVM1 installation as their output is designed to be easy to parse.
Alasdair
Signature · 1 line
[email protected]
Thanks, Alasdair.
I'll indeed look into using LVM2.
I'm using Redhat AS 3.0.
Will the lvm2 rpm from Fedora Core work?
When will lvm2 be officially part of Redhat Enterprise Linux? How can i upgrade from an LVM1 system to LVM2? Is it just a matter of upgrading the rpm?
Thanks,
Stanley
Quoted 16 lines · Alasdair G Kergon
Quoted 4 lines · Stanley Yue
As far as the parsing goes, is it better (in terms of compatibility, output stability) to parse against the command line output (i.e. lvdisplay) or against the
/proc/filesystems(i.e./proc/lvm/VGs/vg00/LVs)?My answer was for LVM2.
Looks like you're using LVM1.
To simplify your future upgrade you should consider using LVM2 tools lvs/pvs/vgs read-only even on an LVM1 installation as their output is designed to be easy to parse.Alasdair
--
[email protected]
Quoted 9 lines · Alasdair G Kergon
These answers are for LVM2.
Quoted 2 lines · Stanley Yue
1) Is there any api library for retrieve linux lvm configuration? I.e. querying for all the vg(s), pv(s), lv(s) on the system?
The commands: lvs, pvs, vgs with numerous cmdline flags. See
lib/report/columns.hfor field names
liblvm.a seems handy, to generate lvm command line tools, but I'm missing a clear differentiation between modifying and non modifying usage.
I'm asking, as I want to develop some lvm information system running as a web service to provide a quick overview about my lvm configuration and status. Thus I definitely want to run it as non root. I might use those nice lvs,pvs,vgs commands, but I don't want to provide them with a suid-bit, as they are potentially able to modify my lvm. The former /proc interface was ideal for this purpose, but it seems to be missing for LVM2. Are there any plans, to provide lvm informations via /proc or /sys again, or would it be possible to write somehow "restricted" lvm-tools using liblvm?
Dieter.
Signature · 4 lines
Dieter St�ken, con terra GmbH, M�nster
[email protected]
http://www.conterra.de/
(0)251-7474-501