Commit Graph

10967 Commits

Author SHA1 Message Date
Osier Yang
ec448fbf17 list: Expose virConnectListAllInterfaces to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py:
  * New file, includes implementation of listAllInterfaces.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-12 15:37:09 +08:00
Osier Yang
3c2e6472d8 list: Use virConnectListAllInterfaces in virsh
tools/virsh-interface.c:
  * vshInterfaceSorter to sort interfaces by name

  * vshInterfaceListFree to free the interface objects list.

  * vshInterfaceListCollect to collect the interface objects, trying
    to use new API first, fall back to older APIs if it's not supported.
2012-09-12 15:37:09 +08:00
Osier Yang
a3cf061c82 list: Implement listAllInterfaces
This is not that ideal as API for other objects, as it's still
O(n). Because interface driver uses netcf APIs to manage the
stuffs, instead of by itself. And netcf APIs don't return a object.
It provides APIs like old libvirt APIs:

   ncf_number_of_interfaces
   ncf_list_interfaces
   ncf_lookup_by_name
   ......

Perhaps we should further improve netcf to let it provide an API
to return the object, but it could be a later patch. And anyway,
we will still benefit from the new API for the simplification,
and no race like the old APIs.

src/interface/netcf_driver.c: Implement listAllInterfaces
2012-09-12 15:37:09 +08:00
Osier Yang
65741d84ed list: Implemente RPC calls for virConnectListAllInterfaces
The RPC generator doesn't support returning list of object yet, this patch
do the work manually.

  * daemon/remote.c:
    Implemente the server side handler remoteDispatchConnectListAllInterfaces.

  * src/remote/remote_driver.c:
    Add remote driver handler remoteConnectListAllInterfaces.

  * src/remote/remote_protocol.x:
    New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES and
    structs to represent the args and ret for it.

  * src/remote_protocol-structs: Likewise.
2012-09-12 15:36:56 +08:00
Osier Yang
f4af202f4e list: Define new API virConnectListAllInterfaces
This is to list the interface objects, supported filtering flags
are: active|inactive.

include/libvirt/libvirt.h.in: Declare enum virConnectListAllInterfaceFlags
                              and virConnectListAllInterfaces.
python/generator.py: Skip auto-generating
src/driver.h: (virDrvConnectListAllInterfaces)
src/libvirt.c: Implement the public API
src/libvirt_public.syms: Export the symbol to public
2012-09-12 15:19:46 +08:00
Eric Blake
01fa1d7a5e docs: mention another iaas app built on libvirt
Reported on the libvirt-users list.

