parted/LVM for ET [Re: [Libvir] Storage manager initial requirements and thoughts

Jim Meyering jim at
Thu Mar 22 12:41:18 UTC 2007

"Richard W.M. Jones" <rjones at> wrote:
> Secondly there is an API of sorts for lvm2.  I think Alasdair called it
> "libcmd", but maybe I got that wrong because Google doesn't seem to turn
> up anything.  In any case, all it is is a wrapper around the command
> line tools, so it seems doubtful that this is going to be any better
> than just invoking the command line tools ourselves.

lvm2cmd is what you're looking for.
It is only slightly higher-level than "system".

Here's an example of that interface,
from the lvm2 repo, doc/example_cmdlib.c:

#include "lvm2cmd.h"

/* All output gets passed to this function line-by-line */
void test_log_fn(int level, const char *file, int line, const char *format)
        /* Extract and process output here rather than printing it */

        if (level != 4)

        printf("%s\n", format);

int main(int argc, char **argv)
        void *handle;
        int r;


        handle = lvm2_init();

        lvm2_log_level(handle, 1);
        r = lvm2_run(handle, "vgs --noheadings vg1");

        /* More commands here */


        return r;

More information about the libvir-list mailing list