1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-12-17 16:23:52 +03:00
Commit Graph

870 Commits

Author SHA1 Message Date
Doug Goldstein
31d815b24b virDomainListAllSnapshots API appeared in 0.9.13 2013-11-22 15:58:06 +00:00
Doug Goldstein
75666e2d3a Don't build LXC module when building less than 1.0.2
The functions that the LXC module wraps did not appear until 1.0.2 so we
can't build the module unless we're building against 1.0.2 or newer.
2013-11-22 15:58:06 +00:00
Doug Goldstein
766f7433f0 Create array of modules to be built
Create an array of modules to be built to allow for flexibility to
enable or disable some modules in the future and allow for additional
modules to be added easily
2013-11-22 15:58:06 +00:00
Doug Goldstein
3878fbd548 Break generator.py to be called per module
Since we don't always want to build all the modules, and there might be
more modules added in the future but we want to retain backwards
compatibility with older libvirts, change generator.py to be called once
per module instead of with all modules at once.
2013-11-22 15:58:06 +00:00
Daniel P. Berrange
41562e063e Setup distutils build system
Create a setup.py for building libvirt python code and add
supporting files

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:06 +00:00
Daniel P. Berrange
e878523679 Add execute permission for sanitytest.py
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:06 +00:00
Daniel P. Berrange
be7d0bccb4 Add build/ to python module path for sanitytest.py
The generated libvirt.py modules will be in the build/
directory, so santitytest.py must use that directory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:06 +00:00
Doug Goldstein
4d083fbf60 Import some virTypedParams* APIs from libvirt
virTypedParamsClear() and virTypedParamsFree() were introduced in
libvirt 1.0.2. In an effort to keep the code clean bring these two
functions to libvirt-python if we're building against a version of
libvirt that's older than 1.0.2
2013-11-22 15:58:06 +00:00
Doug Goldstein
ac89e8177d Import LIBVIR_CHECK_VERSION macro from libvirt
Add LIBVIR_CHECK_VERSION from libvirt upstream so that we can check the
version of the library we are compiling against and support a range of
libvirt versions. The macro was added to libvirt in 1.2.0 so we must
provide it if its not defined.
2013-11-22 15:58:06 +00:00
Daniel P. Berrange
68bbab625a Import VIR_FORCE_CLOSE macro from libvirt
Import the macro for safely closing file descriptors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:06 +00:00
Daniel P. Berrange
218dbee6c6 Remove use of virStrcpyStatic
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:06 +00:00
Daniel P. Berrange
4f1ea70fd1 Import VIR_ALLOC / VIR_ALLOC_N / VIR_REALLOC_N functions
Import the libvirt memory allocation functions, stripping the OOM
testing and error reporting pieces.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:06 +00:00
Daniel P. Berrange
ca48db168f Import code annotation macros from libvirt
Import ATTRIBUTE_RETURN_CHECK, ATTRIBUTE_UNUSED &
ATTRIBUTE_NONNULL macros

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:05 +00:00
Daniel P. Berrange
834ee782d8 Import gnulib's ignore_value macro
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:05 +00:00
Daniel P. Berrange
c856b7c623 Import gnulib's xalloc_oversized macro
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:05 +00:00
Daniel P. Berrange
5b5437349a Add decl of MIN macro
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:05 +00:00
Daniel P. Berrange
e169d3d8cf Import STREQ macro from libvirt
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:05 +00:00
Daniel P. Berrange
3bfb20266b Update header file includes
We're no longer using automake, so <config.h> files are not
required. Also remove of all libvirt internal util header
files. Reference generated header files in build/ subdir.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:05 +00:00
Daniel P. Berrange
19453b7836 Update generator for new code layout
Change the generator.py to

 - Take XML API file names on command line
 - Generate data in build/ directory instead of cwd
