1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
Commit Graph

51 Commits

Author SHA1 Message Date
Zdenek Kabelac
34a9e3d3cd python: add devmapper library to linking
On occasional gcc releases it's better to specify also -ldevmapper
to linking logic for python object.

It's in fact more correct since the liblvm.c code is using
libdevmapper functions - that were linked in only via
liblvm2app library.
2018-02-09 11:00:18 +01:00
Marian Csontos
83e1a0bad8 lvm2app: Suppress deprecation warnings for our builds 2017-12-14 16:45:53 +01:00
Marian Csontos
4cbacf6bac liblvm: Deprecate library and bindings
It is recommended to use D-Bus API instead of liblvm2app or python
bindings.
2017-09-20 13:07:06 +02:00
David Teigland
7ef152c072 python: move lvm_init
Only call lvm_init() when it's needed so that simply
loading the lvm python code in another program doesn't
make that program do lvm initialization.

The version call doesn't need a handle.

The garbage collection can just do lvm_quit to destroy
the command.  The next call that needs lvm_init will
do it first.
2016-05-16 14:36:55 -05:00
Alasdair G Kergon
5987562cf9 lvmdbus: Add new daemon. 2016-02-17 23:53:35 +00:00
Zdenek Kabelac
fcbef05aae doc: change fsf address
Hmm rpmlint suggest fsf is using a different address these days,
so lets keep it up-to-date
2016-01-21 12:11:37 +01:00
Alasdair G Kergon
3934ade5a2 gitignore: Update for in-place build. 2015-07-27 13:18:35 +01:00
Tony Asleson
e8c11c7df0 python: Check for NULL value before constructing string property
When retrieving a property value that is a string, if the character pointer in C
was NULL, we would segfault.  This change checks for non-null before creating a
python string representation.  In the case where the character pointer is NULL
we will return a python 'None' for the value.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2015-05-06 08:51:04 -05:00
Tony Asleson
c21f1ba07a python: Build correct python value for numerical property
With the lvm2app C API adding the ability to determine when a property is
signed we can then use this information to construct the correct representation
of the number for python which will maintain value and sign.  Previously, we
only represented the numbers in python as positive integers.

Python long type exceeds the range for unsigned and signed integers, we just
need to use the appropriate parsing code to build correctly.

Python part of the fix for:
https://bugzilla.redhat.com/show_bug.cgi?id=838257

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2015-05-06 08:51:04 -05:00
bkabrda@redhat.com
5d8b31ffad python: python 3 compat patch for lvm2
As provided by rhbz: 1136366
2015-04-29 15:09:56 +02:00
Tony Asleson
0523c71844 python: Fix ws liblvm.c
Signed-off-by: Tony Asleson <tasleson@redhat.com>
2015-04-10 11:01:46 -05:00
Tony Asleson
2b557b595a python: Make lv addTag/removeTag persistent
Added lvm_vg_write in the addTag/removeTag paths to make the
changes persist.  Added unit test to ensure functionality.

https://bugzilla.redhat.com/show_bug.cgi?id=1210020

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2015-04-10 10:38:43 -05:00
Zdenek Kabelac
75d79f3dad makefiles: standard usage of make.tmpl
Use lvm2 standard TARGETS.

Make liblvm_python.c as intermediate target (gets deleted after use)

Properly delete build dir on make distclean.

Mark install_python_bindings as .PHONY.
2014-11-22 09:58:31 +01:00
Zdenek Kabelac
7278556c76 lvm2api: use fully initilized struct
Don't pass partially initialized struct.
2014-11-13 17:49:41 +01:00
Zdenek Kabelac
f12e3da639 cleanup: gcc warnings 2014-11-10 22:05:49 +01:00
Zdenek Kabelac
618d818c0d lvm2app: update to new lv_create_single API
lv_create_single is more type based.
2014-10-26 18:37:13 +01:00
Alasdair G Kergon
4aa8a14fc2 compilation: Rename tags variables to tagsl. 2014-01-30 21:09:28 +00:00
Tony Asleson
fe5b538c14 lvm2app: Reset buffer after retrieving error message
The error buffer will stack error messages which is fine.  However,
once you retrieve the error messages it doesn't make sense to keep
appending for each additional error message when running in the
context of a library call.

