libvirt-python/ericb.git
10 years agopython: Fix the forward_null error in Python binding codeslibvirt-0.9.10-17.el6libvirt-0.9.10-18.el6libvirt-0.9.10-19.el6libvirt-0.9.10-20.el6libvirt-0.9.10-21.el6libvirt-0.9.10-21.el6_3.1libvirt-0.9.10-21.el6_3.2libvirt-0.9.10-21.el6_3.3libvirt-0.9.10-21.el6_3.4libvirt-0.9.10-21.el6_3.5libvirt-0.9.10-21.el6_3.6libvirt-0.9.10-21.el6_3.7libvirt-0.9.10-21.el6_3.8
Osier Yang [Mon, 7 May 2012 11:02:12 +0000 (7 19:02 +0800)]
python: Fix the forward_null error in Python binding codes

This patch resolves: https://bugzilla.redhat.com/show_bug.cgi?id=771021
(cherry picked from commit b80f4db9931ceea4bec1d178322058df77ece7a4)

Related coverity log:

Error: FORWARD_NULL:
/builddir/build/BUILD/libvirt-0.9.10/python/libvirt-override.c:355:
assign_zero: Assigning: "params" = 0.
/builddir/build/BUILD/libvirt-0.9.10/python/libvirt-override.c:458:
var_deref_model: Passing null variable "params" to function
"getPyVirTypedParameter", which dereferences it. (The dereference is assumed on
the basis of the 'nonnull' parameter attribute.)

10 years agopython: improve conversion validationlibvirt-0.9.10-10.el6libvirt-0.9.10-11.el6libvirt-0.9.10-13.el6libvirt-0.9.10-14.el6libvirt-0.9.10-15.el6libvirt-0.9.10-16.el6
Eric Blake [Sat, 31 Mar 2012 15:45:48 +0000 (31 09:45 -0600)]
python: improve conversion validation

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

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.
(cherry picked from commit 4a86c2bb4b2d8183b76ba44659bb6d2eab1f1573)

10 years agopython: make python APIs use these helper functions
Guannan Ren [Wed, 28 Mar 2012 15:41:05 +0000 (28 09:41 -0600)]
python: make python APIs use these helper functions

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

    *setPyVirTypedParameter
    *libvirt_virDomainGetCPUStats
(cherry picked from commit 1aeb3d9e7f3a967f7d5e59f852e804aef0786f6c)

10 years agopython: Add new helper functions for python to C integral conversion
Guannan Ren [Wed, 28 Mar 2012 15:41:04 +0000 (28 09:41 -0600)]
python: Add new helper functions for python to C integral conversion

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

    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);
(cherry picked from commit 384ebd3fc5deec035d6894352a25fd2b7f637cf0)

10 years agoAdd support for event tray moved of removable diskslibvirt-0.9.10-7.el6libvirt-0.9.10-8.el6libvirt-0.9.10-9.el6
Osier Yang [Mon, 26 Mar 2012 04:12:00 +0000 (26 12:12 +0800)]
Add support for event tray moved of removable disks

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

This patch introduces a new event type for the QMP event
DEVICE_TRAY_MOVED, which occurs when the tray of a removable
disk is moved (i.e opened or closed):

    VIR_DOMAIN_EVENT_ID_TRAY_CHANGE

The event's data includes the device alias and the reason
for tray status' changing, which indicates why the tray
status was changed. Thus the callback definition for the event
is:

enum {
    VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN = 0,
    VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE,

\#ifdef VIR_ENUM_SENTINELS
    VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST
\#endif
} virDomainEventTrayChangeReason;

typedef void
(*virConnectDomainEventTrayChangeCallback)(virConnectPtr conn,
                                           virDomainPtr dom,
                                           const char *devAlias,
                                           int reason,
                                           void *opaque);
(cherry picked from commit a26a1969c37c865b18294c5717544c1dc90beb3c)

Conflicts:

src/qemu/qemu_monitor_json.c:
          No SPICE_* events in RHEL && no __com.redhat_SPICE_* events
          in upstream.
src/remote/remote_protocol.x
src/remote_protocol-structs:
          No PM_WAKEUP PROC in RHEL tree

10 years agopython: add virDomainGetCPUStats python binding API
Guannan Ren [Thu, 22 Mar 2012 17:10:46 +0000 (23 01:10 +0800)]
python: add virDomainGetCPUStats python binding API

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

    dom.getCPUStats(True, 0)
      [{'cpu_time': 24699446159L, 'system_time': 10870000000L, 'user_time': 950000000L}]
    dom.getCPUStats(False, 0)
      [{'cpu_time': 8535292289L}, {'cpu_time': 1005395355L}, {'cpu_time': 9351766377L}, {'cpu_time': 5813545649L}]

    *generator.py Add a new naming rule
    *libvirt-override-api.xml The API function description
    *libvirt-override.c Implement it.
(cherry picked from commit a772f4eebc9e62870ac03dfaaac1102d0fa967b4)

10 years agopython: Avoid memory leaks on libvirt_virNodeGetCPUStats
Alex Jia [Thu, 22 Mar 2012 08:54:03 +0000 (22 09:54 +0100)]
python: Avoid memory leaks on libvirt_virNodeGetCPUStats

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

Detected by valgrind. Leaks are introduced in commit 4955602.

* python/libvirt-override.c (libvirt_virNodeGetCPUStats): fix memory leaks
and improve codes return value.

For details, please see the following link:
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770943

Signed-off-by: Alex Jia <ajia@redhat.com>
(cherry picked from commit 558ebc256dc8179413b1f35d91cd5167e41633cb)

10 years agopython: Avoid memory leaks on libvirt_virNodeGetMemoryStats
Alex Jia [Wed, 21 Mar 2012 16:01:22 +0000 (21 17:01 +0100)]
python: Avoid memory leaks on libvirt_virNodeGetMemoryStats

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

Detected by valgrind. Leaks are introduced in commit 17c7795.

* python/libvirt-override.c (libvirt_virNodeGetMemoryStats): fix memory leaks
and improve codes return value.

For details, please see the following link:
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770944

Signed-off-by: Alex Jia <ajia@redhat.com>
(cherry picked from commit 53b45aa494a94854862603f5694d137f928edfdd)

10 years agopython: Expose virDomain{G,S}etInterfaceParameters APIs in python bindinglibvirt-0.9.10-2.el6libvirt-0.9.10-3.el6libvirt-0.9.10-4.el6libvirt-0.9.10-5.el6libvirt-0.9.10-6.el6
Alex Jia [Tue, 14 Feb 2012 02:46:23 +0000 (14 10:46 +0800)]
python: Expose virDomain{G,S}etInterfaceParameters APIs in python binding

