Commit Graph

1618 Commits

Author SHA1 Message Date
Daniel P. Berrange
40911b66d4 Remove existing OOM test impl
The current OOM test impl is too inefficient to be used on the
large test suites. It loops running 'main' multiple times, once
for each alloc in the 'main' method. This has complexity
'n * (n + 1) / 2' in terms of total alloc count. It will be
replaced by a more efficient impl whicih runs individual test
cases instead. This will have same complexity but the values
of 'n' will be much smaller, so a net win.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-10-08 12:39:30 +01:00
Daniel P. Berrange
50ee3e0357 Don't clobber 'ret' variable in testCompareXMLToXMLHelper
The qemuxml2xmltest.c function testCompareXMLToXMLHelper would
clobber the 'ret' variable causing it to mis-diagnose OOM
errors.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-10-08 12:39:30 +01:00
Giuseppe Scrivano
ba1a91cd1f tests: avoid compile failure on linux kernels older than 2.6.19
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2013-10-07 08:40:30 -06:00
Daniel P. Berrange
b77b16ce41 Remove virConnectPtr arg from virNWFilterDefParse*
None of the virNWFilterDefParse* methods require a virConnectPtr
arg, so just drop it

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-10-07 14:19:10 +01:00
Eric Blake
815e3098ef build: fix build on 32-bit platforms
qemumonitorjsontest.c: In function 'testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo':
qemumonitorjsontest.c:1134: warning: integer constant is too large for 'long' type

* tests/qemumonitorjsontest.c
(testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo)
(testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo): Use correct
type.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-04 17:47:49 -06:00
Eric Blake
bdc55cc7d2 build: fix build --without-remote
I tried to test ./configure --without-lxc --without-remote.
First, the build failed with some odd errors, such as an
inability to build xen, or link failures for virNetTLSInit.
But when you think about it, once there is no remote code,
all of libvirtd is useless, any stateful driver that depends
on libvirtd is also not worth compiling, and any libraries
used only by RPC code are not needed.  So I patched
configure.ac to make for some saner defaults when an
explicit disable is attempted.  Similarly, since we have
migrated virnetdevbridge into generic code, the workaround
for Linux kernel stupidity must not depend on stateful
drivers being in use.

Then there's 'make check' that needs segregation.

Wow - quite a bit of cleanup to make --without-remote useful :)

* configure.ac: Let --without-remote toggle defaults on stateful
drivers and other libraries.  Pick up Linux kernel workarounds
even when qemu and lxc are not being compiled.
* tests/Makefile.am (test_programs): Factor out programs that
require remote.
* src/libvirt_private.syms (rpc/virnet*.h): Move...
* src/libvirt_remote.syms: ...into new file.
* src/Makefile.am (SYM_FILES): Ship new syms file.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-04 17:01:47 -06:00
Michal Privoznik
50c5818c0d qemucapabilitiesdata: Add qemu-1.6.50 data
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-03 15:52:06 +02:00
Michal Privoznik
3e17d7956f qemucapabilitiesdata: Add qemu-1.6.0 data
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-03 15:52:06 +02:00
Michal Privoznik
47674a2241 qemucapabilitiesdata: Add qemu-1.4.2 data
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-03 15:52:06 +02:00
Michal Privoznik
37819287f8 qemucapabilitiesdata: Add qemu-1.3.1 data
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-03 15:52:06 +02:00
Michal Privoznik
f44cea7374 qemucapabilitiesdata: Add qemu-1.2.2 data
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-03 15:52:06 +02:00
Michal Privoznik
2d670cd42b qemuMonitorTestFree: Join worker thread
Join the worker thread no matter if it is running or zombie already.
With current implementation the thread is joined iff @running is true.
However, when worker executes the last line, @running is set to false.
Hence qemuMonitorTestFree() won't join it (and free resources) even
though we can clearly see worker has run (nobody else sets @running =
false).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-03 15:26:09 +02:00
Michal Privoznik
555b042016 qemumonitorjsontest: Test qemuMonitorJSONSystemPowerdown
Right now, we are testing qemuMonitorSystemPowerdown instead of
qemuMonitorJSONSystemPowerdown. It makes no harm, as both functions have
the same header and the former is just a wrapper over the latter. But we
should be consistent as we're testing the JSON functions only in here.
2013-10-03 12:47:53 +02:00
Michal Privoznik
f371400262 qemumonitorjsontest: Test qemuMonitorJSONGetMigrationCapability
And so do qemuMonitorJSONSetMigrationCapability.
2013-10-03 11:35:09 +02:00
Michal Privoznik
02d57c7226 qemumonitorjsontest: Test qemuMonitorJSONGetTargetArch 2013-10-03 11:33:07 +02:00
Michal Privoznik
a328f222fc qemumonitorjsontest: Test qemuMonitorJSONSetBlockIoThrottle
Also do qemuMonitorJSONGetBlockIoThrottle.
2013-10-03 11:32:15 +02:00
Michal Privoznik
4e2a02fe41 qemumonitorjsontest: Test qemuMonitorJSONGetPtyPaths 2013-10-03 11:31:17 +02:00
Michal Privoznik
3491d7b539 qemumonitorjsontest: Test qemuMonitorJSONGetSpiceMigrationStatus 2013-10-03 11:31:06 +02:00
Michal Privoznik
e0decbf05a qemumonitorjsontest: Test qemuMonitorJSONGetMigrationStatus 2013-10-03 11:30:09 +02:00
Michal Privoznik
1280eb0a9d qemumonitorjsontest: Test qemuMonitorJSONGetMigrationCacheSize 2013-10-03 11:29:56 +02:00
Michal Privoznik
846fd13dda qemumonitorjsontest: Test qemuMonitorJSONGetBlockStatsInfo
While the reply can be reused test qemuMonitorJSONGetBlockExtent and
qemuMonitorJSONGetBlockExtent too.
2013-10-03 11:29:39 +02:00
Michal Privoznik
7d655f08cf qemumonitorjsontest: Test qemuMonitorJSONGetBlockInfo 2013-10-03 11:29:29 +02:00
Michal Privoznik
50dc5a398b qemumonitorjsontest: Test qemuMonitorJSONGetBalloonInfo 2013-10-03 11:25:53 +02:00
Cole Robinson
25314fa6c5 test: Wire up managed save APIs
Also add a <test:hasmanagedsave> element to set this data when starting
the connection.
2013-10-01 11:33:56 -04:00
Michal Privoznik
63857eb4a0 tests: Introduce qemucapabilitiestest
This test is there to ensure that our capabilities detection code isn't
broken somehow.

