Commit Graph

10728 Commits

Author SHA1 Message Date
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
Eric Blake
ddd8c3b995 nwfilter: drop use of awk
Commit 2a41bc9 dropped a dependency on gawk, but we can go one step
further and avoid awk altogether.

* src/nwfilter/nwfilter_ebiptables_driver.c
(iptablesLinkIPTablesBaseChain): Simplify command.
(ebiptablesDriverInit, ebiptablesDriverShutdown): Drop awk probe.
2012-09-06 16:33:06 -06:00
Gene Czarcinski
f20b7dbe63 remove dnsmasq command line parameter "--filterwin2k"
This patch removed the "--filterwin2k" dnsmasq command line
parameter which was unnecessary for domain specification,
possibly blocked some usage, and was command line clutter.

Gene Czarcinski <gene@czarc.net>
2012-09-06 10:59:33 -06:00
Eric Blake
ccaf0beec8 build: improved handling of <execinfo.h>, BSD <net/if.h>
FreeBSD and OpenBSD have a <net/if.h> that is not self-contained;
and mingw lacks the header altogether.  But gnulib has just taken
care of that for us, so we might as well simplify our code.  In
the process, I got a syntax-check failure if we don't also take
the gnulib execinfo module.

* .gnulib: Update to latest, for execinfo and net_if.
* bootstrap.conf (gnulib_modules): Add execinfo and net_if modules.
* configure.ac: Let gnulib check for headers.  Simplify check for
'struct ifreq', while also including enough prereq headers.
* src/internal.h (IF_NAMESIZE): Drop, now that gnulib guarantees it.
* src/nwfilter/nwfilter_learnipaddr.h: Use correct header for
IF_NAMESIZE.
* src/util/virnetdev.c (includes): Assume <net/if.h> exists.
* src/util/virnetdevbridge.c (includes): Likewise.
* src/util/virnetdevtap.c (includes): Likewise.
* src/util/logging.c (includes): Assume <execinfo.h> exists.
(virLogStackTraceToFd): Handle gnulib's fallback implementation.
2012-09-06 10:08:47 -06:00
Eric Blake
b6a14aec5f build: avoid tabs that failed syntax-check
Introduced in commit f299ddd6.

* src/check-symfile.pl: Fix whitespace.
* .dir-locals.el (perl-mode): Prevent future occurrences.
2012-09-06 09:43:46 -06:00
Eric Blake
9a6e57517b list: fix typo in virsh patch
A last minute rename in commit fc122e1a to virsh.h was not properly
reflected when rebasing virsh-pool.c in commit 93a346d.

* tools/virsh-pool.c (vshStoragePoolListCollect): Use VSH_MATCH,
not MATCH.
2012-09-06 09:43:23 -06:00
Daniel P. Berrange
f299ddd6b1 Remove duplicate symbols and add test case
When the event symbols were added to the public API, not all
of them were removed from the private exports list. Solaris
gets unhappy when there are duplicated symbols. Extend the
symfile check to test for this scenario
2012-09-06 16:05:41 +01:00
Osier Yang
9278578069 python: Expose virStorageListAllStoragePools 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: Add listAllStoragePools
python/libvirt-override.c: Implementation for the wrapper.
2012-09-06 22:16:11 +08:00
Osier Yang
93a346d353 list: Use virConnectListAllStoragePools in virsh
tools/virsh-pool.c:
  * vshStoragePoolSorter to sort the pool list by pool name.

  * struct vshStoragePoolList to present the pool list, pool info
    is collected by list->poolinfo if 'details' is specified by
    user.

  * vshStoragePoolListFree to free the pool list

  * vshStoragePoolListCollect to collect the pool list, new API
    virStorageListAllPools is tried first, if it's not supported,
    fall back to older APIs.

  * New options --persistent, --transient, --autostart, --no-autostart
    and --type for pool-list. --persistent or --transient is to filter
    the returned pool list by whether the pool is persistent or not.
    --autostart or --no-autostart is to filter the returned pool list
    by whether the pool is autostarting or not. --type is to filter
    the pools by pool types. E.g.

    % virsh pool-list --all --persistent --type dir,disk

tools/virsh.pod:
   * Add documentations for the new options.
2012-09-06 22:09:49 +08:00
Osier Yang
fc122e1a40 list: Change MATCH for common use in virsh
Move definition of MATCH from virsh-domain-monitor.c into
virsh.h, and rename it as VSH_MATCH for further use.

