Commit Graph

216 Commits

Author SHA1 Message Date
Matthias Bolte
1468359f16 python: Fix makefile rule for code generation
Commit 8665f85523 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.
2011-07-21 14:36:34 +02:00
Daniel P. Berrange
8665f85523 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
2011-07-19 13:58:06 +01:00
Eric Blake
07d5d07383 python: prefer unsigned flags
* python/libvirt-override.c (libvirt_virConnectOpenAuth)
(libvirt_virDomainSnapshotListNames)
(libvirt_virDomainRevertToSnapshot): Change flags type.
2011-07-13 17:05:10 -06:00
Matthias Bolte
94538e14e2 python: Fix bogus label placement 2011-07-07 13:24:22 +02:00
Eric Blake
6ae3052c06 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.
2011-07-01 10:44:17 -06:00
Matthias Bolte
9a48ed54f8 python: Don't declare Py_ssize_t for Python 2.6
Commit cd48c3f4e9 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.
2011-06-24 19:34:56 +02:00
Eric Blake
1aa859d633 Revert "Add new API virDomainBlockPull* to headers"
This reverts commit 7d56a16d03.

Conflicts:

	python/generator.py
	src/libvirt_public.syms
2011-06-24 08:41:25 -06:00
Eric Blake
21ecea2e93 Revert "Enable virDomainBlockPull in the python API."
This reverts commit d74b86f5d6.

Conflicts:

	python/generator.py
2011-06-24 08:41:24 -06:00
Eric Blake
c4c59e7228 Revert "Asynchronous event for BlockPull completion"
This reverts commit 12cd77a0c5.

Conflicts:

	python/libvirt-override-virConnect.py
	python/libvirt-override.c
	src/remote/remote_protocol.x
2011-06-24 08:41:24 -06:00
Eric Blake
cd48c3f4e9 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.
2011-06-24 08:28:56 -06:00
Eric Blake
178bab1c53 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.
2011-06-23 22:09:00 -06:00
Cole Robinson
1b68d3f099 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
2011-06-23 10:52:59 -04:00
Cole Robinson
7268cb9274 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.
2011-06-21 10:08:48 -04:00
Cole Robinson
f2fb235b1d 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.
2011-06-21 10:08:48 -04:00
Cole Robinson
d0e3f3d6a6 python: Add bindings for virEvent*Handle/Timeout 2011-06-21 10:08:47 -04:00
Cole Robinson
6094ad7bd7 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
2011-06-21 10:08:47 -04:00
Cole Robinson
3b04871e80 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.
2011-06-21 10:08:47 -04:00
Cole Robinson
ca55dc598c 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.
2011-06-21 10:08:47 -04:00
Cole Robinson
b1ede4cf9c python: Implement bindings for virStreamEventAddCallback
v2:
    Don't generate virStreamFree
2011-06-20 14:11:55 -04:00
Cole Robinson
eb3151b411 python: generator: Don't print warning if nothing to warn about 2011-06-20 14:10:45 -04:00
Cole Robinson
e8c8fc144d 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
2011-06-20 14:10:26 -04:00
Jiri Denemark
67cc825dda 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.
2011-06-16 18:26:12 +02:00
Adam Litke
12cd77a0c5 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>
2011-06-14 22:48:42 -06:00
Adam Litke
d74b86f5d6 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>
2011-06-14 22:37:39 -06:00
Adam Litke
7d56a16d03 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>
2011-06-14 21:20:11 -06:00
Minoru Usui
625aa63eea virNodeGetMemoryStats: Expose new API
Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
2011-06-14 16:07:47 -06:00
Minoru Usui
1f873744c8 virNodeGetCPUStats: Expose new API
Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
2011-06-14 14:48:45 -06:00
Lai Jiangshan
973564094f 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>
2011-06-14 13:00:21 -06:00
Hu Tao
fbd7820b2c 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.
2011-06-13 14:17:16 -06:00
Eric Blake
f73198df3b 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.
2011-06-08 05:28:20 -06:00
Daniel P. Berrange
a6135ec1e6 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
2011-05-29 20:21:53 +08:00
Eric Blake
bc4ee58972 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.
2011-05-29 18:38:10 +08:00
Eric Blake
a9b3a78fa6 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.
2011-05-29 18:24:20 +08:00
Michal Privoznik
ef54d045c3 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.
2011-05-24 10:33:36 +02:00
Michal Privoznik
6bae93d33b python: Fix typo in bindings
This typo caused a bug in which we wanted to free() invalid pointer.
2011-05-23 13:48:19 +02:00
Eric Blake
824dcaff78 libvirt.h: consolidate typed parameter handling
The new type is identical to the three old types that it replaces,
and by creating a common type, this allows future patches to share
common code that manipulates typed parameters.

This change is backwards-compatible in API (recompilation works
without any edits) and ABI (an older client that has not been
recompiled uses the same layout) for code using only public
names; only code using private names (those beginning with _)
will have to adapt.