The v4 patch corrects indentation issues.

The v3 patch follows latest python binding codes and change 'size'
type from int to Py_ssize_t.

An simple example to show how to use it:

import libvirt

conn = libvirt.open(None)
dom = conn.lookupByName('foo')

print dom.interfaceParameters('vnet0', 0)

params = {'outbound.peak': 10,
          'inbound.peak': 10,
          'inbound.burst': 20,
          'inbound.average': 20,
          'outbound.average': 30,
          'outbound.burst': 30}

print dom.setInterfaceParameters('vnet0', params, 0)
print dom.interfaceParameters('vnet0', 0)

Signed-off-by: Alex Jia <ajia@redhat.com>
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=770971
cherry-pick from 8b29c4598609d9b22a39e6f6bf3bf7afe8303faa

10 years agopython: make other APIs share common {get, set}PyVirTypedParameterv0.9.10
Guannan Ren [Fri, 10 Feb 2012 10:17:26 +0000 (10 18:17 +0800)]
python: make other APIs share common {get, set}PyVirTypedParameter

        *libvirt_virDomainBlockStatsFlags
        *libvirt_virDomainGetSchedulerParameters
        *libvirt_virDomainGetSchedulerParametersFlags
        *libvirt_virDomainSetSchedulerParameters
        *libvirt_virDomainSetSchedulerParametersFlags
        *libvirt_virDomainSetBlkioParameters
        *libvirt_virDomainGetBlkioParameters
        *libvirt_virDomainSetMemoryParameters
        *libvirt_virDomainGetMemoryParameters
        *libvirt_virDomainSetBlockIoTune
        *libvirt_virDomainGetBlockIoTune

10 years agopython: refactoring virTypedParameter conversion for NUMA tuning APIs
Guannan Ren [Wed, 8 Feb 2012 12:20:50 +0000 (8 20:20 +0800)]
python: refactoring virTypedParameter conversion for NUMA tuning APIs

          *getPyVirTypedParameter
          *setPyVirTypedParameter
          *virDomainSetNumaParameters
          *virDomainGetNumaParameters

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agopython: Correct arguments number for migrateSetMaxSpeed
Osier Yang [Wed, 8 Feb 2012 09:33:22 +0000 (8 17:33 +0800)]
python: Correct arguments number for migrateSetMaxSpeed

The API definition accepts "flags" argument, however, the
implementation ignores it, though "flags" is unused currently,
we should expose it instead of hard coding, the API
implementation inside hypervisor driver is responsible to check
if the passed "flags" is valid.

10 years agopython: drop unused functionv0.9.10-rc2
Eric Blake [Wed, 8 Feb 2012 00:14:11 +0000 (7 17:14 -0700)]
python: drop unused function

Gcc warned about an unused static function.

* python/libvirt-qemu-override.c (py_str): Delete.

10 years agopyhton: Don't link against libvirt_util.la
Michal Privoznik [Tue, 7 Feb 2012 12:30:42 +0000 (7 13:30 +0100)]
pyhton: Don't link against libvirt_util.la

As we already link with libvirt.la which contains libvirt_utils.la.
Double linking causes global symbols to be presented twice and
thus confusion. This partially reverts c700613b8d463212d142c97108b7a2352e23e559

10 years agomaint: consolidate several .gitignore filesv0.9.10-rc1
Eric Blake [Fri, 3 Feb 2012 21:30:06 +0000 (3 14:30 -0700)]
maint: consolidate several .gitignore files

Unlike .cvsignore under CVS, git allows for ignoring nested
names.  We weren't very consistent where new tests were
being ignored (some in .gitignore, some in tests/.gitignore),
and I found it easier to just consolidate everything.

* .gitignore: Subsume entries from subdirectories.
* daemon/.gitignore: Delete.
* docs/.gitignore: Likewise.
* docs/devhelp/.gitignore: Likewise.
* docs/html/.gitignore: Likewise.
* examples/dominfo/.gitignore: Likewise.
* examples/domsuspend/.gitignore: Likewise.
* examples/hellolibvirt/.gitignore: Likewise.
* examples/openauth/.gitignore: Likewise.
* examples/domain-events/events-c/.gitignore: Likewise.
* include/libvirt/.gitignore: Likewise.
* src/.gitignore: Likewise.
* src/esx/.gitignore: Likewise.
* tests/.gitignore: Likewise.
* tools/.gitignore: Likewise.

10 years agoAdded missing memory reporting into python bindings
Martin Kletzander [Fri, 3 Feb 2012 14:53:06 +0000 (3 15:53 +0100)]
Added missing memory reporting into python bindings

Two types of memory stats were not reported by python bindings. This
patch fixes both of them.

10 years agopython: use libvirt_util to avoid raw free
Eric Blake [Thu, 2 Feb 2012 22:45:54 +0000 (2 15:45 -0700)]
python: use libvirt_util to avoid raw free

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.

10 years agopython: drop redundant function
Eric Blake [Thu, 2 Feb 2012 23:28:26 +0000 (2 16:28 -0700)]
python: drop redundant function

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.

10 years agobuild: clean up CPPFLAGS/INCLUDES usage
Eric Blake [Thu, 2 Feb 2012 20:20:09 +0000 (2 13:20 -0700)]
build: clean up CPPFLAGS/INCLUDES usage

Our syntax checker missed all-lower-case variables (this will
be fixed by the next .gnulib update).  Additionally, anywhere
that we mix in-tree files with generated files, automake recommends
listing builddir prior to srcdir for VPATH builds.

* src/Makefile.am (*_la_CFLAGS): Favor $(top_srcdir).
(INCLUDES): Likewise, and follow automake recommendations on
builddir before srcdir.
* python/Makefile.am (INCLUDES): Swap directory order.
* tests/Makefile.am (INCLUDES): Likewise.
* tools/Makefile.am (INCLUDES): Likewise.
* daemon/Makefile.am (INCLUDES): Likewise.
(libvirtd.init, libvirtd.service): Favor $().
* examples/hellolibvirt/Makefile.am (hellolibvirt_LDADD):
Likewise.
* examples/openauth/Makefile.am (openauth_LDADD): Likewise.
* examples/dominfo/Makefile.am (INCLUDES): Drop dead include.
* examples/domsuspend/Makefile.am (INCLUDES): Likewise.

10 years agopython: Add binding for virDomainGetDiskErrors
Jiri Denemark [Tue, 31 Jan 2012 06:34:51 +0000 (31 07:34 +0100)]
python: Add binding for virDomainGetDiskErrors

10 years agovirDomainGetDiskErrors public API
Jiri Denemark [Tue, 31 Jan 2012 06:41:53 +0000 (31 07:41 +0100)]
virDomainGetDiskErrors public API