* docs/apps.html.in: Add Eucalyptus.
Reported by Eric Choi.
2012-09-12 10:35:59 +08:00
Hu Tao
f7e1a546f2 fix bug in qemuSetupCgroupForEmulator
Should not return 0 when failed to setup cgroup.
2012-09-11 16:08:41 -06:00
Eric Blake
f36fadca10 build: avoid dirty docs on fresh bootstrap
* HACKING: Regenerate.
2012-09-11 15:26:10 -06:00
Federico Simoncelli
984a73c0b3 python: Initialize new_params in virDomainSetSchedulerParameters
The new_params variable must be initialized in case the
virDomainGetSchedulerParameters call fails and we hit the cleanup
section before actually allocating the new parameters.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
2012-09-11 15:19:30 -06:00
Ján Tomko
0b2c40d455 docs: page.xsl: fix FAQ link in subdirectories
Links to the FAQ didn't work on pages in subdirectories, like
devhelp/libvirt-virterror.html or internals/command.html, because
they have had href_base prepended to them.
2012-09-11 17:36:03 +02:00
Ján Tomko
24d7f3d534 docs: hacking.html.in: fix table of contents
Two sections didn't have a working link in the TOC.
2012-09-11 16:45:54 +02:00
Osier Yang
819ea2084f Build: Fix typos which cause build failure
Pushed under trivial rule.
2012-09-11 20:15:15 +08:00
Daniel P. Berrange
d95606e3d8 Don't invoke the auth callback if all credentials were in config file
The remote driver first looks at the libvirt auth config file to
fill in any credentials. It then invokes the auth callback for
any remaining credentials. It was accidentally invoking the
auth callback even if there were not any more credentials
required.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-11 12:16:18 +01:00
Daniel P. Berrange
48fea23ba5 Call virResetLastError in all virConnectOpen* functions
All public API functions must call virResetLastError to clear
out any previous error. The virConnectOpen* functions forgot
to do this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-11 12:16:17 +01:00
Daniel P. Berrange
3f3d2f9dfc Check against python None type when filling in auth parameters
When deciding whether to provide an auth function callback
in openAuth(), credcb was checked against NULL, when it
really needs to be checked against Py_None

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-11 12:16:17 +01:00
Daniel P. Berrange
01573bdf4f Print any exception that occurs in authentication callback
If an exception occurs in the python callback for openAuth()
the stack trace isn't seen by the apps, since this code is
called from libvirt context. To aid diagnostics, print the
error to stderr at least

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-11 12:16:17 +01:00
Daniel P. Berrange
e73ff9763a Fix crash passing an empty list to python openAuth() API
If passing a 'credtype' parameter which was an empty list
to the python openAuth() API, the 'credtype' field in
the virConnectAuth struct would not be initialized. This
lead to a crash when later trying to free that field.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-11 12:16:17 +01:00
Osier Yang
3dcafffe17 virsh: Fix the typos
* tools/virsh-network.c: s/MATCH/VSH_MATCH/
2012-09-11 18:50:12 +08:00
Osier Yang
9cc4270112 list: Expose virConnectListAllNetworks to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py: Implement listAllNetworks.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-11 18:35:14 +08:00
Osier Yang
895913dd59 list: Use virConnectListAllNetworks in virsh
tools/virsh-network.c:
  * vshNetworkSorter to sort networks by name

  * vshNetworkListFree to free the network objects list.

  * vshNetworkListCollect to collect the network objects, trying
    to use new API first, fall back to older APIs if it's not supported.

  * New options --persistent, --transient, --autostart, --no-autostart,
    for net-list, and new field 'Persistent' for its output.

tools/virsh.pod:
  * Add documents for the new options.
2012-09-11 18:35:06 +08:00
Osier Yang
4a27ac1de1 list: Implement listAllNetworks for test driver
src/test/test_driver.c: Implement listAllNetworks.
2012-09-11 17:01:25 +08:00
Osier Yang
f07034159e list: Implement listAllNetworks for network driver
src/network/bridge_driver.c: Implement listAllNetworks.
2012-09-11 17:00:46 +08:00
Osier Yang
d3c6cabbac list: Add helpers to list network objects
src/conf/network_conf.c: Add virNetworkMatch to filter the networks;
and virNetworkList to iterate over all the networks with the filter.

src/conf/network_conf.h: Declare virNetworkList and define the macros
for filters.

src/libvirt_private.syms: Export virNetworkList.
2012-09-11 16:59:51 +08:00
Osier Yang
eff8a8dbb1 list: Implement RPC calls for virConnectListAllNetworks
The RPC generator doesn't support returning list of object, this patch
do the work manually.

* daemon/remote.c:
  Implemente the server side handler remoteDispatchConnectListAllNetworks.

* src/remote/remote_driver.c:
  Add remote driver handler remoteConnectListAllNetworks.

* src/remote/remote_protocol.x:
  New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS and
  structs to represent the args and ret for it.

* src/remote_protocol-structs: Likewise.
2012-09-11 16:59:33 +08:00
Osier Yang
89a1df9b06 list: Define new API virConnectListAllNetworks
This is to list the network objects, supported filtering flags
are: active|inactive, persistent|transient, autostart|no-autostart.

include/libvirt/libvirt.h.in: Declare enum virConnectListAllNetworkFlags
                              and virConnectListAllNetworks.
