1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00
Commit Graph

32 Commits

Author SHA1 Message Date
Dave Wysochanski
dce56c9761 Add lvm_config_override - allow caller to override config, similar to --config.
Allowing the caller to override the LVM configuration with an API will
enable them to use things such as device filters.
While very flexible, there is some danger to this API in that it will
make it harder to debug setups that have a changing config and deduce
what might have happened.  At some point we may want to limit the scope
of this API but for now it is as open as the --config option to lvm commands.

Update exported symbols.  When I renamed lvm_reload_config to lvm_config_reload
I forgot to rename so I renamed that one here.

This I believe is the last liblvm API for now.  ;-)

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 21:02:17 +00:00
Dave Wysochanski
ee7e183f7e Add skeletons of lvm_lv_resize and lvm_pv_resize - not yet implemented.
These lower-priority interfaces are not currently implemented in liblvm
but are on the TODO list in the near term.

Author: Thomas Woerner <twoerner@redhat.com>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 21:00:50 +00:00
Dave Wysochanski
dfe213f804 Add lvm_vg_reduce to liblvm2app
Extend lvm_vg_write to remove pvs removed in lvm_vg_reduce. The lvm
volume_group internal structure removed_pvs is used for that. The list is
empty afterwards.

Add new test for vg->pvs emptyness to lvm_vg_write to prevent to write empty
vgs. This is needed because of lvm_vg_reduce and lv_vg_create, which creates
empty vgs.

Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 17:44:29 +00:00
Dave Wysochanski
0589e19fd7 Update error return and comments for lvm_list_vg_names/uuids.
The two liblvm functions that return a list of vgnames and vguuids use
cmd->mem to allocate the list.  Make it clear to the caller that this
memory will be freed when the LVM handle is freed.

Clean up and clarify the return value of the functions.  In the
case of a memory allocation error, add a couple log_errnos to the internal
code, and make it clear that memory allocation returns a NULL pointer.
If there are no VGs in the system, the list returned is an empty list.

Make a note of the fact that currently we return hidden VG names, how
these can be detected (always start with "#"), and that they should
not be used.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 11:00:17 +00:00
Dave Wysochanski
f6b1eaf700 Rename lvm_reload_config to lvm_config_reload.
The general naming scheme for most liblvm APIs is:
lvm_<object>_<action>

As there are likely to be other things to do on the lvm 'config' object
(i.e. lvm_config_set_device_filter), we should use consistent naming.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 10:18:51 +00:00
Dave Wysochanski
efd7d4c20f More liblvm header file cleanups.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 08:28:13 +00:00
Dave Wysochanski
2642ef553a Add lvm_lv_is_active and lvm_lv_is_suspended.
Return whether an LV is active in the kernel (live table) or suspended
(table suspend).


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:58:11 +00:00
Dave Wysochanski
63b186b6f7 Implement lvm_lv_activate and lvm_lv_deactivate liblvm calls.
Limited implementation but other types of activation should probably have
separate calls.  We also currently do not handle pvmoves or lvconverts.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:57:37 +00:00
Dave Wysochanski
f864285b3a Update liblvm status return codes to be consistent.
For now, we use the following scheme.
For APIs that return an int, success is 0, fail is -1.
APIs that return handles, success is non-NULL, fail is NULL.
At this early stage, liblvm error handling mechanism is subject to change,
but for now we go with this simple scheme consistent with system
programming.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:28:59 +00:00
Dave Wysochanski
648fa396d9 A few more lvm.h updates that got missed.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:49:52 +00:00
Dave Wysochanski
2572832e0c Rename lvm_scan_vgs to lvm_scan.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:44:05 +00:00
Dave Wysochanski
93e025dcc4 Update lvm.h - comments describing function behavior, divide into sections.
Hard to divide into smaller patches because of the moving around and
commenting, so just put in the new file diffs.  We will review and can
update as necessary.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:35:57 +00:00
Dave Wysochanski
5ed9395077 Update lvm.h handle and handle list comments.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:11:58 +00:00
Dave Wysochanski
4e57aae3a7 Rename lvm_vg_get_free to lvm_vg_get_free_size.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:06:46 +00:00
Dave Wysochanski
1efda0fbb9 Rename lvm_list_vg_ids to lvm_list_vg_uuids.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:06:21 +00:00
Dave Wysochanski
0185663b88 Rename lvm_vg_get_free_count to lvm_vg_get_free_extent_count.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:05:49 +00:00
Dave Wysochanski
8bcb96836d Add lvm_vg_remove_lv liblvm function.
Add a very simple version of lvm_vg_remove_lv.
Since we currently can only create linear LVs, this simple remove function
is adequate.  We must refactor lvremove_single a bit.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 14:36:52 +00:00
Dave Wysochanski
83f25cd121 Add most all liblvm 'get' functions needed for anaconda.
Add the most straightforward 'get' functions required for anaconda.
These are the ones that return simple uint64_t values.
The other more complex ones involve the lv_attr bits.  These will
come in a separate patch series since each lv_attr bit will be returned
in a separate API instred of returning the string and requiring the
user to parse it.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 13:06:59 +00:00
Dave Wysochanski
7a35a9f5d8 Add lvm_vg_create_lv_linear liblvm function.
Create a default linear logical volume from a volume group.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:34:36 +00:00
Dave Wysochanski
bae6bc62bd Update lvm_vg_extend to do an implicit pvcreate on the device.
Although the tools do not currently do this, we update lvm_vg_extend
to do an implicit pvcreate on an uninitialized device.  The tools will
soon be refactored to do this as well, but more work is needed in the
tools.  For now we update lvm_vg_extend since this is the behavior
required by liblvm.
With this change, the simple liblvm unit test, test/api/vgtest.c
should pass whether or not the device is initialized.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:54:40 +00:00
Dave Wysochanski
fe63e644d9 Add lvm_scan_vgs liblvm fn to scan the system for LVM metadata.
The lvm_list_vg_{names|ids} functions do not do a scan so we provide
a liblvm function that does a scan.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 12:48:21 +00:00
Dave Wysochanski
122ccd0d04 Add lvm_list_vg_names and lvm_list_vg_ids liblvm functions.
These functions provide the capability of enumerating all vgnames and
vgids in the system.  They do not do a scan of the system.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 12:47:15 +00:00
Dave Wysochanski
f032ed7498 Add lvm_{pv|vg|lv}_get_{uuid|name}.
Caller must free the memory of the uuid / name returned.
This may not be the best memory management policy since it may lead to
memory leaks if the caller has code like this:
if (!lvm_vg_get_name(vg))