We already provide ways to detect when a domain has been paused as a
result of I/O error, but there was no way of getting the exact error or
even the device that experienced it.  This new API may be used for both.

10 years agopython: correct a copy-paste error
Alex Jia [Wed, 1 Feb 2012 07:00:12 +0000 (1 15:00 +0800)]
python: correct a copy-paste error

* python/libvirt-override-virStream.py: fix a copy-paste error in sendAll().

Signed-off-by: Alex Jia <ajia@redhat.com>
10 years agoAdd new public API virDomainGetCPUStats()
KAMEZAWA Hiroyuki [Sat, 28 Jan 2012 06:20:28 +0000 (28 15:20 +0900)]
Add new public API virDomainGetCPUStats()

add new API virDomainGetCPUStats() for getting cpu accounting information
per real cpus which is used by a domain.  The API is designed to allow
future extensions for additional statistics.

based on ideas by Lai Jiangshan and Eric Blake.

* src/libvirt_public.syms: add API for LIBVIRT_0.9.10
* src/libvirt.c: define virDomainGetCPUStats()
* include/libvirt/libvirt.h.in: add virDomainGetCPUStats() header
* src/driver.h: add driver API
* python/generator.py: add python API (as not implemented)

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoresize: add virStorageVolResize() API
Zeeshan Ali (Khattak) [Fri, 27 Jan 2012 05:29:56 +0000 (27 07:29 +0200)]
resize: add virStorageVolResize() API

Add a new function to allow changing of capacity of storage volumes.
Plan out several flags, even if not all of them will be implemented
up front.

Expose the new command via 'virsh vol-resize'.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoAPI: make declaration of _LAST enum values conditional
Eric Blake [Fri, 20 Jan 2012 18:43:28 +0000 (20 11:43 -0700)]
API: make declaration of _LAST enum values conditional

Although this is a public API break, it only affects users that
were compiling against *_LAST values, and can be trivially
worked around without impacting compilation against older
headers, by the user defining VIR_ENUM_SENTINELS before using
libvirt.h.  It is not an ABI break, since enum values do not
appear as .so entry points.  Meanwhile, it prevents users from
using non-stable enum values without explicitly acknowledging
the risk of doing so.

See this list discussion:
https://www.redhat.com/archives/libvir-list/2012-January/msg00804.html

* include/libvirt/libvirt.h.in: Hide all sentinels behind
LIBVIRT_ENUM_SENTINELS, and add missing sentinels.
* src/internal.h (VIR_DEPRECATED): Allow inclusion after
libvirt.h.
(LIBVIRT_ENUM_SENTINELS): Expose sentinels internally.
* daemon/libvirtd.h: Use the sentinels.
* src/remote/remote_protocol.x (includes): Don't expose sentinels.
* python/generator.py (enum): Likewise.
* tests/cputest.c (cpuTestCompResStr): Silence compiler warning.
* tools/virsh.c (vshDomainStateReasonToString)
(vshDomainControlStateToString): Likewise.

10 years agodomiftune: Add API virDomain{S,G}etInterfaceParametersv0.9.9v0.9.9-rc1v0.9.9-rc2
Hu Tao [Thu, 29 Dec 2011 07:33:16 +0000 (29 15:33 +0800)]
domiftune: Add API virDomain{S,G}etInterfaceParameters

The APIs are used to set/get domain's network interface's parameters.
Currently supported parameters are bandwidth settings.

* include/libvirt/libvirt.h.in: new API and parameters definition
* python/generator.py: skip the Python API generation
* src/driver.h: add new entry to the driver structure
* src/libvirt_public.syms: export symbols

10 years agoremove a static limit on max domains in python bindings
Daniel Veillard [Thu, 29 Dec 2011 08:20:00 +0000 (29 16:20 +0800)]
remove a static limit on max domains in python bindings

* python/libvirt-override.c: remove the predefined array in the
  virConnectListDomainsID binding and call virConnectNumOfDomains
  to do a proper allocation

10 years agopython: Fix problems of virDomain{Set, Get}BlockIoTune bindings
Alex Jia [Thu, 29 Dec 2011 05:22:52 +0000 (29 13:22 +0800)]
python: Fix problems of virDomain{Set, Get}BlockIoTune bindings

The parameter 'params' is useless for virDomainGetBlockIoTune API,
and the return value type should be a virTypedParameterPtr but not
integer. And "PyArg_ParseTuple" in functions
libvirt_virDomain{Set,Get}BlockIoTune misses format unit for "format"
argument.

* libvirt-override-api.xml: Remove useless the parameter 'params'
from virDomainGetBlockIoTune API, and change return value type from
integer to virTypedParameterPtr.

* python/libvirt-override.c: Add the missed format units.

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

Signed-off-by: Alex Jia <ajia@redhat.com>
10 years agoadd new API virDomain{G, S}etNumaParameters
Hu Tao [Tue, 20 Dec 2011 08:35:00 +0000 (20 16:35 +0800)]
add new API virDomain{G, S}etNumaParameters

Set up the types for the numa functions and insert them into the
virDriver structure definition.

10 years agopython: plug memory leak on libvirt_virConnectOpenAuth
Alex Jia [Mon, 19 Dec 2011 08:12:19 +0000 (19 16:12 +0800)]
python: plug memory leak on libvirt_virConnectOpenAuth

* Detected by valgrind. Leak introduced in commit 5ab109f.

* python/libvirt-override.c: avoid memory leak on libvirt_virConnectOpenAuth.

* How to reproduce?

  % valgrind -v --leak-check=full virt-clone --print-xml
  Note: it can hit the issue although options are incomplete.

* Actual valgrind result:

==1801== 12 bytes in 1 blocks are definitely lost in loss record 25 of 3,270
==1801==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==1801==    by 0xCF1F60E: libvirt_virConnectOpenAuth (libvirt-override.c:1507)
==1801==    by 0x3AFEEDE7F3: PyEval_EvalFrameEx (ceval.c:3794)
==1801==    by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801==    by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801==    by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801==    by 0x3AFEEDF99E: PyEval_EvalFrameEx (ceval.c:3880)
==1801==    by 0x3AFEEE0466: PyEval_EvalCodeEx (ceval.c:3044)
==1801==    by 0x3AFEEE0541: PyEval_EvalCode (ceval.c:545)
==1801==    by 0x3AFEEFB88B: run_mod (pythonrun.c:1351)
==1801==    by 0x3AFEEFB95F: PyRun_FileExFlags (pythonrun.c:1337)
==1801==    by 0x3AFEEFCE4B: PyRun_SimpleFileExFlags (pythonrun.c:941)