python/generator.py: Skip auto-generating
src/driver.h: (virDrvConnectListAllNetworks)
src/libvirt.c: Implement the public API
src/libvirt_public.syms: Export the symbol to public
2012-09-11 16:58:16 +08:00
Christophe Fergeau
164c03d33b Fix unwanted closing of libvirt client connection
e5a1bee07 introduced a regression in Boxes: when Boxes is left idle
(it's still doing some libvirt calls in the background), the
libvirt connection gets closed after a few minutes. What happens is
that this code in virNetClientIOHandleOutput gets triggered:

if (!thecall)
    return -1; /* Shouldn't happen, but you never know... */

and after the changes in e5a1bee07, this causes the libvirt connection
to be closed.

Upon further investigation, what happens is that
virNetClientIOHandleOutput is called from gvir_event_handle_dispatch
in libvirt-glib, which is triggered because the client fd became
writable. However, between the times gvir_event_handle_dispatch
is called, and the time the client lock is grabbed and
virNetClientIOHandleOutput is called, another thread runs and
completes the current call. 'thecall' is then NULL when the first
thread gets to run virNetClientIOHandleOutput.

After describing this situation on IRC, danpb suggested this:

11:37 < danpb> In that case I think the correct thing would be to change
               'return -1' above to 'return 0' since that's not actually an
               error - its a rare, but expected event

which is what this patch is doing. I've tested it against master
libvirt, and I didn't get disconnected in ~10 minutes while this
happens in less than 5 minutes without this patch.
2012-09-10 14:13:06 +02:00
Osier Yang
fa2e35a336 list: Expose virStoragePoolListAllVolumes to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virStoragePool.py:
  * New file, includes implementation of listAllVolumes.

python/libvirt-override.c: Implementation for the wrapper.
2012-09-10 10:41:18 +08:00
Osier Yang
7e9548fce3 list: Use virStoragePoolListAllVolumes in virsh
tools/virsh-volume.c:
  * vshStorageVolSorter to sort storage vols by name

  * vshStorageVolumeListFree to free the volume objects list

  * vshStorageVolumeListCollect to collect the volume objects, trying
    to use new API first, fall back to older APIs if it's not supported.
2012-09-10 10:40:34 +08:00
Osier Yang
a4d7f4a0d9 list: Implement virStoragePoolListAllVolumes for test driver
src/test/test_driver.c: Implement poolListAllVolumes.
2012-09-10 10:39:58 +08:00
Osier Yang
7254a3670e list: Implement virStoragePoolListAllVolumes for storage driver
src/storage/storage_driver.c: Implement poolListAllVolumes.
2012-09-10 10:38:57 +08:00
Osier Yang
a8bac1c0f3 list: Implement RPC calls for virStoragePoolListAllVolumes
The RPC generator doesn't returning support list of object, this
patch do the work manually.

  * daemon/remote.c:
    Implemente the server side handler remoteDispatchStoragePoolListAllVolumes

  * src/remote/remote_driver.c:
    Add remote driver handler remoteStoragePoolListAllVolumes

  * src/remote/remote_protocol.x:
    New RPC procedure REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES and
    structs to represent the args and ret for it.

  * src/remote_protocol-structs: Likewise.
2012-09-10 10:37:43 +08:00
Osier Yang
a42eac601e list: Define new API virStoragePoolListAllVolumes
Simply returns the storage volume objects. No supported filter
flags.

include/libvirt/libvirt.h.in: Declare the API
python/generator.py: Skip the function for generating. virStoragePool.py
                     will be added in later patch.
src/driver.h: virDrvStoragePoolListVolumesFlags
src/libvirt.c: Implementation for the API.
src/libvirt_public.syms: Export the symbol to public
2012-09-10 10:37:22 +08:00
Matthias Bolte
aa7c4068a8 esx: Remove unused variable from esxDomainGetAutostart 2012-09-09 12:44:20 +02:00
Laine Stump
7038322991 docs: point out git send-email location, be more stern about make check
An email came to libvir-list wondering why the git send-email command
was missing in spite of having git installed; this is due to the
send-email command being in a sub-package of the main git package.

While touching the hacking file, I thought it would be useful to 1)
indicate the location of the source (docs/hacking.html.in) in the
message at the top of HACKING, and also to make the note about running
"make check" and "make syntax-check" a bit more stern.
2012-09-08 23:20:29 -04:00
Eric Blake
892242519a build: fix build on older gcc
On RHEL 6.2, gcc 4.4.6 complains:
cc1: warning: command line option "-Wenum-compare" is valid for C++/ObjC++ but not for C
which in turn breaks a -Werror build.

