linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Oliver Rath <rath@mglug.de>
To: linux-lvm@redhat.com
Subject: [linux-lvm] api recommandation (example_cmdlib.c doesnt work properly)?
Date: Wed, 9 May 2018 08:52:57 +0200	[thread overview]
Message-ID: <f45ed20a-6773-54c2-d1f6-774522f1d7f8@mglug.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 1319 bytes --]

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 ---------------------------------

root@w541:/home/oliver/gits/lvm2/doc# lvremove -f levg/test
  Logical volume "test" successfully removed
root@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@the moment (right? Didnt find documentation for it), so
the only way seems liblvm or call explicit the lvm-tools.

Tfh!

Oliver


[-- Attachment #2: example_cmdlib.c --]
[-- Type: text/x-csrc, Size: 1148 bytes --]

/*
 * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
 *
 * This file is part of LVM2.
 *
 * This copyrighted material is made available to anyone wishing to use,
 * modify, copy, or redistribute it subject to the terms and conditions
 * of the GNU General Public License v.2.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "lvm2cmd.h"
#include <stdio.h>

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

	if (level != 4)
		return;

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

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

	lvm2_log_fn(test_log_fn);

	handle = lvm2_init();

	lvm2_log_level(handle, 4);
	// r = lvm2_run(handle, "vgs --reportformat=json levg");
	r = lvm2_run(handle, "lvcreate --name test --size 12M levg");

	/* More commands here */

	lvm2_exit(handle);
	return r;
}


             reply	other threads:[~2018-05-09  6:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09  6:52 Oliver Rath [this message]
2018-05-09  8:27 ` [linux-lvm] api recommandation (example_cmdlib.c doesnt work properly)? Zdenek Kabelac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f45ed20a-6773-54c2-d1f6-774522f1d7f8@mglug.de \
    --to=rath@mglug.de \
    --cc=linux-lvm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).