Signed-off-by: Alex Jia <ajia@redhat.com>
10 years agopython: Expose blockPeek and memoryPeek in Python binding
Osier Yang [Thu, 15 Dec 2011 13:01:33 +0000 (15 21:01 +0800)]
python: Expose blockPeek and memoryPeek in Python binding

A simple example to show how to use it:

\#! /usr/bin/python

import os
import sys
import libvirt

disk = "/var/lib/libvirt/images/test.img"

conn = libvirt.open(None)
dom = conn.lookupByName('test')

mem_contents = dom.memoryPeek(0, 32, libvirt.VIR_MEMORY_VIRTUAL);
sys.stdout.write(mem_contents)

% python test.py | hexdump
0000000 1660 0209 0000 0000 0000 0000 0000 0000
0000010 0000 0000 0000 0000 d3a0 01d0 0000 0000
0000020

10 years agopython: Fix export of virDomainSnapshotListChildrenNames
Peter Krempa [Tue, 13 Dec 2011 14:49:59 +0000 (13 15:49 +0100)]
python: Fix export of virDomainSnapshotListChildrenNames

Commit f2013c9dd1ce468b8620ee35c232a93ef7026fb0 added implementation of
virDomainSnapshotListChildrenNames override export, but registration of
the newly exported function was not added.

 *python/libvirt-override.c: - register export of function

10 years agopython: Expose binding for virNodeGetMemoryStats()v0.9.8
Peter Krempa [Mon, 28 Nov 2011 17:19:28 +0000 (28 18:19 +0100)]
python: Expose binding for virNodeGetMemoryStats()

This patch adds binding for virNodeGetMemoryStats method of libvirtd.
Return value is represented as a python dictionary mapping field
names to values.

10 years agopython: Expose binding for virNodeGetCPUStats()
Peter Krempa [Mon, 28 Nov 2011 17:19:27 +0000 (28 18:19 +0100)]
python: Expose binding for virNodeGetCPUStats()

This patch adds binding for virNodeGetCPUStats method of libvirtd.
Return value is represented as a python dictionary mapping field names
to values.

10 years agoSupport virDomain{Set, Get}BlockIoTune in the python APIv0.9.8-rc1v0.9.8-rc2
Lei Li [Tue, 15 Nov 2011 09:02:49 +0000 (15 17:02 +0800)]
Support virDomain{Set, Get}BlockIoTune in the python API

Python support for both setting and getting block I/O throttle.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoAdd new API virDomain{Set, Get}BlockIoTune
Lei Li [Tue, 15 Nov 2011 09:02:43 +0000 (15 17:02 +0800)]
Add new API virDomain{Set, Get}BlockIoTune

This patch add new pulic API virDomainSetBlockIoTune and
virDomainGetBlockIoTune.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agopython: Fix documentation of virStream recvv0.9.7
Matthias Bolte [Mon, 31 Oct 2011 16:11:33 +0000 (31 17:11 +0100)]
python: Fix documentation of virStream recv

This was fixed in be757a3f7baf93b for libvirt.c.

10 years agostartupPolicy: Emit event on disk source droppingv0.9.7-rc1
Michal Privoznik [Tue, 18 Oct 2011 14:15:42 +0000 (18 16:15 +0200)]
startupPolicy: Emit event on disk source dropping

If a disk source gets dropped because it is not accessible,
mgmt application might want to be informed about this. Therefore
we need to emit an event. The event presented in this patch
is however a bit superset of what written above. The reason is simple:
an intention to be easily expanded, e.g. on 'user ejected disk
in guest' events. Therefore, callback gets source string and disk alias
(which should be unique among a domain) and reason (an integer);

10 years agoFix two comments related to error handling
Philipp Hahn [Mon, 17 Oct 2011 15:02:33 +0000 (17 17:02 +0200)]
Fix two comments related to error handling

Signed-off-by: Philipp Hahn <hahn@univention.de>
10 years agosnapshot: new virDomainSnapshotListChildrenNames API
Eric Blake [Sun, 25 Sep 2011 01:56:26 +0000 (24 19:56 -0600)]
snapshot: new virDomainSnapshotListChildrenNames API

The previous API addition allowed traversal up the hierarchy;
this one makes it easier to traverse down the hierarchy.

In the python bindings, virDomainSnapshotNumChildren can be
generated, but virDomainSnapshotListChildrenNames had to copy
from the hand-written example of virDomainSnapshotListNames.

* include/libvirt/libvirt.h.in (virDomainSnapshotNumChildren)
(virDomainSnapshotListChildrenNames): New prototypes.
(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS): New flag alias.
* src/libvirt.c (virDomainSnapshotNumChildren)
(virDomainSnapshotListChildrenNames): New functions.
* src/libvirt_public.syms: Export them.
* src/driver.h (virDrvDomainSnapshotNumChildren)
(virDrvDomainSnapshotListChildrenNames): New callbacks.
* python/generator.py (skip_impl, nameFixup): Update lists.
* python/libvirt-override-api.xml: Likewise.
* python/libvirt-override.c
(libvirt_virDomainSnapshotListChildrenNames): New wrapper function.

10 years agomaint: typo fixes
Eric Blake [Mon, 10 Oct 2011 20:02:06 +0000 (10 14:02 -0600)]
maint: typo fixes

I noticed a couple typos in recent commits, and fixed the remaining
instances of them.

* docs/internals/command.html.in: Fix spelling errors.
* include/libvirt/libvirt.h.in (virConnectDomainEventCallback):
Likewise.
* python/libvirt-override.py (virEventAddHandle): Likewise.
* src/lxc/lxc_container.c (lxcContainerChild): Likewise.
* src/util/hash.c (virHashCreateFull): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalMakeVol): Likewise.
* src/esx/esx_driver.c (esxFormatVMXFileName): Likewise.
* src/vbox/vbox_tmpl.c (vboxIIDIsEqual_v3_x): Likewise.

10 years agopython: Fix bindings generated in VPATH buildv0.9.5v0.9.5-rc3v0.9.6
Jiri Denemark [Fri, 16 Sep 2011 09:46:46 +0000 (16 11:46 +0200)]
python: Fix bindings generated in VPATH build

10 years agopython: Fix libvirt.py generation to include virterror info
Cole Robinson [Wed, 14 Sep 2011 20:25:42 +0000 (14 16:25 -0400)]
python: Fix libvirt.py generation to include virterror info

Recent generator refactoring broke libvirt.py. With this patch, libvirt.py
is generated exactly the same as before offending commit 9eba0d25.