Meanwhile, in Fedora 17, gcc 4.7.0, -Wenum-compare has been enhanced
to also work on C, but at the same time, it is documented that -Wall
now implicitly includes -Wenum-compare.

Therefore, it is sufficient to remove explicit checks for this option,
avoiding the warning from older gcc while still getting the
compile-time safety from newer gcc.

* m4/virt-compile-warnings.m4 (-Wenum-compare): Omit explicit check.
2012-09-07 14:15:22 -06:00
Daniel P. Berrange
3f685c4dd8 Fix RPM spec conditional when %{rhel} is not defined 2012-09-07 16:45:50 +01:00
Christophe Fergeau
defa8b8589 events: Fix domain event race on client disconnect
GNOME Boxes sometimes stops getting domain events from libvirtd, even
after restarting it. Further investigation in libvirtd shows that
events are properly queued with virDomainEventStateQueue, but the
timer virDomainEventTimer which flushes the events and sends them to
the clients never gets called. Looking at the event queue in gdb
shows that it's non-empty and that its size increases with each new
events.

virDomainEventTimer is set up in virDomainEventStateRegister[ID]
when going from 0 client connecte to 1 client connected, but is
initially disabled. The timer is removed in
virDomainEventStateRegister[ID] when the last client is disconnected
(going from 1 client connected to 0).

This timer (which handles sending the events to the clients) is
enabled in virDomainEventStateQueue when queueing an event on an
empty queue (queue containing 0 events). It's disabled in
virDomainEventStateFlush after flushing the queue (ie removing all
the elements from it). This way, no extra work is done when the queue
is empty, and when the next event comes up, the timer will get
reenabled because the queue will go from 0 event to 1 event, which
triggers enabling the timer.

However, with this Boxes bug, we have a client connected (Boxes), a
non-empty queue (there are events waiting to be sent), but a disabled
timer, so something went wrong.

When Boxes connects (it's the only client connecting to the libvirtd
instance I used for debugging), the event timer is not set as expected
(state->timer == -1 when virDomainEventStateRegisterID is called),
but at the same time the event queue is not empty. In other words,
we had no clients connected, but pending events. This also explains
why the timer never gets enabled as this is only done when an event
is queued on an empty queue.

I think this can happen if an event gets queued using
virDomainEventStateQueue and the client disconnection happens before
the event timer virDomainEventTimer gets a chance to run and flush
the event. In this situation, virDomainEventStateDeregister[ID] will
get called with a non-empty event queue, the timer will be destroyed
if this was the only client connected. Then, when other clients connect
at a later time, they will never get notified about domain events as
the event timer will never get enabled because the timer is only
enabled if the event queue is empty when virDomainEventStateRegister[ID]
gets called, which will is no longer the case.