How to gather test data:

Firstly, the data is split into two separate files. The former (with
suffix .replies) contains all the qemu replies. This is very fragile as
introducing a new device can mean yet another monitor command and hence
edit of this file in the future. But there's no better way of doing
this. To get this data simply turn on debug logs and copy all the
QEMU_MONITOR_IO_PROCESS lines. But be careful to not copy incomplete
ones (yeah, we report some incomplete lines too). Long story short, at
the libvirtd startup, a dummy qemu is spawn to get all the capabilities.

The latter (with suffix .caps) contains capabilities XML. Just start a
domain and copy the corresponding part from its state XML file.
Including <qemuCaps> tag.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-01 11:13:36 +02:00
Michal Privoznik
bd958586ec qemuMonitorTest: Make check for monitor command match optional
In a few cases we might want to not care if monitor command executed on
the mocked monitor matches the one we have reply for. Sounds crazy, but
if we just want monitor to return certain values (e.g. read from a file)
there is no need to care about command match.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-01 10:48:47 +02:00
Michal Privoznik
0badd8a43d tests: Learn qemuMonitorTestNew optional greeting
Currently, when creating a new mocked monitor, the greeting can't be
chosen. This is crucial for next patches, because some info as qemu
version is obtained in the greeting message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-01 10:48:47 +02:00
Doug Goldstein
2817353db5 VMware: Add Fusion version test
This adds a test for the version string of VMware Fusion.
2013-09-30 16:58:37 -05:00
Cédric Bosdonnat
bd773e74f0 LXC: workaround machined uncleaned data with containers running systemd.
The problem is described by [0] but its effect on libvirt is that
starting a container with a full distro running systemd after having
stopped it simply fails.

The container cleanup now calls the machined Terminate function to make
sure that everything is in order for the next run.

 [0]: https://bugs.freedesktop.org/show_bug.cgi?id=68370
2013-09-30 16:47:23 +01:00
Michal Privoznik
4679e9422a fchosttest: Run the test only under linux
Currently, we have functions to handle fc_host implemented just
for linux. On all other platforms an error is thrown. It makes no
sense to run the test on those platforms then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-09-27 18:32:43 +02:00
Eric Blake
9940392c2f build: fix testsuite building under cygwin
Similar to commit 8f34f19.

* tests/Makefile.am (virnetserverclienttest_CFLAGS): Add XDR_CFLAGS.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-09-27 07:26:09 -06:00
Peter Krempa
795527548f conf: Don't crash on invalid chardev source definition of RNGs and other
Since commit 297c99a5 an invalid source definition XML of a character
device that is used as backend for RNG devices, smartcards and redirdevs
causes crash of the daemon when parsing such a definition.

The device types mentioned above are not a part of a regular character
device but are backends for other types. Thus when parsing such device
NULL is passed as the argument @chr_def. Later when checking the
validity of the definition @chr_def was dereferenced when parsing a UNIX
socket backend with missing path of the socket and crashed the daemon.