10 years agoqemu_api: Update Makefile to generate libvirtmod_qemu libv0.9.5-rc2
Osier Yang [Fri, 9 Sep 2011 11:10:43 +0000 (9 19:10 +0800)]
qemu_api: Update Makefile to generate libvirtmod_qemu lib

10 years agoqemu_api: Update Py binding generator to generate files for QEMU APIs
Osier Yang [Fri, 9 Sep 2011 11:09:44 +0000 (9 19:09 +0800)]
qemu_api: Update Py binding generator to generate files for QEMU APIs

It will generate:
  libvirt-qemu.py
  libvirt-qemu.h
  libvirt-qemu.c
  libvirt-qemu-export.c

10 years agoqemu_api: Add override XML and C files for QEMU APIs
Osier Yang [Fri, 9 Sep 2011 11:07:56 +0000 (9 19:07 +0800)]
qemu_api: Add override XML and C files for QEMU APIs

There is only one function (virDomainQemuMonitorCommand) need to
be hand-craft.

10 years agolatency: Expose the new API for Python bindingv0.9.5-rc1
Osier Yang [Mon, 5 Sep 2011 08:24:21 +0000 (5 16:24 +0800)]
latency: Expose the new API for Python binding

10 years agoAdd public API for getting migration speed
Jim Fehlig [Fri, 26 Aug 2011 18:10:21 +0000 (26 12:10 -0600)]
Add public API for getting migration speed

Includes impl of python binding since the generator was not
able to cope.

Note: Requires gendispatch.pl patch from Matthias Bolte

https://www.redhat.com/archives/libvir-list/2011-August/msg01367.html

10 years agopython: avoid unlikely sign extension buglibvirt-0.9.4-10.el6libvirt-0.9.4-11.el6libvirt-0.9.4-5.el6libvirt-0.9.4-6.el6libvirt-0.9.4-7.1.el6libvirt-0.9.4-7.2.el6libvirt-0.9.4-7.el6libvirt-0.9.4-8.el6libvirt-0.9.4-9.el6v0.9.4
Eric Blake [Tue, 2 Aug 2011 16:03:41 +0000 (2 10:03 -0600)]
python: avoid unlikely sign extension bug

Detected by Coverity; same analysis as for commit f73198df.

* python/libvirt-override.c (libvirt_virDomainGetVcpuPinInfo): Use
correct type.

10 years agofreebsd: Fix build problem due to picking up the wrong libvirt.h
Matthias Bolte [Thu, 28 Jul 2011 12:55:21 +0000 (28 14:55 +0200)]
freebsd: Fix build problem due to picking up the wrong libvirt.h

Gettext annoyingly modifies CPPFLAGS in-place, putting
-I/usr/local/include into the search patch if libintl headers
must be used from that location.  But since we must support
automake 1.9.6 which lacks AM_CPPFLAGS, and since CPPFLAGS is used
prior to INCLUDES, this means that the build picks up the _old_
installed libvirt.h in priority to the in-tree version, leading
to all sorts of weird build failures on FreeBSD.

Fix this by teaching configure to undo gettext's actions, but
to keep any changes required by gettext at the end of INCLUDES
after all in-tree locations are used first.  Also requires
adding a wrapper Makefile.am and making gnulib-tool create
just gnulib.mk files during the bootstrap process.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: add missing copyright noticesv0.9.4-rc2
Eric Blake [Thu, 28 Jul 2011 18:56:24 +0000 (28 12:56 -0600)]
maint: add missing copyright notices

I went with the shorter license notice used by src/libvirt.c,
rather than spelling out the full LGPLv2+ clause into each of
these files.

* configure.ac: Declare copyright.
* all Makefile.am: Likewise.

10 years agopython: add python binding for virDomainSetMemoryParameters
Hu Tao [Wed, 27 Jul 2011 02:13:11 +0000 (27 10:13 +0800)]
python: add python binding for virDomainSetMemoryParameters

10 years agopython: add python binding for virDomainGetMemoryParameters
Hu Tao [Wed, 27 Jul 2011 02:13:10 +0000 (27 10:13 +0800)]
python: add python binding for virDomainGetMemoryParameters

10 years agopython: add python binding for virDomainSetBlkioParameters
Hu Tao [Wed, 27 Jul 2011 02:13:09 +0000 (27 10:13 +0800)]
python: add python binding for virDomainSetBlkioParameters

10 years agopython: add python binding for virDomainGetBlkioParameters
Hu Tao [Wed, 27 Jul 2011 02:13:08 +0000 (27 10:13 +0800)]
python: add python binding for virDomainGetBlkioParameters

10 years agosend-key: Implement Python API
Lai Jiangshan [Thu, 21 Jul 2011 09:21:10 +0000 (21 17:21 +0800)]
send-key: Implement Python API

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
10 years agopython: Properly report errors if virStreamRecv fails
Cole Robinson [Tue, 26 Jul 2011 23:25:43 +0000 (26 19:25 -0400)]
python: Properly report errors if virStreamRecv fails

We only want to raise the special value -2. -1 should return None
which tells the bindings to throw an exception.

10 years agopython: Handle embedded NUL in stream.send datav0.9.4-rc1
Cole Robinson [Mon, 25 Jul 2011 15:44:36 +0000 (25 11:44 -0400)]
python: Handle embedded NUL in stream.send data

Otherwise things like volume upload are only useful with text data.

10 years agopython: add Python binding for virDomainGetVcpuPinInfo API
Taku Izumi [Mon, 25 Jul 2011 07:04:50 +0000 (25 15:04 +0800)]
python: add Python binding for virDomainGetVcpuPinInfo API

This patch adds the Python bindings for virDomainGetVcpuPinInfo API.
* python/generator.py: add it to generator skip list
* python/libvirt-override-api.xml: provide an override description
* python/libvirt-override.c: provide an override binding implementation

10 years agopython: add Python binding for virDomainPinVcpusFlags API
Taku Izumi [Mon, 25 Jul 2011 07:00:11 +0000 (25 15:00 +0800)]
python: add Python binding for virDomainPinVcpusFlags API

This patch adds the Python bindings for virDomainPinVcpuFlags API.
* python/generator.py: add it to the generator skip list
* python/libvirt-override-api.xml: provide override description
* python/libvirt-override.c: provide override bindings implementation

10 years agopython: add Python binding for virDomainGetSchedulerParametersFlags API
Taku Izumi [Mon, 25 Jul 2011 06:57:33 +0000 (25 14:57 +0800)]
python: add Python binding for virDomainGetSchedulerParametersFlags API

This patch adds the Python bindings for
virDomainGetSchedulerParametersFlags API.

10 years agopython: add Python binding for virDomainGetSchedulerParametersFlags API
Taku Izumi [Mon, 25 Jul 2011 06:54:34 +0000 (25 14:54 +0800)]
python: add Python binding for virDomainGetSchedulerParametersFlags API