To avoid this issue, this commit makes sure to remove all events from
the event queue when the last client in unregistered. As there is
no longer anyone interested in receiving these events, these events
are stale so there is no need to keep them around. A client connecting
later will have no interest in getting events that happened before it
got connected.
2012-09-07 14:45:00 +02:00
Daniel P. Berrange
bd172f1345 Fix location of SELinux mount during RPM builds
When building RPMs the host kernel cannot be assumed to match
the target OS kernel. Thus auto-detecting /selinux vs
/sys/fs/selinux based on the host kernel can result in the
wrong choice (eg F18 builds on a RHEL6 host kernel)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-07 13:31:00 +01:00
Daniel P. Berrange
a4fd740561 Don't assume use of /sys/fs/cgroup
The introduction of /sys/fs/cgroup came in fairly recent kernels.
Prior to that time distros would pick a custom directory like
/cgroup or /dev/cgroup. We need to auto-detect where this is,
rather than hardcoding it

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-07 13:30:20 +01:00
Daniel P. Berrange
48d112210d Introduce a test suite for the JSON monitor
Take advantage of the previously added monitor helpers to
create a test suite for the QEMU JSON monitor impl. As a
proof of concept, this tests the 'qemuMonitorGetStatus'
implementation

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-07 13:18:09 +01:00
Daniel P. Berrange
8d78fd04be Add helper library for testing the qemu monitor code
To be able to test the QEMU monitor code, we need to have a fake
QEMU monitor server. This introduces a simple (dumb) framework
that can do this. The test case registers a series of items to
be sent back as replies to commands that will be executed. A
thread runs the event loop looking for incoming replies and
sending back this pre-registered data. This allows testing all
QEMU monitor code that deals with parsing responses and errors
from QEMU, without needing QEMU around

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-07 13:18:04 +01:00
Daniel P. Berrange
1f490138ba Add non-null annotations to qemuMonitorOpen
Add some non-null annotations to qemuMonitorOpen and also
check that the error callback is set, since it is mandatory

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-07 13:18:00 +01:00
Jiri Denemark
e2a7f97b2b examples: Fix event detail printing in python test
If there is only one detail string for a particular event, we need to pu
comma after the string otherwise the string itself will be taken as a
list and only its first character will be printed out. For example,

    myDomainEventCallback1 EVENT: Domain fedora17(12) Shutdown F

instead of the desired

    myDomainEventCallback1 EVENT: Domain fedora17(12) Shutdown Finished
2012-09-07 09:38:22 +02:00
Jiri Denemark
fc4115e8d6 Add PMSUSPENDED life cycle event
While PMSUSPENDED state was added a long time ago, we didn't have
corresponding life cycle event.
2012-09-07 09:38:22 +02:00
Jiri Denemark
afab4824eb Fix PMSuspend and PMWakeup events
The unused reason parameter of PM{Suspend,Wakeup} event callbacks was
completely ignored in lot of places and those events were not actually
working at all.
2012-09-07 09:38:22 +02:00
Peter Krempa
51907779ee virsh: Update only changed scheduler tunables
When setting the cpu tunables in virsh you are able to update only a
subset of them. Virsh while doing the update updated all of the
tunables, changed ones with new values and unchanged with old ones.
This is unfortunate as it:
a) might overwrite some other change by a race condition (unprobable)
b) fails with range checking as some of the old values saved might be
   out of range

This patch changes the update procedure so that only the changed value
is updated on the host.

This patch also fixes a very unprobable memory leak if the daemon would
return a string tunable parameter, as the typed parameter array was not
cleared.
2012-09-07 08:08:37 +02:00
Peter Krempa
245cef9f97 util: Add helper to assign typed params from string
This patch adds a helper to deal with assigning values to
virTypedParameter structures from strings. The helper parses the value
from the string and assigns it to the corresponding union value.
2012-09-07 08:08:16 +02:00
Peter Krempa
972e914f59 qemu: Add range checking for scheduler tunables when changed by API
The quota and period tunables for cpu scheduler accept only a certain
range of values. When changing the live configuration invalid values get
rejected. This check is not performed when changing persistent config.

This patch adds a separate range check, that improves error messages
when changing live config and adds the check for persistent config.
This check is done only when using the API. It is still possible to
specify invalid values in the XML.
2012-09-07 07:52:48 +02:00
Peter Krempa
3e250b3669 qemu: clean up qemuSetSchedulerParametersFlags()
This patch tries to clean the code up a little bit and shorten very long
lines.

The apparent semantic change from moving the condition before calling
the setter function is a non-issue here as the setter function is a
no-op when called with both arguments zero.
2012-09-07 07:52:48 +02:00
Osier Yang
6cdf0aafc8 virsh: Improve the document for pool-list
Which is lost by commit 93a346d353.
2012-09-07 11:10:48 +08:00