| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
The libvirt_intWrap() accepts an integer and passes it to
PyLong_FromLong() which accepts a long. It's perfectly okay to
let compiler do that implicitly.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
|
|
|
|
| |
Python C API offers PyLong_FromUnsignedLong() which allows us to
drop typecast.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
|
|
|
|
|
| |
Python C API offers PyLong_AsUnsignedLong() which already raises
an exception on negative values. Rewrite our libvirt_uintUnwrap()
to use that and drop check for negative values.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
|
|
|
| |
Mingw-w64 target does not support uint definition.
Signed-off-by: Bastian Germann <bage@linutronix.de>
|
|
|
|
|
|
|
|
|
| |
python2 will be end of life by the time of the next
libvirt release. All our supported build targets, including
CentOS7, have a python3 build available.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
|
|
|
|
|
| |
Copies heavily from existing virDomainSnapshot handling, regarding
what special cases the generator has to be taught and what overrides
need to be written.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
|
|
|
|
|
| |
Define the various rules in the generator to wire up methods into the
virNetwork class and create the new virNetworkPort class.
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
| |
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
|
|
|
|
| |
If the function fails it should always set an exception.
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
|
|
|
|
|
|
| |
When python3 builds C modules, it adds the -Wsign-compare flag to GCC.
This creates lots of warnings where we compare a 'size_t' value against
an 'int' value due to signed/unsigned difference. Change all the size_t
types to ssize_t to address this.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
| |
To insert Py_None into some other python object like dict or tuple, you
need to increase reference to the Py_None. We have a macro to do that.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
|
| |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
|
|
|
| |
Follow the libvirt hacking guide and make the code consistent.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If hypervisor is not Xen, the errs in struct _virDomainBlockStats will be -1.
But in KVM when we call domain.blockStats(), errs is 18446744073709551615.
To fix that, this patch has two changes:
1. Replace use of the PyLong_FromUnsignedLongLong with PyLong_FromLongLong
in function libvirt_longlongWrap
2. If the paramemter of libvirt_longlongWrap is unsigned long long,
use libvirt_ulonglongWrap instead because of above change.
After this patch, errs is -1 which is consistent with virDomainBlockStats api.
Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
|
|
|
|
|
|
|
|
| |
The PyUnicode_AsUTF8 method doesn't exist prior to Python 3.3.
It is also somewhat inefficient, so rewrite it to use an
intermediate PyBytes object.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
|
| |
Instead of using a 'z#i' format string to receive byte array,
use 'O' and then libvirt_charPtrSizeUnwrap. This lets us hide
the Python 3 vs 2 differences in typewrappers.c
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
| |
In Python3 the PyInt / PyLong types have merged into a single
PyLong type. Conditionalize the use of PyInt to Python 2 only
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
|
| |
Replace use of PyString with either PyBytes or PyUnicode.
The former is used for buffers with explicit sizes, which
are used by APIs processing raw bytes.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
|
|
| |
Replace use of the PyInt_FromLong and PyLong_FromLongLong
with libvirt_{int,uint,longlong,ulonglong}Wrap helpers.
This isolates the need for Python3 specific code in one
place.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Replace calls to PyString_AsString with the helper method
libvirt_charPtrUnwrap. This isolates the code that will
change in Python3.
In making this change, all callers now have responsibility
for free'ing the string.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
| |
Functions should not make assumptions about the memory management
callers use for parameters
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
|
| |
The virNodeGetSecurityModel, virDomainGetSecurityLabel and
virDomainGetSecurityLabelList methods were disabled in the
python binding for inexplicable reasons.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
| |
Import the libvirt memory allocation functions, stripping the OOM
testing and error reporting pieces.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
libvirt_ulonglongUnwrap requires the integer type of python obj.
But libvirt_longlongUnwrap still could handle python obj of
Pyfloat_type which causes the float value to be rounded up
to an integer.
For example
>>> dom.setSchedulerParameters({'vcpu_quota': 0.88})
0
libvirt_longlongUnwrap treats 0.88 as a valid value 0
However
>>> dom.setSchedulerParameters({'cpu_shares': 1000.22})
libvirt_ulonglongUnwrap will throw out an error
"TypeError: an integer is required"
The patch make this consistent.
|
|
|
|
|
|
|
|
|
|
| |
The result is indeterminate for NULL argument to python
functions as follows. It's better to return negative value in
these situations.
PyObject_IsTrue will segfault if the argument is NULL
PyFloat_AsDouble(NULL) is -1.000000
PyLong_AsUnsignedLongLong(NULL) is 0.000000
|
|
|
|
|
|
|
|
|
|
|
| |
Below code failed to compile on a 32 bit machine with error
typewrappers.c: In function 'libvirt_intUnwrap':
typewrappers.c:135:5: error: logical 'and' of mutually exclusive tests is always false [-Werror=logical-op]
cc1: all warnings being treated as errors
The patch fixes this error.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Laszlo Ersek pointed out that in trying to convert a long to an
unsigned int, we used:
long long_val = ...;
if ((unsigned int)long_val == long_val)
According to C99 integer promotion rules, the if statement is
equivalent to:
(unsigned long)(unsigned int)long_val == (unsigned long)long_val
since you get an unsigned comparison if at least one side is
unsigned, using the largest rank of the two sides; but on 32-bit
platforms, where unsigned long and unsigned int are the same size,
this comparison is always true and ends up converting negative
long_val into posigive unsigned int values, rather than rejecting
the negative value as we had originally intended (python longs
are unbounded size, and we don't want to do silent modulo
arithmetic when converting to C code).
Fix this by using direct comparisons, rather than casting.
* python/typewrappers.c (libvirt_intUnwrap, libvirt_uintUnwrap)
(libvirt_ulongUnwrap, libvirt_ulonglongUnwrap): Fix conversion
checks.
|
|
|
|
|
|
|
|
|
|
|
| |
int libvirt_intUnwrap(PyObject *obj, int *val);
int libvirt_uintUnwrap(PyObject *obj, unsigned int *val);
int libvirt_longUnwrap(PyObject *obj, long *val);
int libvirt_ulongUnwrap(PyObject *obj, unsigned long *val);
int libvirt_longlongUnwrap(PyObject *obj, long long *val);
int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val);
int libvirt_doubleUnwrap(PyObject *obj, double *val);
int libvirt_boolUnwrap(PyObject *obj, bool *val);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Return statements with parameter enclosed in parentheses were modified
and parentheses were removed. The whole change was scripted, here is how:
List of files was obtained using this command:
git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' | \
grep -e '\.[ch]$' -e '\.py$'
Found files were modified with this command:
sed -i -e \
's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
-e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
Then checked for nonsense.
The whole command looks like this:
git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' | \
grep -e '\.[ch]$' -e '\.py$' | xargs sed -i -e \
's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
-e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch starts the process of elevating the python binding code
to be on the same level as the rest of libvirt when it comes to
requiring good coding styles. Statically linking against the
libvirt_util library makes it much easier to write good code,
rather than having to open-code and reinvent things locally.
Done by global search and replace of s/free(/VIR_FREE(/, followed
by hand-inspection of remaining malloc and redundant memset.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_raw_allocation):
Remove python from exemption.
* python/Makefile.am (INCLUDES): Add gnulib and src/util. Drop
$(top_builddir)/$(subdir), as automake already guarantees that.
(mylibs, myqemulibs): Pull in libvirt_util and gnulib.
(libvirtmod_la_CFLAGS): Catch compiler warnings if configured to
use -Werror.
* python/typewrappers.c (libvirt_charPtrSizeWrap)
(libvirt_charPtrWrap): Convert free to VIR_FREE.
* python/generator.py (print_function_wrapper): Likewise.
* python/libvirt-override.c: Likewise.
|
|
|
|
|
|
|
|
|
| |
I noticed some redundant code while preparing my next patch.
* python/generator.py (py_types): Fix 'const char *' mapping.
* python/typewrappers.h (libvirt_charPtrConstWrap): Drop.
* python/typewrappers.c (libvirt_charPtrConstWrap): Delete, since
it is identical to libvirt_constcharPtrWrap.
|
|
|
|
|
|
|
| |
The return values for the python version are different that the C version
of virStreamSend: on success we return a string, an error raises an exception,
and if the stream would block we return int(-2). We need to do this
since strings aren't passed by reference in python.
|
|
|
|
|
|
|
|
|
|
| |
On Fedore 14, virt-manager spews a bunch of warnings to the console:
/usr/lib64/python2.7/site-packages/libvirt.py:1781: PendingDeprecationWarning: The CObject type is marked Pending Deprecation in Python 2.7. Please use capsule objects instead.
Have libvirt use the capsule API if available. I've verified this compiles
fine on older python (2.6 in RHEL6 which doesn't have capsules), and
virt-manager seems to function fine.
|
|
|
|
|
| |
I have primarily followed the pattern of the 'secret' driver to provide
support for the missing python bindings for the network filter API.
|
|
|
|
| |
Signed-off-by: Chris Lalancette <clalance@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Introduce a new public API that provides a way to get progress
info on currently running jobs on a virDomainpPtr. APIs that
are initially within scope of this idea are
virDomainMigrate
virDomainMigrateToURI
virDomainSave
virDomainRestore
virDomainCoreDump
These all take a potentially long time and benefit from monitoring.
The virDomainJobInfo struct allows for various pieces of information
to be reported
- Percentage completion
- Time
- Overall data
- Guest memory data
- Guest disk/file data
* include/libvirt/libvirt.h.in: Add virDomainGetJobInfo
* python/generator.py, python/libvirt-override-api.xml,
python/libvirt-override.c: Override for virDomainGetJobInfo API
* python/typewrappers.c, python/typewrappers.h: Introduce wrapper
for unsigned long long type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* include/libvirt/libvirt.h.in: Public API contract for
virStreamPtr object
* src/libvirt_public.syms: Export data stream APIs
* src/libvirt_private.syms: Export internal helper APIs
* src/libvirt.c: Data stream API driver dispatch
* src/datatypes.h, src/datatypes.c: Internal helpers for virStreamPtr
object
* src/driver.h: Define internal driver API for streams
* .x-sc_avoid_write: Ignore src/libvirt.c because it trips
up on comments including write()
* python/Makefile.am: Add libvirt-override-virStream.py
* python/generator.py: Add rules for virStreamPtr class
* python/typewrappers.h, python/typewrappers.c: Wrapper
for virStreamPtr
* docs/libvirt-api.xml, docs/libvirt-refs.xml: Regenerate
with new APIs
|
|
* README: New file describing what each file is used for
* livvirt-override.c, libvirt-override.py, libvirt-override-api.xml,
libvirt-override-virConnect.py: Manually written code overriding
the generator
* typewrappers.c, typewrappers.h: Data type wrappers
* generator.py: Automatically pre-prend contents of libvirt-override.py
to generated libvirt.py. Output into libvirt.py directly instead of
libvirtclass.py. Don't generate libvirtclass.txt at all. Write C
files into libvirt.c/.h directly
* Makefile.am: Remove rule for creating libvirt.py from libvirt-override.py
and libvirtclass.py, since generator.py does it directly
|