This patch adds the Python bindings for
virDomainGetSchedulerParametersFlags API.
* python/libvirt-override-api.xml: provide and override description
* python/libvirt-override.c: implement the bindings

11 years agoAsynchronous event for BlockJob completion
Adam Litke [Fri, 22 Jul 2011 05:57:42 +0000 (22 13:57 +0800)]
Asynchronous event for BlockJob completion

When an operation started by virDomainBlockPull completes (either with
success or with failure), raise an event to indicate the final status.
This API allow users to avoid polling on virDomainGetBlockJobInfo if
they would prefer to use an event mechanism.

* daemon/remote.c: Dispatch events to client
* include/libvirt/libvirt.h.in: Define event ID and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle the new event
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for block_stream completion and emit a libvirt block pull event
* src/remote/remote_driver.c: Receive and dispatch events to application
* src/remote/remote_protocol.x: Wire protocol definition for the event
* src/remote_protocol-structs: structure definitions for protocol verification
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for BLOCK_STREAM_COMPLETED event
  from QEMU monitor

11 years agoEnable virDomainBlockPull in the python API
Adam Litke [Fri, 22 Jul 2011 05:43:53 +0000 (22 13:43 +0800)]
Enable virDomainBlockPull in the python API

virDomainGetBlockJobInfo requires manual override since it returns a
custom type.

* python/generator.py: reenable bindings for this entry point
* python/libvirt-override-api.xml python/libvirt-override.c:
  manual overrides

11 years agoAdd new API virDomainBlockPull* to headers
Adam Litke [Fri, 22 Jul 2011 05:18:06 +0000 (22 13:18 +0800)]
Add new API virDomainBlockPull* to headers

Set up the types for the block pull functions and insert them into the
virDriver structure definition.  Symbols are exported in this patch to
prevent
documentation compile failures.

* include/libvirt/libvirt.h.in: new API
* src/driver.h: add the new entry to the driver structure
* python/generator.py: fix compiler errors, the actual python bindings
* are
  implemented later
* src/libvirt_public.syms: export symbols
* docs/apibuild.py: Extend 'unsigned long' parameter exception to this
* API

11 years agopython: Fix makefile rule for code generation
Matthias Bolte [Thu, 21 Jul 2011 11:45:42 +0000 (21 13:45 +0200)]
python: Fix makefile rule for code generation

Commit 8665f85523f0451c changed generated.stamp to $(GENERATE).stamp,
but missed one instance in the CLEANFILES list. This can break the
build in case the generated code is deleted but the .stamp file stays
around and therefore the code isn't regenerated.

11 years agoQuieten build & ensure API build scripts exit with non-zero status
Daniel P. Berrange [Thu, 12 May 2011 10:19:42 +0000 (12 11:19 +0100)]
Quieten build & ensure API build scripts exit with non-zero status

The current API build scripts will continue and exit with a zero
status even if they find problems. This has been the cause of many
build problems, or hidden build errors, in the past. Change the
scripts so they always exit with a non-zero status for any problems
they do not understand. Also turn off all debug output by default
so they respect $(AM_V_GEN)

* docs/Makefile.am: Use $(AM_V_GEN) for API/HTML scripts
* docs/apibuild.py, python/generator.py: Exit with non-zero status
  if problems are found. Also be silent, not outputting any debug
  messages.
* src/Makefile.am: Use $(AM_V_GEN) for ESX generator
* python/Makefile.am: Tweak rule

11 years agopython: prefer unsigned flags
Eric Blake [Thu, 7 Jul 2011 18:13:45 +0000 (7 12:13 -0600)]
python: prefer unsigned flags

* python/libvirt-override.c (libvirt_virConnectOpenAuth)
(libvirt_virDomainSnapshotListNames)
(libvirt_virDomainRevertToSnapshot): Change flags type.

11 years agopython: Fix bogus label placement
Matthias Bolte [Wed, 6 Jul 2011 17:25:18 +0000 (6 19:25 +0200)]
python: Fix bogus label placement

11 years agobuild: consistently use CFLAGSv0.9.3
Eric Blake [Tue, 31 May 2011 22:15:28 +0000 (31 16:15 -0600)]
build: consistently use CFLAGS

According to the automake manual, CPPFLAGS (aka INCLUDES, as spelled
in automake 1.9.6) should only include -I, -D, and -U directives; more
generic directives like -Wall belong in CFLAGS since they affect more
phases of the build process.  Therefore, we should be sticking CFLAGS
additions into a CFLAGS container, not a CPPFLAGS container.

* src/Makefile.am (libvirt_driver_vmware_la_CFLAGS): Use AM_CFLAGS.
(INCLUDES): Move CFLAGS items...
(AM_CFLAGS): ...to their proper location.
* python/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
* tests/Makefile.am (INCLUDES, AM_CFLAGS): Likewise.
(commandtest_CFLAGS, commandhelper_CFLAGS)
(virnetmessagetest_CFLAGS, virnetsockettest_CFLAGS): Use AM_CFLAGS.

11 years agopython: Don't declare Py_ssize_t for Python 2.6v0.9.3-rc1v0.9.3-rc2
Matthias Bolte [Fri, 24 Jun 2011 17:34:56 +0000 (24 19:34 +0200)]
python: Don't declare Py_ssize_t for Python 2.6

Commit cd48c3f4e95597 added a Py_ssize_t typedef for Python < 2.7.
But Py_ssize_t was added in Python 2.5. This makes the build fail
for Python 2.6.

Adjust the check to match Python < 2.5 to fix this.

11 years agoRevert "Add new API virDomainBlockPull* to headers"
Eric Blake [Thu, 23 Jun 2011 21:40:48 +0000 (23 15:40 -0600)]
Revert "Add new API virDomainBlockPull* to headers"

This reverts commit 7d56a16d036d9aa7292e10e884c129742036f8a7.

Conflicts:

python/generator.py
src/libvirt_public.syms

11 years agoRevert "Enable virDomainBlockPull in the python API."
Eric Blake [Thu, 23 Jun 2011 17:56:54 +0000 (23 11:56 -0600)]
Revert "Enable virDomainBlockPull in the python API."

This reverts commit d74b86f5d6ecae3d18a391f90a918fcac75914db.

Conflicts:

python/generator.py

11 years agoRevert "Asynchronous event for BlockPull completion"
Eric Blake [Thu, 23 Jun 2011 17:54:19 +0000 (23 11:54 -0600)]
Revert "Asynchronous event for BlockPull completion"

This reverts commit 12cd77a0c58a80179182f7d09e8e73f9f66b4677.