2013-11-22 15:58:05 +00:00
Daniel P. Berrange
3f61b08d5b Remove obsolete Makefile.am
We are no longer using automake, so Makefile.am is obsolete

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:58:05 +00:00
Daniel P. Berrange
34aa32ba8a Move python example programs into python/examples/ subdirectory
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-11-22 15:55:39 +00:00
Daniel P. Berrange
70b8c9a2a3 Mostly revert "python: remove virConnectGetCPUModelNames from globals"
This reverts commit 6b90d7428d72e92db292a9228c44701bfd5003c9.

The original problem was that libvirt_virConnectGetCPUModelNames
was listed twice in the exports table, once automatically from
the generator and once from the manual override. We merely needed
to list it in the skip_impl list, and not delete the manually
written code entirely.
2013-11-22 15:54:43 +00:00
Doug Goldstein
45ac117cf6 python: remove virConnectGetCPUModelNames from globals
Commit de51dc9c9aed0e615c8b301cccb89f4859324eb0 primarily added
virConnectGetCPUModelNames as libvirt.getCPUModelNames(conn, arch)
instead of libvirt.virConnect.getCPUModelNames(arch) so revert the code
that does the former while leaving the code that does the later.

This is the rest of the patch that was ACK'd by Dan but I committed only
the partial patch in 6a8b8ae.
2013-11-21 14:20:45 -06:00
Doug Goldstein
4b6944d3c0 python: remove virConnectGetCPUModelNames from globals
Commit de51dc9c9aed0e615c8b301cccb89f4859324eb0 primarily added
virConnectGetCPUModelNames as libvirt.getCPUModelNames(conn, arch)
instead of libvirt.virConnect.getCPUModelNames(arch) so revert the code
that does the former while leaving the code that does the later.
2013-11-21 08:47:08 -06:00
Eric Blake
9e8b8a824d maint: fix comma style issues: python
Most of our code base uses space after comma but not before;
fix the remaining uses before adding a syntax check.