This patch clears and resets the buffer after the user retrieves
the error message.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-11-19 14:40:42 -06:00
Tony Asleson
0c7a7d4d84 python-lvm: VG/LV name validation.
Python portion of
https://bugzilla.redhat.com/show_bug.cgi?id=883689

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-11-19 14:40:40 -06:00
Tony Asleson
531d85a0ee python-lvm: Add addl. PV create arguments
Added overloaded PV create arguments with defaults for PV
creation.

Addresses bug: https://bugzilla.redhat.com/show_bug.cgi?id=880395

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-11-19 14:40:36 -06:00
Tony Asleson
20ffb0f721 python-lvm: Ensure library handle is correct after python gc() call
In a previous commit we added the ability for the library to do garbage
collection, to free all the memory used by the library handle buffer by closing
and re-opening the library handle.  When we introduced this functionality we
also opened up the opportunity that the user of the python bindings to have
an object that references the old library handle.  In this case if the user
tried to use the old object a segmentation fault could occur because the
memory had been previously freed.

This patch tries to mitigate this by storing a copy of the library handle that
was used when the object was created so that it can compare the current in
use pointer with what existed when the object was created.  In the case where
they match the operation is permitted to continue, otherwise an exception is
throw, thus avoiding a segmentation fault.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-11-19 14:40:27 -06:00
Tony Asleson
1f744733a1 python-lvm: Correct names
The existing names do not follow accepted guidelines.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-11-19 14:40:25 -06:00
Tony Asleson
46a1202a61 python-lvm: Correct parsing arguments for integers
There were a few places where the code was incorrectly
using parse arguments for the supplied variable type &
size.  Changing the variables to be declared exactly
like python is expecting so if we build on an arch
where the size of type is different than typically
expected we will continue to match.  In addition the
parse character needed to be corrected in a few spots
too.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-26 10:24:01 -05:00
Tony Asleson
929d5f3563 python-lvm: Change exception back to LibLVMerror
This is an API exposed name and shouldn't be changed
to _LibLVMError.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-24 17:55:12 -05:00
Alasdair G Kergon
97df05ce10 python: Introduce pyexecdir
Use pyexecdir for $DESTDIR + $prefix
2013-07-24 22:07:10 +01:00
Alasdair G Kergon
462df8d89d python: fix Makefile installation path
Use --prefix rather than --root.
(Needs more thorough investigation, but this seems to avoid /usr/usr
paths.)
2013-07-24 21:52:39 +01:00
Zdenek Kabelac
7dc21c1597 python: make clean removes build dir
Cleanning compiled objects for clean: target.
2013-07-24 17:14:10 +02:00
Zdenek Kabelac
03efb7c2e1 python: make install to prefix dir
Respect $prefix and avoid install to live system.
2013-07-22 12:41:22 +02:00
Zdenek Kabelac
d4ad728610 cleanup: lvm complient style
drop unused assignments.
2013-07-22 12:41:21 +02:00
Tony Asleson
1a005b40a4 python-lvm: Add call to close/re-open C lib.
As the library handle has a dm pool associated with
it for long running processes it is required to close and
re-open the library to free the dm pool.  Call added so
python clients can reclaim memory, lvm.gc().

Note: Any python objects on the heap become invalid at the
time this call is made.  If referenced, a seg. fault could
occur.  No simple way to make this safe with the current
memory management in the C library.  Use with caution!

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-18 16:03:29 -05:00
Tony Asleson
40feaa7bbe python-lvm: Bug fixes from unit tests.
After the last rebase, existing unit test case was
run which uncovered a number of errors that required
attention.

Uninitialized variables and changes to type of numeric
return type were addressed.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
8882480083 python-lvm: Change snapshot call impl.
Using the new object parameter creation to create the snapshot.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
2a3472b2b3 python-lvm: Bindings for thin pool, thin lv creation V3
V2: Bug fix.
V3: Use updated property interface, add constants for discard.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
f576b32203 python-lvm: Added lv method getOrigin
Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
9e0260c2e3 python-lvm: Add method to retrieve lv attr.
Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
588a16cadb python-lvm: Add pvCreate python method
Added to base namespace.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
45a0f9e45b python-lvm: Add bindings for lvm_pv_remove
Method off of base lvm namespace "pvRemove".

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
ef3ab801e8 lvm2app: Add function to retrieve list of PVs V3
As locks are held, you need to call the included function
to release the memory and locks when done transversing the
list of physical volumes.

V2: Rebase fix
V3: Prevent VGs from getting cached and then write protected.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:33 -05:00
Andy Grover
86e528c667 lvm2app: No special behavior for 0 for max_snap_size in lvm_lv_snapshot()
It isn't possible to choose a sane default for snapshot size, so just
play it straight and use the passed size instead of adding special
behavior for 0.