Conflicts:

python/libvirt-override-virConnect.py
python/libvirt-override.c
src/remote/remote_protocol.x

11 years agobuild: avoid python 2.4 build failure
Eric Blake [Fri, 24 Jun 2011 04:17:19 +0000 (23 22:17 -0600)]
build: avoid python 2.4 build failure

I'm not sure when Py_ssize_t was introduced; but Fedora 14 Python 2.7
has it, while RHEL 5 Python 2.4 lacks it.  It should be easy enough
to adjust if someone runs into problems.

* python/typewrappers.h (Py_ssize_t): Define for older python.

11 years agobuild: avoid python 2.4 build failure
Eric Blake [Fri, 24 Jun 2011 04:09:00 +0000 (23 22:09 -0600)]
build: avoid python 2.4 build failure

On RHEL 5, I got:

/usr/bin/python ./generator.py /usr/bin/python
  File "./generator.py", line 427
    "virStreamFree", # Needed in custom virStream __del__, but free shouldn't
                   ^
SyntaxError: invalid syntax

* python/generator.py (function_skip_python_impl): Use same syntax
as other skip lists.

11 years agopython: Generate virStreamFree but don't expose in bindings
Cole Robinson [Tue, 21 Jun 2011 00:06:49 +0000 (20 20:06 -0400)]
python: Generate virStreamFree but don't expose in bindings

Turns out I was right in removing this the first time :) This is
needed in our custom __del__ function, but the C code wasn't
being generated. Add new infrastructure to do what we want

11 years agopython: Mark event callback wrappers as private
Cole Robinson [Thu, 16 Jun 2011 00:14:45 +0000 (15 20:14 -0400)]
python: Mark event callback wrappers as private

These functions aren't intended to be called directly by users, so mark
them as private.

While we're at it, remove unneeded exception handling, and break some
long lines.

11 years agopython: events: Fix C->Python handle callback prototype
Cole Robinson [Thu, 16 Jun 2011 00:02:27 +0000 (15 20:02 -0400)]
python: events: Fix C->Python handle callback prototype

If registering our own event loop implementation written in python,
any handles or timeouts callbacks registered by libvirt C code must
be wrapped in a python function. There is some argument trickery that
makes this all work, by wrapping the user passed opaque value in
a tuple, along with the callback function.

Problem is, the current setup requires the user's event loop to know
about this trickery, rather than just treating the opaque value
as truly opaque.

Fix this in a backwards compatible manner, and adjust the example
python event loop to do things the proper way.

11 years agopython: Add bindings for virEvent*Handle/Timeout
Cole Robinson [Wed, 15 Jun 2011 23:35:44 +0000 (15 19:35 -0400)]
python: Add bindings for virEvent*Handle/Timeout

11 years agoPromote virEvent*Handle/Timeout to public API
Cole Robinson [Wed, 15 Jun 2011 21:54:30 +0000 (15 17:54 -0400)]
Promote virEvent*Handle/Timeout to public API

Since we virEventRegisterDefaultImpl is now a public API, callers need
a way to invoke the default registered Handle and Timeout functions. We
already have general functions for these internally, so promote
them to the public API.

v2:
    Actually add APIs to libvirt.h

11 years agopython: Implement virStreamSend/RecvAll helpers
Cole Robinson [Wed, 15 Jun 2011 20:54:16 +0000 (15 16:54 -0400)]
python: Implement virStreamSend/RecvAll helpers

Pure python implementation. The handler callbacks have been altered
a bit compared to the C API: RecvAll doesn't pass length of the data read
since that can be trivially obtained from python string objects, and SendAll
requires the handler to return the string data to send rather than
store the data in a string pointer.

11 years agopython: Implement virStreamSend/Recv
Cole Robinson [Tue, 14 Jun 2011 20:07:43 +0000 (14 16:07 -0400)]
python: Implement virStreamSend/Recv

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.

11 years agopython: Implement bindings for virStreamEventAddCallback
Cole Robinson [Tue, 14 Jun 2011 17:49:22 +0000 (14 13:49 -0400)]
python: Implement bindings for virStreamEventAddCallback

v2:
    Don't generate virStreamFree

11 years agopython: generator: Don't print warning if nothing to warn about
Cole Robinson [Wed, 15 Jun 2011 21:57:37 +0000 (15 17:57 -0400)]
python: generator: Don't print warning if nothing to warn about

11 years agopython: libvirt-override: use simpler debug
Cole Robinson [Tue, 14 Jun 2011 16:59:44 +0000 (14 12:59 -0400)]
python: libvirt-override: use simpler debug

In a couple instances we have to mark a debug variable as ATTRIBUTE_UNUSED
to avoid warnings.

v2:
    Use #if 0 to comment out debug define

11 years agoIntroduce virDomainGetControlInfo API
Jiri Denemark [Tue, 24 May 2011 08:28:50 +0000 (24 11:28 +0300)]
Introduce virDomainGetControlInfo API

The API can be used to query current state of an interface to VMM used
to control a domain. In QEMU world this translates into monitor
connection.

11 years agoAsynchronous event for BlockPull completion
Adam Litke [Tue, 14 Jun 2011 14:36:53 +0000 (14 09:36 -0500)]
Asynchronous event for BlockPull completion

When an operation started by virDomainBlockPullAll completes (either with
success or with failure), raise an event to indicate the final status.  This
allows an API user to avoid polling on virDomainBlockPullInfo if they would
prefer to use the event mechanism.

* daemon/remote.c: Dispatch events to client
* include/libvirt/libvirt.h.in: Define event ID and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle the new event
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for block_stream completion and emit a libvirt block pull event
* src/remote/remote_driver.c: Receive and dispatch events to application
* src/remote/remote_protocol.x: Wire protocol definition for the event
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for BLOCK_STREAM_COMPLETED event
  from QEMU monitor

Signed-off-by: Adam Litke <agl@us.ibm.com>
11 years agoEnable virDomainBlockPull in the python API.
Adam Litke [Tue, 14 Jun 2011 14:36:52 +0000 (14 09:36 -0500)]
Enable virDomainBlockPull in the python API.

virDomainBlockPullAll and virDomainBlockPullAbort are handled automatically.
virDomainBlockPull and virDomainBlockPullInfo require manual overrides since
they return a custom type.

* python/generator.py: reenable bindings for this entry point
* python/libvirt-override-api.xml python/libvirt-override.c:
  manual overrides

Signed-off-by: Adam Litke <agl@us.ibm.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd new API virDomainBlockPull* to headers
Adam Litke [Thu, 9 Jun 2011 17:10:07 +0000 (9 12:10 -0500)]
Add new API virDomainBlockPull* to headers