* tools/virsh-domain-monitor.c: Change MATCH into VSH_MATCH
* tools/virsh.h: Define VSH_MATCH
2012-09-06 22:06:45 +08:00
Osier Yang
974a63305e virsh: Fix the wrong doc for pool-list
The storage pool's management doesn't relate with a domain, it
probably was an intention, but not achieved yet. And the fact
is only active pools are listed by default.
2012-09-06 22:04:56 +08:00
Osier Yang
f7eac4f722 list: Add helper to convert strings separated by ', ' to array
tools/virsh.c: New helper function vshStringToArray.
tools/virsh.h: Declare vshStringToArray.
tools/virsh-domain.c: use the helper in cmdUndefine.
2012-09-06 22:04:43 +08:00
Osier Yang
cf45862817 list: Implement listAllStoragePools for test driver
src/test/test_driver.c: Implement listAllStoragePools
2012-09-06 22:03:59 +08:00
Osier Yang
c71f989bb5 list: Implement listAllStoragePools for storage driver
src/storage/storage_driver.c: Implement listAllStoragePools.
2012-09-06 22:03:20 +08:00
Osier Yang
17fd00888a list: Implement the RPC calls for virConnectListAllStoragePools
The RPC generator doesn't support returning list of object, this patch does
the work manually.

  * daemon/remote.c:
    Implement the server side handler remoteDispatchConnectListAllStoragePools

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

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

  * src/remote_protocol-structs: Likewise.
2012-09-06 22:02:04 +08:00
Osier Yang
84208a4a8b list: Add helpers for listing storage pool objects
src/conf/storage_conf.c: Add virStoragePoolMatch to filter the
pools; Add virStoragePoolList to iterate over the pool objects
with filter.

src/conf/storage_conf.h: Declare virStoragePoolMatch,
virStoragePoolList, and the macros for filters.

src/libvirt_private.syms: Export helper virStoragePoolList.
2012-09-06 21:59:00 +08:00
Osier Yang
075c754af0 list: Define new API virStorageListAllStoragePools
This introduces a new API to list the storage pool objects,
4 groups of flags are provided to filter the returned pools:

  * Active or not

  * Autostarting or not

  * Persistent or not

  * And the pool type.

include/libvirt/libvirt.h.in: New enum virConnectListAllStoragePoolFlags;
                              Declare the API.
python/generator.py: Skip the generating
src/driver.h: (virDrvConnectListAllStoragePools)
src/libvirt.c: Implementation for the API.
src/libvirt_public.syms: Export the symbol.
2012-09-06 21:58:36 +08:00
Peter Krempa
9e0ba44faf esx: Add implementation for virConnectListAllDomains()
ESX doesn't use the common virDomainObj implementation so this patch
adds a separate implementation.

This driver supports all currently defined filtering flags, but as with
other drivers some combinations yield a empty result list.
2012-09-06 11:06:10 +02:00
Peter Krempa
60d0ecdaa1 hyperv: Add implementation for virConnectListAllDomains()
Hyperv doesn't use the common virDomainObj implementation so this patch
adds a separate implementation.

This driver supports all currently added flags for filtering although
some of those don't make sense with this driver (no support yet) and
thus produce no output when used.
2012-09-06 10:04:30 +02:00
Jasper Lievisse Adriaanse
edc67a6f5d Define DYNLIB_NAME on OpenBSD. 2012-09-06 15:26:44 +08:00
Eric Blake
5d3b65f96b build: avoid test failure when sasl was not compiled in
On systems without cyrus-sasl-devel available (I happened to be
in that situation on my FreeBSD testing), this test fails rather
miserably:

TEST: libvirtdconftest
      .....!!!!!!...!!!!!!!!!!!!!!!!!!!!!!!!!  39  FAIL
FAIL: libvirtdconftest

with verbose output showing things like:

39) Test corruption                                          ... libvir: Config File error : unsupporeted configuration: remoteReadConfigFile: /usr/home/dummy/libvirt/tests/../daemon/libvirtd.conf: auth_tcp: unsupported auth sasl

* tests/libvirtdconftest.c (testCorrupt): Avoid failure when sasl
is missing.
2012-09-05 15:02:01 -06:00
Eric Blake
ae94cf2d13 build: avoid check-symfile on non-Linux
I tested both OpenBSD and cygwin; both failed 'make check' with:

  GEN    check-symfile
Can't return outside a subroutine at ./check-symfile.pl line 13.

Perl requires 'exit 77' instead of 'return 77' in that context,
but even with that tweak, the build still fails, since the exit
code of 77 is only special to explicit TESTS=foo listings, and
not to make-only dependency rules where we are not going through
automake's test framework.

* src/check-symfile.pl: Kill bogus platform check...
* src/Makefile.am (check-symfile): ...and replace with an automake
conditional.
2012-09-05 13:10:18 -06:00
Laine Stump
98e732fc34 network: prevent infinite hang if ovs-vswitchd isn't running
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=852984

