Discussion:
[linux-lvm] api recommandation (example_cmdlib.c doesnt work properly)?
Oliver Rath
2018-05-09 06:52:57 UTC
Permalink
Hi list,

i tried to get some lvm-commands working using example_cmdlib.c
(modified, attached). Unfortunatly the example hangs trying a "lvcreate
--name test --size 12M levg" command:

---------------------- snip ---------------------------------

***@w541:/home/oliver/gits/lvm2/doc# lvremove -f levg/test
  Logical volume "test" successfully removed
***@w541:/home/oliver/gits/lvm2/doc# ./example_cmdlib
WARNING: Sum of all thin volume sizes (870,00 GiB) exceeds the size of
thin pools and the amount of free space in volume group (<6,17 GiB).
WARNING: You have not turned on protection against thin pools running
out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to
trigger automatic extension of thin pools before they get full.

---------------------- snap ---------------------------------

Here the only way to continue is to killall -9 example_cmdlib. If you
like, i can send a strace from the run (300kb). The program was built with

gcc example_cmdlib.c -o example_cmdlib  -llvm2cmd

Whats wrong here? Ist there a better api for communicating from other
programs?

Imho the python support is deprecated, lvm2app is deprecated, dbus-api
is limited at the moment (right? Didnt find documentation for it), so
the only way seems liblvm or call explicit the lvm-tools.

Tfh!

Oliver
Zdenek Kabelac
2018-05-09 08:27:55 UTC
Permalink
Post by Oliver Rath
Hi list,
i tried to get some lvm-commands working using example_cmdlib.c
(modified, attached). Unfortunatly the example hangs trying a "lvcreate
Hi

Please avoid tweaking code to use cmdlib - it's internal library and
lvm2 is highly recommending to always FORK lvm2 command - instead
of trying to embeded it in your application.

There are numerous memory requirements during certain operation that would be
pretty bad to be imposed for other users tool.

If you want to 'stream' multiple commands - you could pipe lvm shell to
minimize forking, however than error reporting & reaction becomes a bit harder
to play with.
Post by Oliver Rath
Whats wrong here? Ist there a better api for communicating from other
programs?
It's simply not official API and it's based on internal knowledge and uses
settings from lvm.conf - these settings are tied to use of lvm command.
Post by Oliver Rath
Imho the python support is deprecated, lvm2app is deprecated, dbus-api
is limited at the moment (right? Didnt find documentation for it), so
the only way seems liblvm or call explicit the lvm-tools.
dBus API is somewhat 'frozen' as there is no active development on this part,
and would be nice to get someone involved into this more...


Regards


Zdenek

Loading...