* python/libvirt-override.c: Consistently use commas.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-11-20 09:14:55 -07:00
Doug Goldstein
34b7679331 Add missing break to switch-case block
The case label for VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED did not have its
own break statement but relied on falling through which we probably
don't want.
2013-11-19 10:29:28 -06:00
Marian Neagul
1da4ac52f5 python: Fix Create*WithFiles filefd passing
Commit d76227be added functions virDomainCreateWithFiles and
virDomainCreateXMLWithFiles, but there was a little piece missing in
python bindings.  This patch fixes proper passing of file descriptors
in the overwrites of these functions.
v1.1.4 v1.1.4-rc2 v1.1.4-rc1
2013-10-22 23:01:18 +01:00
Daniel P. Berrange
15c6588cf5 Don't link virt-login-shell against libvirt.so (CVE-2013-4400)
The libvirt.so library has far too many library deps to allow
linking against it from setuid programs. Those libraries can
do stuff in __attribute__((constructor) functions which is
not setuid safe.

The virt-login-shell needs to link directly against individual
files that it uses, with all library deps turned off except
for libxml2 and libselinux.

Create a libvirt-setuid-rpc-client.la library which is linked
to by virt-login-shell. A config-post.h file allows this library
to disable all external deps except libselinux and libxml2.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
CVE-2013-4400-3
2013-10-21 14:03:52 +01:00
Eric Blake
90461df0ca maint: avoid 'const fooPtr' in python bindings
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in the python bindings.

* python/generator.py (py_types): Drop useless conversions.
* python/libvirt-override.c (getPyVirTypedParameter)
(setPyVirTypedParameter): Use intended type.

Signed-off-by: Eric Blake <eblake@redhat.com>
CVE-2013-4400-2 CVE-2013-4400-1 CVE-2013-4401
2013-10-14 14:34:37 -06:00
Michal Privoznik
bc11687229 python: Document virNodeGetInfo bug
The memory size in virNodeGetInfo python API binding is reported in MiB
instead of KiB (like we have in C struct). However, there already might
be applications out there relying on this inconsistence so we can't
simply fix it. Document this sad fact as known bug.
v1.1.3
2013-09-30 11:42:52 +02:00
Giuseppe Scrivano
357df252fb python: add bindings for virConnectGetCPUModelNames
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
CVE-2013-4399 v1.1.3-rc2 v1.1.3-rc1
2013-09-23 16:59:39 -06:00
Giuseppe Scrivano
9d091faa7d libvirt: add new public API virConnectGetCPUModelNames
The new function virConnectGetCPUModelNames allows to retrieve the list
of CPU models known by the hypervisor for a specific architecture.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-23 15:41:50 -06:00
Daniel P. Berrange
793ca0c3b1 Fix potential use of uninitialized value in virDomainGetVcpuPinInfo
The virDomainGetVcpuPinInfo python wrapper had a potential use of
uninitialized values

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-20 17:22:39 +01:00
Oskari Saarenmaa
44dce1e00f docs, comments: minor typo fixes
Signed-off-by: Oskari Saarenmaa <os@ohmu.fi>
Signed-off-by: Eric Blake <eblake@redhat.com>
CVE-2013-4311 CVE-2013-4296
2013-09-10 17:06:41 -06:00
Eric Blake
58b82e0d57 build: enforce makefile conditional style
Automake has builtin support to prevent botched conditional nesting,
but only if you use:
if FOO
else !FOO
endif !FOO

An example error message when using the wrong name:

daemon/Makefile.am:378: error: else reminder (LIBVIRT_INIT_SCRIPT_SYSTEMD_TRUE) incompatible with current conditional: LIBVIRT_INIT_SCRIPT_SYSTEMD_FALSE
daemon/Makefile.am:381: error: endif reminder (LIBVIRT_INIT_SCRIPT_SYSTEMD_TRUE) incompatible with current conditional: LIBVIRT_INIT_SCRIPT_SYSTEMD_FALSE

As our makefiles tend to have quite a bit of nested conditionals,
it's better to take advantage of the benefits of the build system
double-checking that our conditionals are well-nested, but that
requires a syntax check to enforce our usage style.

Alas, unlike C preprocessor and spec files, we can't use indentation
to make it easier to see how deeply nesting goes.

* cfg.mk (sc_makefile_conditionals): New rule.
* daemon/Makefile.am: Enforce the style.
* gnulib/tests/Makefile.am: Likewise.
* python/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* tests/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-04 09:40:20 -06:00
Ján Tomko
ed0a51292d Fix leaks in python bindings
https://bugzilla.redhat.com/show_bug.cgi?id=1003828
CVE-2013-4297
2013-09-03 13:19:17 +02:00
Guan Qiang
bf69603b24 python: Fix a PyList usage mistake
Fix PyList usage mistake in Function libvirt_lxc_virDomainLxcOpenNamespace.

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

Signed-off-by: Eric Blake <eblake@redhat.com>
v1.1.2 v1.1.2-rc2 CVE-2013-4291 CVE-2013-4292
2013-08-29 06:52:56 -06:00
Claudio Bley
1f01027098 python: simplify complicated conditional assignment v1.1.2-rc1 2013-08-23 10:54:58 +02:00
Claudio Bley
d101d3bce8 Test for object identity when checking for None in Python
Consistently use "is" or "is not" to compare variables to None,
because doing so is preferrable, as per PEP 8
(http://www.python.org/dev/peps/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
> is not, never the equality operators.
2013-08-23 08:12:26 +02:00
Guido Günther
2d533bde3b python: Use RELRO_LDFLAGS and NO_INDIRECT_LDFLAGS
A readonly GOT and detecting indirect linkage is useful here too.
2013-08-22 16:17:36 +02:00
Daniel P. Berrange
a85bf91386 Delete obsolete / unused python test files
The python/tests directory contains a number of so called
"tests" for the python API. These are all hardcoded to
look for Xen and cannot be run in any automated fashion,
and no one is ever manually running them. Given that they
don't meaningully contribute to the test coverage, delete
them.

For some reason these tests were also copied into the
filesystem as part of 'make install'. The change to the
RPM in commit 3347a4203278ec93d7b0ceb88b5ed10e4f14765c
caused a build failure, since it removed the code which
deleted these installed tests.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
CVE-2013-5651 CVE-2013-4239
2013-07-30 14:13:58 +01:00
Cole Robinson
9dd30d2725 python: Drop TODO
File hasn't been really touched for 7 years. And with recent rawhide
changes it contributed to an RPM build failure. Let's drop it.

This also removes installation of a libvirt-python doc dir, so drop
handling of it from the RPM spec.
v1.1.1 libvirt-1.1.1-1.el7
2013-07-29 07:54:18 -04:00
Eric Blake
a5328130d1 maint: split long lines in Makefiles
Makefiles are another easy file to enforce line limits.

Mostly straightforward; interesting tricks worth noting:
src/Makefile.am: $(confdir) was already defined, use it in more places
tests/Makefile.am: path_add and VG required some interesting compression

* cfg.mk (sc_prohibit_long_lines): Add another test.
* Makefile.am: Fix offenders.
* daemon/Makefile.am: Likewise.
* docs/Makefile.am: Likewise.
* python/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* tests/Makefile.am: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
v1.1.1-rc2 v1.1.1-rc1
2013-07-19 05:25:35 -06:00
Jiri Denemark
8566ca3ad1 Add VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event 2013-07-18 15:28:45 +02:00
Daniel P. Berrange
03e7cacfa2 Introduce new domain create APIs to pass pre-opened FDs to LXC
With container based virt, it is useful to be able to pass
pre-opened file descriptors to the container init process.
This allows for containers to be auto-activated from incoming
socket connections, passing the active socket into the container.

To do this, introduce a pair of new APIs, virDomainCreateXMLWithFiles
and virDomainCreateWithFiles, which accept an array of file
descriptors. For the LXC driver, UNIX file descriptor passing
will be used to send them to libvirtd, which will them pass
them down to libvirt_lxc, which will then pass them to the container
init process.

This will only be implemented for LXC right now, but the design
is generic enough it could work with other hypervisors, hence
I suggest adding this to libvirt.so, rather than libvirt-lxc.so

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-18 11:01:14 +01:00
Guannan Ren
f8bc3a9ccc python: return dictionary without value in case of no blockjob
Currently, when there is no blockjob, dom.blockJobInfo('vda')
still reports error because it doesn't distinguish return value 0 from -1.
libvirt.libvirtError: virDomainGetBlockJobInfo() failed

virDomainGetBlockJobInfo() API return value:
 -1 in case of failure, 0 when nothing found, 1 found.

And use PyDict_SetItemString instead of PyDict_SetItem when key is
of string type. PyDict_SetItemString increments key/value reference
count, so call Py_DECREF() for value. For key, we don't need to
do this, because PyDict_SetItemString will handle it internally.
CVE-2013-4153 CVE-2013-4154
2013-07-15 18:20:42 +08:00
Daniel P. Berrange
82395204f3 Convert 'int i' to 'size_t i' in python/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-10 17:55:17 +01:00
Michal Privoznik
8eceaa39e2 viralloc: Report OOM error on failure
Similarly to VIR_STRDUP, we want the OOM error to be reported in
VIR_ALLOC and friends.
CVE-2013-2230
2013-07-10 11:07:31 +02:00
Jiri Denemark
9b3d789449 python: Add bindings for extensible migration APIs
The patch implements wrappers for virDomainMigrate3 and
virDomainMigrateToURI3.
CVE-2013-2218 v1.1.0 v1.1.0-rc2 v1.1.0-rc1
2013-06-25 01:28:39 +02:00
Jiri Denemark
1c94615878 Extensible migration APIs
This patch introduces two new APIs virDomainMigrate3 and
virDomainMigrateToURI3 that may be used in place of their older
variants. These new APIs take optional migration parameters (such as
bandwidth, domain XML, ...) in an array of virTypedParameters, which
makes adding new parameters easier as there's no need to introduce new
APIs whenever a new migration parameter needs to be added. Both APIs are
backward compatible and will automatically use older migration calls in
case the new calls are not supported as long as the typed parameters
array does not contain any parameter which was not supported by the
older calls.
2013-06-25 01:24:53 +02:00