Also revert change to Python lib, size parameter must be supplied.

Signed-off-by: Andy Grover <agrover@redhat.com>
2012-12-17 14:14:38 -08:00
Andy Grover
0958905b1b python-lvm: Make second lv.snapshot() argument optional
If no size is given, size defaults to 0, which in lvm_lv_snapshot will
allocate extents equal to the original LV be allocated for the new
snapshot.

Signed-off-by: Andy Grover <agrover@redhat.com>
2012-12-14 14:10:41 -08:00
Andy Grover
0e3093979e python-lvm: whitespace in python/liblvm.c.
Sorry, it bugged me. Should be perfect now.

Signed-off-by: Andy Grover <agrover@redhat.com>
2012-12-14 10:32:35 -08:00
Andy Grover
58b61c252a python-lvm: Small fixups to new create_lv_snapshot
Tabify

Remove use of asize, unneeded.

Don't initialize lvobj->parent_vgobj to NULL, the object ctor already
zeroed everything on alloc.

Redo call to lvm_lv_snapshot to use the liblvm snapshot implementation
we went with.

Add {}s to silence warning in lv_dealloc.

Rename snapshot function for consistency.

Update WHATS_NEW.

Signed-off-by: Andy Grover <agrover@redhat.com>
2012-12-14 10:30:26 -08:00
James Antill
0db733f18a python-lvm: Add snapshot support
Signed-off-by: Andy Grover <agrover@redhat.com>
2012-12-14 10:30:13 -08:00
James Antill
1ec6a59dcf Fix Py_BuildValue for i386
see https://bugzilla.redhat.com/show_bug.cgi?id=881989

Signed-off-by: James Antill <james.antill@redhat.com>
Signed-off-by: Andy Grover <agrover@redhat.com>
2012-12-05 16:31:50 -08:00
Tony Asleson
bbff143d54 python-lvm: Memory leaks & seg. fault fixes
Issues found (thus far) in unit test developemnt for python bindings.

Added Py_DECREF(ptr) in liblvm_lvm_vg_open & liblvm_lvm_vg_create
in error paths so that we correctly clean up memory.

Added a call to lvm_vg_close when we remove a vg.  The code was
clearing out the vg pointer which prevented us from actually
calling lvm_vg_close in the close path.

liblvm_lvm_vg_create_lv_linear was not initializing
lvobj->parent_vgobj and if lvm_vg_create_lv_linear failed
we went through liblvm_lv_dealloc on clean up and tried to
Py_DECREF an invalid pointer.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2012-10-25 18:09:10 -05:00
Tony Asleson
8073ce1690 python-lvm: seg. fault in liblvm_lvm_percent_to_float
The first parameter needs to be present even if it isn't being
used, otherwise the one any only parameter we get is null
which causes PyArg_ParseTuple to seg. fault.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2012-10-23 14:54:06 -05:00
Andy Grover
0e47639a44 python-lvm: Implement proper refcounting for parent objects
Our object nesting:

lib -> VG -> LV -> lvseg
          -> PV -> pvseg

Implement refcounting and checks to ensure parent objects are not
dealloced before their children. Also ensure calls to self or child's
methods are handled cleanly for objects that have been closed or removed.

Ensure all functions that are object methods have a first parameter named
'self', for consistency

Rename local vars that reference a Python object to '*obj', in order to
differentiate from liblvm handles

Fix a misspelled pv method name

Signed-off-by: Andy Grover <agrover@redhat.com>
2012-10-17 12:55:25 -07:00
Tony Asleson
10ba799ab0 python-lvm: Update example to work with lvm object removal.
Signed-off-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: Andy Grover <agrover@redhat.com>
2012-10-15 14:11:10 -07:00
Andy Grover
12b631a676 python-lvm: whitespace and Yoda conditionals
Signed-off-by: Andy Grover <agrover@redhat.com>
2012-10-15 14:11:10 -07:00
Andy Grover
84a4d4b970 python-lvm: Remove liblvm object
Instead of requiring users to create a liblvm object, and then calling
methods on it, the module acquires a liblvm handle as part of
initialization. This makes it impossible to instantiate a liblvm object
with a different systemdir, but there is an alternate envvar method for
that obscure use case.

Signed-off-by: Andy Grover <agrover@redhat.com>
2012-10-15 14:11:10 -07:00