Maybe we don't care - if we do we can use pools tied to handles later
or some other scheme.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Thomas Woerner <twoerner@redhat.com>
2009-07-23 23:40:05 +00:00
Dave Wysochanski
6c6c821445 Add lvm_vg_list_{pvs|lvs} - return lists of pv/lv handles for a vg.
- Use vgmem pool to allocate a list of lvm_*_list structs
- Allocate a new list each call (list may have changed since last call)
- Add to liblvm's exported symbols

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Thomas Woerner <twoerner@redhat.com>
2009-07-23 23:39:02 +00:00
Dave Wysochanski
357ed599ec Add list structure definitions for liblvm objects.
- pv_t, vg_t, lv_t
- include libdevmapper.h: needed for struct dm_list

These list structures will be needed in later APIs to return a list of
handles to one object, given another object.  For example, lvm_vg_list_lvs()
will return a list of LV handles (lv_t's) given a VG handle (vg_t).  We
need a structure to do this so we define the LV structure, as well as the
other structures at this point.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-23 23:37:24 +00:00
Dave Wysochanski
5f055102fa Remove lvseg_t and pvseg_t typedefs from liblvm/lvm.h.
We do not need lvseg and pvseg for now.  If we need we will add back
later.
2009-07-23 23:36:20 +00:00
Dave Wysochanski
f6ffb81bf8 Update lvm_vg_create to use NULL / non-NULL return for the time being.
Some of the error interface is still TBD.  Rather than exporting a lot
of codes, etc, just use a simple pass / fail.  The allows our unit test
to not segfault if trying to create a VG that already exists.
2009-07-23 01:20:22 +00:00
Dave Wysochanski
729f472c04 Add lvm_vg_open() to open an existing VG for reading or writing.
lvm_vg_open() calls internal vg_read() function which is the entry point
for reading an existing VG.  In addition to the mode, we include a 'flags'
parameter for future extensions.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-22 22:24:16 +00:00
Dave Wysochanski
a0b1b1872e Change default errno value to 0 (no error) and add prototypes in lvm.h
Since we are using errno values, we should use '0' as a default value
which indicates a non-error, rather than defining some made-up default
value that is not defined in errno.  If we need to deviate from errno
values, this will most likely indicate a flaw in our design.

Add prototypes for lvm_errno and lvm_errmsg inside lvm.h and provide
a basic description of their function.  This fixes a couple compile
warnings.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-16 03:07:45 +00:00
Dave Wysochanski
930a1434ac Add lvm_vg_* APIs to create and modify VGs.
Add some liblvm APIs for VGs.  Most of these APIs simply call into the internal
liblvm library.  Ideally we should call the liblvm functions directly from
the tools.  However, until we convert more of the code to liblvm functions,
things like the cmd_context will get in the way.  For now just implement the
liblvm functions as wrappers around the internal functions, with a little
error checking and return code handling.  We put all these vg APIs into a
new file, lvm_vg.c

The following APIs are implemented:
lvm_vg_create, lvm_vg_extend, lvm_vg_set_extent_size, lvm_vg_write,
lvm_vg_remove, lvm_vg_close.

Still TODO:
- cleanup error handling by using lvm_errno() and related APIs
- cleanup naming / clarify which functions commit to disk vs not
- implement more 'set' functions
- decide on 'set' / 'change' nomenclature

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 03:02:14 +00:00
Dave Wysochanski
39d6ccdfc7 Define handles to liblvm objects for pv, vg, lv, lvseg, pvseg.
Define the 5 main liblvm objects to be the pv, vg, lv, lvseg, and pvseg.
We need handles defined to all these objects in order for liblvm to be
equivalent to the reporting commands pvs, vgs, and lvs.

- move vg_t, lv_t, and pv_t from metadata-exported.h into lvm.h
- move lv_segment and pv_segment forward declarations into lvm.h
- add lvseg_t and pvseg_t to lvm.h

NOTE: We currently have an inconsistency in handle definitions.
lvm_t is defined as a pointer, while these other handles are just
structures.  We should pick one scheme and be consistent - perhaps
define all handles as pointers (this is what I've seen elsewhere).

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 03:00:30 +00:00
Dave Wysochanski
227301e041 Move lvm.h from lib to liblvm. 2009-03-06 22:49:48 +00:00