summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* python: Mark event callback wrappers as privateCole Robinson2011-06-214-73/+59
| | | | | | | | 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.
* python: events: Fix C->Python handle callback prototypeCole Robinson2011-06-211-2/+24
| | | | | | | | | | | | | | | 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.
* python: Add bindings for virEvent*Handle/TimeoutCole Robinson2011-06-213-36/+221
|
* Promote virEvent*Handle/Timeout to public APICole Robinson2011-06-211-0/+8
| | | | | | | | | | 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
* python: Implement virStreamSend/RecvAll helpersCole Robinson2011-06-212-2/+66
| | | | | | | | 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.
* python: Implement virStreamSend/RecvCole Robinson2011-06-215-4/+117
| | | | | | | 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.
* python: Implement bindings for virStreamEventAddCallbackCole Robinson2011-06-204-14/+100
| | | | | v2: Don't generate virStreamFree
* python: generator: Don't print warning if nothing to warn aboutCole Robinson2011-06-201-3/+5
|
* python: libvirt-override: use simpler debugCole Robinson2011-06-201-104/+57
| | | | | | | | 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
* Introduce virDomainGetControlInfo APIJiri Denemark2011-06-163-0/+34
| | | | | | 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.
* Asynchronous event for BlockPull completionAdam Litke2011-06-142-0/+63
| | | | | | | | | | | | | | | | | | | | | 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>
* Enable virDomainBlockPull in the python API.Adam Litke2011-06-143-3/+69
| | | | | | | | | | | | | 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>
* Add new API virDomainBlockPull* to headersAdam Litke2011-06-141-0/+3
| | | | | | | | | | | | | | 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>
* virNodeGetMemoryStats: Expose new APIMinoru Usui2011-06-141-0/+1
| | | | Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
* virNodeGetCPUStats: Expose new APIMinoru Usui2011-06-141-0/+1
| | | | Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
* send-key: Defining the public APILai Jiangshan2011-06-141-0/+1
| | | | | | | | | | 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>
* Deprecate several CURRENT/LIVE/CONFIG enumsHu Tao2011-06-131-0/+6
| | | | | | | | | | | | | | | | | 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.
* python: avoid unlikely sign extension bugEric Blake2011-06-081-1/+1
| | | | | | | | | | | | | | | | | 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.
* Introduce a new event emitted when a virtualization failure occursv0.9.2CVE-2011-2178Daniel P. Berrange2011-05-291-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* sched: introduce virDomainGetSchedulerParametersFlagsEric Blake2011-05-291-0/+1
| | | | | | | | | | | | | | | | | 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.
* libvirt.h: avoid regression, and document preferred nameEric Blake2011-05-291-14/+14
| | | | | | | | | | | | | | | | | | 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.
* python: Don't free must-not-free variablesMichal Privoznik2011-05-241-8/+3
| | | | | | 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.
* python: Fix typo in bindingsMichal Privoznik2011-05-231-1/+1
| | | | This typo caused a bug in which we wanted to free() invalid pointer.
* libvirt.h: consolidate typed parameter handlingEric Blake2011-05-181-0/+12
| | | | | | | | | | | | | | | | | | | | | | 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.
* introduce virDomainSetSchedulerParametersFlagsHu Tao2011-05-171-0/+1
| | | | | This new function allows aditional flags to be passed into from the virsh command line.
* virDomainGetState public APIJiri Denemark2011-05-163-0/+37
| | | | | This API is supposed to replace virDomainGetInfo when the only purpose of calling it is getting current domain status.
* python: Use hardcoded python path in libvirt.pyv0.9.1v0.9.0CVE-2011-1486Jiri Denemark2011-03-143-7/+7
| | | | | | | | | | | | | | | | This partially reverts (and fixes that part in a different way) commit e4384459c93e3e786aa483c7f077d1d22148f689, 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.
* libvirt: add virDomain{Get,Set}BlkioParametersCVE-2011-1146Gui Jianfeng2011-03-103-1/+34
| | | | | | Add virDomainSetBlkioParameters virDomainGetBlkioParameters Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
* maint: fix grammar in error messageEric Blake2011-02-211-2/+2
| | | | * python/tests/create.py: Use correct wording.
* maint: Expand tabs in python codeJiri Denemark2011-02-182-293/+293
| | | | | Also cfg.mk is tweaked to force this for all future changes to *.py files.
* python: Use PyCapsule API if availablev0.8.8Cole Robinson2011-01-101-39/+50
| | | | | | | | | | 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.
* Use python discovered through env instead of hardcoding a pathv0.8.7v0.8.6Matthias Bolte2010-11-142-1/+6
| | | | | | | | 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.
* Fix several minor problems introduced by the memtune seriesv0.8.5Matthias Bolte2010-10-121-2/+4
| | | | | | | | | | | | | | 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.
* Adding structure and defines for virDomainSet/GetMemoryParametersNikunj A. Dadhania2010-10-123-0/+28
| | | | | | | | | | | | | | | | | | | | | 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.
* python: drop unnecessary conn assignmentDan Kenigsberg2010-09-271-9/+0
| | | | | | Since 554d82a200289938d5639a782a9f12e3e2e968f0, conn is unused. Let's drop it - but keep the signature of the constructor for backward compatibility.
* Fix SEGV on exit after domainEventDeregister()v0.8.4v0.8.3Philipp Hahn2010-07-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* python: Fix IOErrorReasonCallback bindingsCole Robinson2010-07-141-1/+1
| | | | | A copy and paste error was causing us to dispatch the incorrect routine. Spotted by Dan Kenigsberg.
* Ensure we return the callback ID in python events bindingDaniel P. Berrange2010-07-121-0/+1
| | | | | | | | | 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
* Add missing parameter in python Disk IO error callbackv0.8.2Daniel P. Berrange2010-06-251-1/+1
| | | | | | | | The IO error callback was forgetting to pass the action parameter, causing a stack trace when IO errors arrive * python/libvirt-override-virConnect.py: Add missing action parameter in IO error callback
* Fix description of virStorageVolGetInfo()Philipp Hahn2010-06-181-1/+1
| | | | | | | | Probably a copy-paste-bug in python/libvirt-override-api.xml: virStorageVolGetInfo() extracts information about a "storage volume", not the "storage pool" as virStoragePoolGetInfo() does. Signed-off-by: Philipp Hahn <hahn@univention.de>
* maint: simplify some ignore filesEric Blake2010-06-151-2/+0
| | | | | | | | | | | | | | * .hgignore: Delete, no longer used. * examples/python/.gitignore: Delete, covered globally. * include/.gitignore: Likewise. * python/tests/.gitignore: Likewise. * docs/schemas/.gitignore: Likewise. * tests/xml2sexprdata/.gitignore: Likewise. * tests/sexpr2xmldata/.gitignore: Likewise. * tests/confdata/.gitignore: Likewise. * tests/xencapsdata/.gitignore: Likewise. * tests/xmconfigdata/.gitignore: Likewise. * tests/xml2sexprdata/.gitignore: Likewise.
* Fix up the python bindings for snapshotting.Chris Lalancette2010-05-203-3/+53
| | | | | | | | | | | | | | | | | | | | | | | | This involved a few fixes. To start with, an virDomainSnapshot object is really tied to a domain, not a connection, so we have to generate a slightly different object so that we can get at self._dom for the object. Next, we had to "dummy" up an override piece of XML with a bogus argument that the function doesn't actually take. That's so that the generator places virDomainRevertToSnapshot underneath the correct class (namely, the virDomain class). Finally, we had to hand-implement the virDomainRevertToSnapshot implementation, ignoring the bogus pointer we are being passed. With all of this in place, I was able to successfully take a snapshot and revert to it using only the Python bindings. Signed-off-by: Chris Lalancette <clalance@redhat.com>
* python: don't ignore virInitialize failure in module initializationJim Meyering2010-05-181-1/+2
| | | | | * python/libvirt-override.c (initlibvirtmod): Upon virInitialize failure, skip the Py_InitModule call.
* Add support for another explicit IO error eventv0.8.1Daniel P. Berrange2010-04-302-1/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces a new event type VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR event, but also includes a string describing the cause of the event. Thus there is a new callback definition for this event type typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn, virDomainPtr dom, const char *srcPath, const char *devAlias, int action, const char *reason, void *opaque); This is currently wired up to the QEMU block IO error events * daemon/remote.c: Dispatch IO error events to client * examples/domain-events/events-c/event-test.c: Watch for IO error events * include/libvirt/libvirt.h.in: Define new IO error event ID and callback signature * src/conf/domain_event.c, src/conf/domain_event.h, src/libvirt_private.syms: Extend API to handle IO error events * src/qemu/qemu_driver.c: Connect to the QEMU monitor event for block IO errors and emit a libvirt IO error event * src/remote/remote_driver.c: Receive and dispatch IO error events to application * src/remote/remote_protocol.x: Wire protocol definition for IO error events * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event from QEMU monitor
* Implement python binding for virDomainGetBlockInfoDaniel P. Berrange2010-04-293-0/+35
| | | | | | | | | | | | | | | This binds the virDomainGetBlockInfo API to python's blockInfo method on the domain object >>> c = libvirt.openReadOnly('qemu:///session') >>> d = c.lookupByName('demo') >>> f = d.blockInfo("/dev/loop0", 0) >>> print f [1048576000L, 104857600L, 104857600L] * python/libvirt-override-api.xml: Define override signature * python/generator.py: Skip C impl generator for virDomainGetBlockInfo * python/libvirt-override.c: Manual impl of virDomainGetBlockInfo
* nwfilter: python bindings for nwfilterStefan Berger2010-04-295-4/+198
| | | | | I have primarily followed the pattern of the 'secret' driver to provide support for the missing python bindings for the network filter API.
* Don't ship generated python/libvirt.? files.Philipp Hahn2010-04-201-1/+2
| | | | | | | | | | | | | libvirt.c and libvirt.h are auto-generated files. Mentioning their names in *_SOURCES includes them in the distribution. During an out-of-tree build these shipped files are included instead of the auto-generated version, potentially breaking the build (as it happend in 0.8.0, because the shipped libvirt.h was missing the declaration for 'libvirt_virDomainUpdateDeviceFlags') Use the nodist_*_SOURCES automake variable instead. Signed-off-by: Philipp Hahn <hahn@univention.de>
* Fixup python binding for virDomainSnapshot APIsDaniel P. Berrange2010-04-203-1/+78
| | | | | | | | | | The generator code was totally wrong for the virDomainSnapshot APIs, not generating the wrapper class, and giving methods the wrong names * generator.py: Set metadata for virDomainSnapshot type & APIs * libvirt-override-api.xml, libvirt-override.c: Hand-code the virDomainSnapshotListNames glue layer
* More event callback fixesv0.8.0Daniel P. Berrange2010-04-091-2/+50
| | | | | | | | | | | In a couple of cases typos meant we were firing the wrong type of event. In the python code my previous commit accidentally missed some chunks of the code. * python/libvirt-override-virConnect.py: Add missing python glue accidentally left out of previous commit * src/conf/domain_event.c, src/qemu/qemu_monitor_json.c: Fix typos in event name / method name to invoke
* Fix up python bindings for new event callbacksDaniel P. Berrange2010-04-082-0/+496
| | | | | | | | | | | | | The generator was disabled for the new event callbacks, since they need to be hand written. This patch adds the C and python glue to expose the new APIs in the python binding. The python example program is extended to demonstrate of the code * python/libvirt-override.c: Registration and dispatch of events at the C layer * python/libvirt-override-virConnect.py: Python glue for events * examples/domain-events/events-python/event-test.py: Demo use of new event callbacks