* include/libvirt/libvirt.h.in (virTypedParameterType)
(VIR_TYPED_PARAM_FIELD_LENGTH, _virTypedParameter): New enum,
macro, and type.
(virSchedParameter, virBlkioParameter, virMemoryParameter):
Rewrite in terms of a common type, while keeping all old public
names for backwards compatibility.
(struct _virSchedParameter, struct _virBlkioParameter)
(struct _virMemoryParameter): Delete - these are private names.
* python/generator.py (enum): Cope with the refactoring.
2011-05-18 08:40:28 -06:00
Hu Tao
d4b8a35755 introduce virDomainSetSchedulerParametersFlags
This new function allows aditional flags to be passed into from
the virsh command line.
2011-05-17 09:37:46 -06:00
Jiri Denemark
d65a924b34 virDomainGetState public API
This API is supposed to replace virDomainGetInfo when the only purpose
of calling it is getting current domain status.
2011-05-16 10:04:18 +02:00
Jiri Denemark
c51f08272a python: Use hardcoded python path in libvirt.py
This partially reverts (and fixes that part in a different way) commit
e4384459c9, which replaced
``/usr/bin/python'' with ``/usr/bin/env python'' in all examples or
scripts used during build to generate other files.

However, python bindings module is compiled and linked against a
specific python discovered or explicitly provided in configure phase.
Thus libvirt.py, which is generated and installed into the system,
should use the same python binary for which the module has been built.

The hunk in Makefile.am replaces $(srcdir) with $(PYTHON), which might
seem wrong but it is not. generator.py didn't use any of its command
line arguments so passing $(srcdir) to it was redundant.
2011-03-14 12:37:19 +01:00
Gui Jianfeng
13c5282122 libvirt: add virDomain{Get,Set}BlkioParameters
Add virDomainSetBlkioParameters virDomainGetBlkioParameters

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
2011-03-10 17:53:16 -07:00
Eric Blake
f409661e71 maint: fix grammar in error message
* python/tests/create.py: Use correct wording.
2011-02-21 10:35:25 -07:00
Jiri Denemark
15285754dd maint: Expand tabs in python code
Also cfg.mk is tweaked to force this for all future changes to *.py
files.
2011-02-18 08:59:51 +01:00
Cole Robinson
4254dfea78 python: Use PyCapsule API if available
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.
2011-01-10 15:18:05 -05:00
Matthias Bolte
e4384459c9 Use python discovered through env instead of hardcoding a path
This is more flexible regarding the location of the python binary
but doesn't allow to pass the -u flag. The -i flag can be passed
from inside the script using the PYTHONINSPECT env variable.

This fixes a problem with the esx_vi_generator.py on FreeBSD.
2010-11-14 22:45:59 +01:00
Matthias Bolte
43c2c61f68 Fix several minor problems introduced by the memtune series
Add proper documentation to the new VIR_DOMAIN_MEMORY_* macros in
libvirt.h.in to placate apibuild.py.

Mark args as unused in for libvirt_virDomain{Get,Set}MemoryParameters
in the Python bindings and add both to the libvirtMethods array.

Update remote_protocol-structs to placate make syntax-check.

Undo unintended modifications in vboxDomainGetInfo.

Update the function table of the VirtualBox and XenAPI drivers.
2010-10-12 21:24:11 +02:00
Nikunj A. Dadhania
bf1b76ffaa Adding structure and defines for virDomainSet/GetMemoryParameters
This patch adds a structure virMemoryParameter, it contains the name of
the
parameter and the type of the parameter along with a union.

dv:
+ rename enums to VIR_DOMAIN_MEMORY_PARAM_*
+ remove some extraneous tabs

v4:
+ Add unsigned int flags to the public api for future extensions

v3:
+ Protoype for virDomainGetMemoryParameters and dummy python binding.

v2:
+ Includes dummy python bindings for the library to build cleanly.
+ Define string constants like "hard_limit", etc.
+ re-order this patch.
2010-10-12 19:26:09 +02:00
Dan Kenigsberg
fe3bb9440a python: drop unnecessary conn assignment
Since 554d82a200, conn is unused. Let's
drop it - but keep the signature of the constructor for backward
compatibility.
2010-09-27 15:10:38 -06:00
Philipp Hahn
eac63161cc Fix SEGV on exit after domainEventDeregister()
When the last callback is removed using domainEventDeregister(), the
events dispatcher is deregistered from the C-library, but
domainEventsCallbacks is still an empty list.
On shutdown __del__() deregisters the dispatacher again, which SEGVs

	# You need the event-loop implementation from the Python examples;
	# give the file a name which is importable by Python.
	ln examples/domain-events/events-python/event-test.py eloop.py
	python -c 'from eloop import *
	import sys

	def dump(*args): print " ".join(map(str, args))

	virEventLoopPureStart()
	c = libvirt.open("xen:///")
	c.domainEventRegister(dump, None)
	c.domainEventDeregister(dump)
	sys.exit(0)'

domainEventDeregister() needs to delete domainEventCallbacks so subsequent
calls to __del__() and domainEventRegister() choose the right code paths.
Setting it to None is not enough, since calling domainEventRegiser() again
would trigger an TypeError.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2010-07-23 13:26:40 -06:00
Cole Robinson
f9abc44ad5 python: Fix IOErrorReasonCallback bindings
A copy and paste error was causing us to dispatch the incorrect
routine. Spotted by Dan Kenigsberg.
2010-07-14 10:52:18 -04:00
Daniel P. Berrange
a6c539445e Ensure we return the callback ID in python events binding
A missing return statement in the python binding meant that
the callers could not get the callback ID, and thus not be
able to unregister event callbacks

* python/libvirt-override-virConnect.py: Add missing return
  statement
2010-07-12 13:41:52 +01:00