If a network or interface is configured to use Open vSwitch, but
ovs-vswitchd (the Open vSwitch database service) isn't running, the
ovs-vsctl add-port/del-port commands will hang indefinitely rather
than returning an error. There is a --nowait option, but that appears
to have no effect on add-port and del-port commands, so instead we add
a --timeout=5 to the commands - they will retry for up to 5 seconds,
then fail if there is no response.
2012-09-05 14:35:04 -04:00
Laine Stump
89810fc423 build: require netcf-0.2.2 when installing on Fedora18+
A previous patch forced libnl-3 and netcf-0.2.2 (which itself requires
libnl-3) when *building* for Fedora 18+ (and RHEL 7+), but the
install-time Requires: for netcf has always been implicit due to
libvirtd linking with libnetcf.so. However, the since the API of netcf
didn't change when it was rebuilt to use libnl-3, the internal library
version didn't change either, making it possible (from rpm's point of
view) to upgrade libvirt without upgrading netcf (in reality, that
leads to a segfault - see
https://bugzilla.redhat.com/show_bug.cgi?id=853381).

The solution is to put an explicit Requires: line in libvirt's
specfile for fedora >= 18 and rhel >= 7.
2012-09-05 14:35:04 -04:00
Eric Blake
d51024aee6 build: don't fail when xsltproc is missing
On a machine without xsltproc, the build failed with:

Scripting search.php
/usr/local/bin/bash: line 1: search.php.tmp: No such file or directory
rm: ./search.php: No such file or directory

Regression introduced in commit 28183590.

* docs/Makefile.am (%.php): Skip in the same conditions when the
.tmp file is skipped.
2012-09-05 12:05:55 -06:00
Eric Blake
c579d6b3d6 build: avoid warnings from gcc 4.2.1
OpenBSD ships with gcc 4.2.1, which annoyingly treats all format
strings as though they were also attribute((nonnull)).  The two
concepts are orthogonal, though, as evidenced by the number of
spurious warnings it generates on uses where we know that
virReportError specifically handles NULL instead of a format
string; worse, since we now force -Werror on git builds, it
prevents development builds on OpenBSD.

I hate to do this, as it disables ALL format checking on older
gcc, and therefore misses out on some useful checks (code that
happened to compile on Linux may still have type mismatches
when compiled on other platforms, as evidenced by the number
of times I have fixed formatting mismatches for uid_t as found
by warnings on Cygwin), but I don't see any other way to keep
-Werror alive and still compile on OpenBSD.

A more invasive change would be to make virReportError() mark
its format attribute as nonnull, and fix (a lot of) fallout;
we may end up doing that anyways as part of danpb's error
refactoring improvements, but not today.

* src/internal.h (ATTRIBUTE_FMT_PRINTF): Use preferred spellings.
* m4/virt-compile-warnings.m4 (-Wformat): Disable on older gcc.
2012-09-05 12:05:55 -06:00
Martin Kletzander
9f86fb9326 qemu: don't pin all the cpus
This is another fix for the emulator-pin series. When going through
the cputune pinning settings, the current code is trying to pin all
the CPUs, even when not all of them are specified. This causes error
in the subsequent function which, of course, cannot find the cpu to
pin. Since it's enough to pass the correct VCPU ID to the function,
the fix is trivial.
2012-09-05 19:25:10 +02:00
Eric Blake
60efb60018 maint: avoid doubled name in syntax check failures
Based on the similar gnulib commit 96ad9077.  The use of
$(_sc_search_regexp) already injects $(ME) into any output
messages, so a failure of these rules would look like this,
pre-patch:

maint.mk: maint.mk: use virStrToLong_*, not strtol variants

* cfg.mk (sc_prohibit_strncmp, sc_prohibit_strtol)
(sc_libvirt_unmarked_diagnostics): Drop redundant $(ME).
2012-09-05 11:16:20 -06:00
Eric Blake
44342a0efe build: use re-entrant functions in virsh
Yesterday's commit 15d2c9f pointed out that virsh was still using
localtime(), which is not thread-safe, even though virsh is
definitely multi-threaded.  Even if we only ever triggered it from
one thread, it's better safe than sorry for maintenance purposes.

* cfg.mk (exclude_file_name_regexp--sc_prohibit_nonreentrant):
Tighten the rule.
* tools/virsh.c (vshOutputLogFile): Avoid localtime.
(vshEditWriteToTempFile, vshEditReadBackFile, cmdCd, cmdPwd)
(vshCloseLogFile): Avoid strerror.
* tools/console.c (vshMakeStdinRaw): Likewise.
* tools/virsh-domain.c (vshGenFileName): Fix spacing in previous
patch.
2012-09-05 11:09:04 -06:00
Daniel P. Berrange
8386b304b0 Remove explicit dependency on ceph RPM
The libvirt storage driver uses librbd.so for its functionality.
RPM will automatically add a dependency on the library, so there
is no need to have an explicit dependency on the ceph RPM itself.
This allows newer Fedora distros to avoid pulling in the huge
ceph RPM, in favour of just having the libraries installed
2012-09-05 10:49:38 +01:00
Jiri Denemark
965ccdd1bd qemu: Do not require auth scheme in graphics events
Only VNC_{{DIS,}CONNECTED,INITIALIZED} and SPICE_INITIALIZED events are
documented to support server/auth field and even there it is marked as
optional. Emit "" auth scheme in case QEMU didn't send it.
2012-09-05 11:27:14 +02:00
Martin Kletzander
95fbc83387 conf: describe security_driver behavior
As a request was raised for this, I added few lines in the "Notes"
part of the "security_driver" comments about allowed values.
2012-09-05 06:46:57 +02:00
Martin Kletzander
aa698a49dd docs: correct dompmwakeup description 2012-09-05 06:36:55 +02:00
Paul Eggert
15d2c9fad4 Pass a correct pointer type to localtime_r(3).
On 09/04/2012 08:20 AM, Eric Blake wrote:
> tv_sec is required by POSIX to be
> of type time_t; so this is a bug in the OpenBSD header
> [for declaring it as long]

Most likely this problem arose because of the patch I pushed
in gnulib commit e07d7c40f3ca5ec410cf5aa6fa03cfe51e712039.
Previously, gnulib required timeval's tv_sec to be
the same size as time_t.  But now, it requires only that
tv_sec be big enough to hold a time_t.

This patch was needed for Emacs.  Without the patch, gnulib
replaced struct timeval on OpenBSD, and this messed up
utimens.c, and Emacs wouldn't build.

Alternatively, gnulib could substitute its own struct timeval
for the system's, wrapping every struct timeval-using function
(gettimeofday, futimesat, futimes, lutimes, etc.  That'd be
more work, though.  And it would introduce some performance
issues with gettimeofday, which is supposed to be fast.

I've been trying to get away from using struct timeval,
and to use the higher-resolution struct timespec instead,
so messing with these obsolescent interfaces has been
lower priority for me.  But if someone wants to take the
more-ambitious approach that'd be fine, I expect.

For this particular case, though, how about if we avoid
the problem entirely?  libvirt doesn't need to use struct
timeval here at all.  It makes libvirt smaller and probably
faster, and it ports to OpenBSD without messing with gnulib.
2012-09-04 17:20:08 -06:00
Eric Blake
d74e5a4dfc build: use correct libraries for clock_gettime
On OpenBSD, clock_gettime() exists in libc rather than librt, and
blindly linking with -lrt made the build fail.  Gnulib already
did the work for determining which libraries to use, so we should
reuse that work rather than doing it ourselves.

* bootstrap.conf (gnulib_modules): Pull in clock-time.
* configure.ac (RT_LIBS): Drop.
* src/Makefile.am (libvirt_util_la_LIBADD): Use gnulib variable
instead.
* src/util/virtime.c (includes): Simplify.
2012-09-04 10:57:25 -06:00
Jasper Lievisse Adriaanse
afa67b7743 Include an extra header needed for OpenBSD. 2012-09-04 10:45:18 -06:00
Viktor Mihajlovski
72f1f2206e Rename iolimit to blockio.
After discussion with DB we decided to rename the new iolimit
element as it creates the impression it would be there to
limit (i.e. throttle) I/O instead of specifying immutable
characteristics of a block device.
This is also backed by the fact that the term I/O Limits has
vanished from newer storage admin documentation.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2012-09-04 09:14:36 -06:00
Jiri Denemark
03c42a4510 qemu: Fix reboot with guest agent
When reboot using qemu guest agent was requested, qemu driver kept
waiting for SHUTDOWN event from qemu. However, such event is never
emitted during guest reboot and qemu driver would keep waiting forever.
2012-09-04 14:09:54 +02:00
Daniel P. Berrange
8675406cea Fix mingw64 build by using intptr_t for int->void* casts
The viratomictest.c was casting from an int to a void* via a
long. This works on Linux or Mingw32, but fails on Mingw64
due to a pointer/integer size mis-match. Replacing 'long'
with 'intptr_t' ensures matching type sizes
2012-09-04 11:16:55 +01:00
Peter Krempa
00b81636c5 qemu: Don't update graphic definitions on password change failure
When the password change failed we updated the graphic definition
anyways, which is not desired.
2012-09-03 16:52:27 +02:00