Set up the types for the block pull functions and insert them into the
virDriver structure definition.  Symbols are exported in this patch to prevent
documentation compile failures.

* include/libvirt/libvirt.h.in: new API
* src/driver.h: add the new entry to the driver structure
* python/generator.py: fix compiler errors, the actual python bindings are
  implemented later
* src/libvirt_public.syms: export symbols

Signed-off-by: Adam Litke <agl@us.ibm.com>
11 years agovirNodeGetMemoryStats: Expose new API
Minoru Usui [Tue, 7 Jun 2011 01:03:36 +0000 (7 10:03 +0900)]
virNodeGetMemoryStats: Expose new API

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
11 years agovirNodeGetCPUStats: Expose new API
Minoru Usui [Tue, 7 Jun 2011 00:58:47 +0000 (7 09:58 +0900)]
virNodeGetCPUStats: Expose new API

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
11 years agosend-key: Defining the public API
Lai Jiangshan [Tue, 7 Jun 2011 09:11:12 +0000 (7 17:11 +0800)]
send-key: Defining the public API

Add public virDomainSendKey() and enum libvirt_keycode_set
for the @codeset.

Python version of virDomainSendKey() has not been implemented yet,
it will be done soon.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
11 years agoDeprecate several CURRENT/LIVE/CONFIG enums
Hu Tao [Wed, 8 Jun 2011 06:33:33 +0000 (8 14:33 +0800)]
Deprecate several CURRENT/LIVE/CONFIG enums

This patch deprecates following enums:

VIR_DOMAIN_MEM_CURRENT
VIR_DOMAIN_MEM_LIVE
VIR_DOMAIN_MEM_CONFIG

VIR_DOMAIN_VCPU_LIVE
VIR_DOMAIN_VCPU_CONFIG

VIR_DOMAIN_DEVICE_MODIFY_CURRENT
VIR_DOMAIN_DEVICE_MODIFY_LIVE
VIR_DOMAIN_DEVICE_MODIFY_CONFIG

And modify internal codes to use virDomainModificationImpact.

11 years agopython: avoid unlikely sign extension bug
Eric Blake [Fri, 3 Jun 2011 19:53:26 +0000 (3 13:53 -0600)]
python: avoid unlikely sign extension bug

Detected by Coverity.  cpumap was allocated with a value of
(unsigned short)*(int), which is an int computation, and then
promotes to size_t.  On a 64-bit platform, this fails if bit
32 of the product is set (because of sign extension giving
a HUGE value to malloc), even though a naive programmer would
assume that since the first value is unsigned, the product
is also unsigned and at most 4GB would be allocated.

Won't bite in practice (the product should never be that large),
but worth using the right types to begin with, so that we are
now computing (unsigned short)*(size_t).

* python/libvirt-override.c (libvirt_virDomainGetVcpus): Use
correct type.

11 years agoIntroduce a new event emitted when a virtualization failure occursCVE-2011-2178v0.9.2
Daniel P. Berrange [Sun, 29 May 2011 12:21:53 +0000 (29 20:21 +0800)]
Introduce a new event emitted when a virtualization failure occurs

This introduces a new domain

  VIR_DOMAIN_EVENT_ID_CONTROL_ERROR

Which uses the existing generic callback

typedef void (*virConnectDomainEventGenericCallback)(virConnectPtr conn,
                                                     virDomainPtr dom,
                                                     void *opaque);

This event is intended to be emitted when there is a failure in
some part of the domain virtualization system. Whether the domain
continues to run/exist after the failure is an implementation
detail specific to the hypervisor.

The idea is that with some types of failure, hypervisors may
prefer to leave the domain running in a "degraded" mode of
operation. For example, if something goes wrong with the QEMU
monitor, it is possible to leave the guest OS running quite
happily. The mgmt app will simply loose the ability todo various
tasks. The mgmt app can then choose how/when to deal with the
failure that occured.
* daemon/remote.c: Dispatch of new event
* examples/domain-events/events-c/event-test.c: Demo catch
  of event
* include/libvirt/libvirt.h.in: Define event ID and callback
* src/conf/domain_event.c, src/conf/domain_event.h: Internal
  event handling
* src/remote/remote_driver.c: Receipt of new event from daemon
* src/remote/remote_protocol.x: Wire protocol for new event
* src/remote_protocol-structs: add new event for checks

11 years agosched: introduce virDomainGetSchedulerParametersFlags
Eric Blake [Tue, 17 May 2011 21:17:14 +0000 (17 15:17 -0600)]
sched: introduce virDomainGetSchedulerParametersFlags

If we can choose live or config when setting, then we need to
be able to choose which one we are querying.

Also, make the documentation clear that set must use a non-empty
subset (some of the hypervisors fail if params is NULL).

* include/libvirt/libvirt.h.in
(virDomainGetSchedulerParametersFlags): New prototype.
* src/libvirt.c (virDomainGetSchedulerParametersFlags): Implement
it.
* src/libvirt_public.syms: Export it.
* python/generator.py (skip_impl): Don't auto-generate.
* src/driver.h (virDrvDomainGetSchedulerParametersFlags): New
callback.

11 years agolibvirt.h: avoid regression, and document preferred name
Eric Blake [Sun, 29 May 2011 10:24:20 +0000 (29 18:24 +0800)]
libvirt.h: avoid regression, and document preferred name

Commit 824dcaff was a regression (thankfully unreleased) for any
client code that used 'struct _virSchedParameter' directly rather
than the preferred virSchedParameter typedef.  Adding a #define
avoids even that API change, while rearranging the file makes it
clear what the old vs. new API is.

* include/libvirt/libvirt.h.in: Rearrange older names to the
bottom and improve documentation on preferred names.
(virDomainGetSchedulerParameters, virDomainSetSchedulerParameters)
(virDomainSetSchedulerParametersFlags)
(virDomainSetBlkioParameters, virDomainGetBlkioParameters)
(virDomainSetMemoryParameters, virDomainGetMemoryParameters):
Use newer type names.
* python/libvirt-override.c: Adjust code generation to cope.
Suggested by Daniel P. Berrange.

11 years agopython: Don't free must-not-free variables
Michal Privoznik [Mon, 23 May 2011 12:41:00 +0000 (23 14:41 +0200)]
python: Don't free must-not-free variables

py_str() function call PyString_AsString(). As written in documentation,
the caller must not free the returned value, because it points to some
internal structures.

11 years agopython: Fix typo in bindings
Michal Privoznik [Mon, 23 May 2011 08:51:46 +0000 (23 10:51 +0200)]
python: Fix typo in bindings

This typo caused a bug in which we wanted to free() invalid pointer.