Sample offending configuration:
  <devices>
  ...
    <rng model='virtio'>
      <backend model='egd' type='unix'>
        <source mode='bind' service='1024'/>
      </backend>
    </rng>
  </devices>

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1012196
2013-09-26 08:48:38 +02:00
Daniel P. Berrange
b32ac57ee5 Avoid use of uninitialized data in virnetmessagetest
If an error occurs in virnetmessagetest it was possible it
would free uninitialized data.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
a93eb09a97 Avoid crash on OOM in virnetmessagetest
The virnetmessagetest code did not check for failure to
allocate the message object. This lead to a crash on OOM
in the test suite.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
5e67ed4215 Avoid crash on OOM in virportallocatortest
The virportallocatortest did not check if the object
allocation failed in all cases. This lead to a crash
on OOM in the testsuite

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
7617e5e45d Avoid crash on OOM in virlockspacetest
The virlockspacetest.c did not check for failure to create
a lockspace, causing a crash on OOM

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
0b30d3458a Avoid crash on OOM in virbuftest
The virbuftest code did not check virBufferError before
accessing the buffer contents, resulting in a crash on
OOM conditions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
0bbeafc768 Avoid uninitialized data in qemuMonitorTestNew
The virDomainChrSourceDef variable should be memset to
0, so that the cleanup block does not free uninitialized
data on OOM.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
9129f9b3f1 Avoid double free in qemuMonitorCommonTestInit on OOM
The qemuMonitorCommonTestInit method did not allocate the
test object, so it should not free it upon failure. Doing
so causes a double free with the caller.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
92f8c3fc71 Fix leak on OOM in qemuMonitorCommonTestNew
Don't leak the path string in qemuMonitorCommonTestNew if
an OOM occurs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
4f2094346d Don't ignore errors parsing nwfilter rules
For inexplicable reasons, the nwfilter XML parser is intentionally
ignoring errors that arise during parsing. As well as meaning that
users don't get any feedback on their XML mistakes, this will lead
it to silently drop data in OOM conditions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
1bf1b38773 Don't print all test suite errors to stderr in vmx2xmltest
The vmx2xmltest test would print all errors to stderr, which
is not helpful when running OOM tests, and differs from the
behaviour of other tests.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:09 +01:00
Daniel P. Berrange
3debed1bbd Don't clobber 'ret' in LXC XML test case
The testCompareXMLToXMLHelper method clobbered the 'ret' variable
in several places leading to a failure to report OOM errors from
the test suite.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:08 +01:00
Daniel P. Berrange
3169991555 Fix handling of OOM when getting Xen dom ID
The methods for obtaining the Xen dom ID cannot distinguish
between returning -1 due to an error and returning -1 due to
the domain being shutoff. Change them to return the dom ID
via an output parameter.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-25 18:12:08 +01:00
Laine Stump
386ebb47a5 qemu: prefer to put a Q35 machine's dmi-to-pci-bridge at 00:1E.0
This resolves one of the issues listed in:

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

00:1E.0 is the location of this controller on at least some actual Q35
hardware, so we try to replicate the placement. The bridge should work
just as well in any other location though, so if 00:1E.0 isn't
available, just allow it to be auto-assigned anywhere appropriate.
2013-09-25 10:39:23 -04:00
Laine Stump
b83d26f6c4 qemu: support ich9-intel-hda audio device
This resolves one of the issues in:

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

This device is identical to qemu's "intel-hda" device (known as "ich6"
in libvirt), but has a different PCI device ID (which matches the ID
of the hda audio built into the ich9 chipset, of course). It's not
supported in earlier versions of qemu, so it requires a capability
bit.
2013-09-25 10:38:02 -04:00
Daniel P. Berrange
de87497fd1 Fix format specifier for OOM test fprintfs
The testutils.c file had some fprintfs which had not been
converted from %d to %zu, when 'testCounter' change to be
a size_t. This was a build breaker if --enable-test-oom
was enabled

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-24 16:56:53 +01:00
Daniel P. Berrange
6fdafe278d Add test case for virNetServerClient object identity code
Start a test case for the virNetServerClient object, which
initially checks the creation of a virIdentityPtr object.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-09-24 09:37:26 +01:00
Doug Goldstein
7457cbe871 VMware: Make version parsing testable and add tests
This splits up the version parsing code into a callable API like QEMU
help/version string parsing so that we can test it as we need to add
additional patterns for newer versions/products.
2013-09-20 08:23:31 -05:00
Ján Tomko
5b36ab900a Don't dereference NULL in qemumonitorjsontest
In case of an error, qemuMonitorTestNewSimple returns NULL.
Error out instead of dereferencing it.

Found by Coverity, reported by John Ferlan.
2013-09-20 13:46:13 +02:00