Commit Graph

53 Commits

Author SHA1 Message Date
Thorsten Behrens
721949059b maint: align whitespaces with project conventions. 2014-01-20 14:35:08 +01:00
Michal Privoznik
88a0894c4d qemumonitorjsontest: Introduce GetNonExistingCPUData test
In the 730af8f2cd commit we are fixing broken qemu startup on systems
with ancient qemu. This commit introduces the regression test for that
specific case to make sure we don't break it again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-11-19 16:30:28 +01:00
Peter Krempa
84f6960214 qemu: Check for presence of device and properities when getting CPUID
The QOM path in qemu that contains the CPUID registers of a running VM
may not be present (introduced in QEMU 1.5).

Since commit d94b781771 we have a regression with QEMU that don't
support reporting of the CPUID register state via the monitor as the
process startup code expects the path to exist.

This patch adds code that checks with the monitor if the requested path
already exists and uses it only in this case.
2013-11-12 19:36:06 +01:00
Peter Krempa
a6a6f84af9 qemu: Change return type of qemuMonitorGetGuestCPU()
To allow returning more granular errors, change the error type to an
integer.
2013-11-12 19:35:51 +01:00
Jiri Denemark
3afde0756f qemu: Add monitor APIs to fetch CPUID data from QEMU
The qemu monitor supports retrieval of actual CPUID bits presented to
the guest using QMP monitor. Add APIs to extract these information and
tests for them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2013-11-08 09:44:36 +01:00
Eric Blake
b8984770dc maint: avoid 'const fooPtr' in tests
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in the testsuite.

* tests/cputest.c (cpuTestCompareXML): Use intended type.
* tests/qemucapabilitiestest.c (testQemuCaps): Likewise.
* tests/qemumonitorjsontest.c: Drop const.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-14 14:34:37 -06:00
Michal Privoznik
c643b64e30 qemumonitorjsontest: Test qemuMonitorJSONSendKey
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-11 10:24:48 +02:00
Michal Privoznik
370a7a7959 qemumonitorjsontest: Test qemuMonitorJSONGetVirtType
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-11 10:22:11 +02:00
Michal Privoznik
ec7005d3c7 qemumonitorjsontest: Test qemuMonitorJSONGetCPUInfo
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-11 10:20:35 +02:00
Michal Privoznik
fbc3adc96d qemumonitorjsontest: Extend the test for yet another monitor commands
So far, we're unit testing some basic functions and some (so called)
simple functions (e.g. "qmp_capabilities", "system_powerdown"). However,
there are more functions which expect simple "{'return': {}}" reply, but
takes more args to construct the command (for instance "set_link"). This
patch aims on such functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-10-11 10:20:15 +02:00
Daniel P. Berrange
eee6eb666c Remove test case average timing
The test case average timing code has not been used by any test
case ever. Delete it to remove complexity.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-10-08 12:39:30 +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
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
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
Michal Privoznik
2cf3a4e526 qemumonitorjsontest: Introduce DO_TEST_SIMPLE
This macro is there to test the simplest monitor functions we have,
those in the form of: int ( *func) (qemuMonitorPtr). So far, we have
seven such functions.
2013-09-19 12:31:59 +02:00
Michal Privoznik
4f1b6df127 qemumonitorjsontest: Test CPU state handling code
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2013-09-19 12:31:59 +02:00
Jiri Denemark
a950b4f91d tests: Add support for passing vm to qemu monitor
Some tests need the monitor to operate on an already existing VM object
rather than on a new mock-up the monitor test normally creates.
2013-08-26 16:09:55 +02:00
Jiri Denemark
c9150d3747 tests: Free test at the end of GetDeviceAliases JSON test
Commit 58b147ad07 added a test for
qemuMonitorGetDeviceAliases but forgot to free the test object at the
end which causes all sort of weird errors and failures when new tests
are added after the GetDeviceAliases.
2013-07-22 16:59:14 +02:00
Jiri Denemark
58b147ad07 qemu: Introduce qemuMonitorGetDeviceAliases
This API provides a NULL-terminated list of devices which are currently
attached to a QEMU domain.
2013-07-19 18:45:47 +02:00
John Ferlan
50336d871a Add qemuMonitorJSONSetObjectProperty() method for QMP qom-set command
Add a new qemuMonitorJSONSetObjectProperty() method to support invocation
of the 'qom-set' JSON monitor command with a provided path, property, and
expected data type to set.

NOTE: The set API was added only for the purpose of the qemumonitorjsontest

The test code uses the same "/machine/i440fx" property as the get test and
attempts to set the "realized" property to "true" (which it should be set
at anyway).
2013-07-15 12:26:16 -04:00
John Ferlan
bdce278984 Add qemuMonitorJSONGetObjectProperty() method for QMP qom-get command
Add a new qemuMonitorJSONGetObjectProperty() method to support invocation
of the 'qom-get' JSON monitor command with a provided path, property, and
expected data type return. The qemuMonitorJSONObjectProperty is similar to
virTypedParameter; however, a future patch will extend it a bit to include
a void pointer to balloon driver statistic data.

NOTE: The ObjectProperty structures and API are added only for the
      purpose of the qemumonitorjsontest

The provided test will execute a qom-get on "/machine/i440fx" which will
return a property "realized".
2013-07-15 12:26:16 -04:00
John Ferlan
d76a89780b Add qemuMonitorJSONGetObjectListPaths() method for QMP qom-list command
Add a new qemuMonitorJSONGetObjectListPaths() method to support invocation
of the 'qom-list' JSON monitor command with a provided path.

NOTE: The ListPath structures and API's are added only for the
      purpose of the qemumonitorjsontest

The returned list of paired data fields of "name" and "type" that can
be used to peruse QOM configuration data and eventually utilize for the
balloon statistics.

The test does a "{"execute":"qom-list", "arguments": { "path": "/"}}" which
returns "{"return": [{"name": "machine", "type": "child<container>"},
{"name": "type", "type": "string"}]}" resulting in a return of an array
of 2 elements with [0].name="machine", [0].type="child<container>".  The [1]
entry appears to be a header that could be used some day via a command such
as "virsh qemuobject --list" to format output.
2013-07-15 12:26:15 -04:00
Michal Privoznik
0f7a7ce5ff qemu_monitor: Introduce qemuMonitorDetachCharDev
This function wraps 'chardev-remove' qemu monitor command around.
It takes chardev alias as its single argument besides qemu monitor
pointer.
2013-07-12 11:00:04 +02:00
Michal Privoznik
4a51447abe qemu_monitor: Introduce qemuMonitorAttachCharDev
The function being introduced is responsible for preparing and
executing 'chardev-add' qemu monitor command. Moreover, in case
of PTY chardev, the corresponding pty path is updated.
2013-07-12 11:00:01 +02:00
Daniel P. Berrange
7a1e691711 Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-10 17:40:13 +01:00
Eric Blake
bd56d0d813 qemu: query command line options in QMP
Ever since the conversion to using only QMP for probing features
of qemu 1.2 and newer, we have been unable to detect features
that are added only by additional command line options.  For
example, we'd like to know if '-machine mem-merge=on' (added
in qemu 1.5) is present.  To do this, we will take advantage
of qemu 1.5's query-command-line-parameters QMP call [1].

This patch wires up the framework for probing the command results;
if the QMP command is missing, or if a particular command line
option does not output any parameters (for example, -net uses
a polymorphic parser, which showed up as no parameters as of qemu
1.5), we silently treat that command as having no results.

[1] https://lists.gnu.org/archive/html/qemu-devel/2013-04/msg05180.html

* src/qemu/qemu_monitor.h (qemuMonitorGetOptions)
(qemuMonitorSetOptions)
(qemuMonitorGetCommandLineOptionParameters): New functions.
* src/qemu/qemu_monitor_json.h
(qemuMonitorJSONGetCommandLineOptionParameters): Likewise.
* src/qemu/qemu_monitor.c (_qemuMonitor): Add cache field.
(qemuMonitorDispose): Clean it.
(qemuMonitorGetCommandLineOptionParameters): Implement new function.
* src/qemu/qemu_monitor_json.c
(qemuMonitorJSONGetCommandLineOptionParameters): Likewise.
(testQemuMonitorJSONGetCommandLineParameters): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-13 15:15:54 -06:00
Stefan Berger
7e77f252bd test: Add JSON test for query-tpm-types
Add a test case for query-tpm-models QMP command.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2013-04-26 08:33:44 -04:00
Peter Krempa
9ea249e7d9 virCaps: get rid of defaultDiskDriverName
This patch removes the defaultDiskDriverName from the virCaps
structure. This particular default value is used only in the qemu driver
so this patch uses the recently added callback to fill the driver name
if it's needed instead of propagating it through virCaps.
2013-04-04 22:42:38 +02:00
Peter Krempa
e84b19316a maint: Rename xmlconf to xmlopt and virDomainXMLConfig to virDomainXMLOption
This patch is the result of running:

for i in $(git ls-files | grep -v html | grep -v \.po$ ); do
  sed -i -e "s/virDomainXMLConf/virDomainXMLOption/g" -e "s/xmlconf/xmlopt/g" $i
done

and a few manual tweaks.
2013-04-04 22:18:56 +02:00
Peter Krempa
27cf98e2d1 virCaps: conf: start splitting out irrelevat data
The virCaps structure gathered a ton of irrelevant data over time that.
The original reason is that it was propagated to the XML parser
functions.

This patch aims to create a new data structure virDomainXMLConf that
will contain immutable data that are used by the XML parser. This will
allow two things we need:

1) Get rid of the stuff from virCaps

2) Allow us to add callbacks to check and add driver specific stuff
after domain XML is parsed.

This first attempt removes pointers to private data allocation functions
to this new structure and update all callers and function that require
them.
2013-03-13 09:27:14 +01:00
Eric Blake
eb41338e25 tests: consistent skip messages
On RHEL 5, I noticed this test failure message:

TEST: qemumonitorjsontest
libvirt not compiled with yajl, skippingSKIP: qemumonitorjsontest

* tests/virstoragetest.c (testPrepImages): Use simpler fputs.
* tests/qemumonitorjsontest.c (mymain): Ensure trailing newline.
2013-02-26 10:06:25 -07:00
Eric Blake
dce95297e3 tests: uniformly report test failures
testutils.c likes to print summaries after a test completes,
including if it failed.  But if the test outright exit()s,
this summary is skipped.  Enforce that we return instead of exit.

* cfg.mk (sc_prohibit_exit_in_tests): New syntax check.
* tests/commandhelper.c (main): Fix offenders.
* tests/qemumonitorjsontest.c (mymain): Likewise.
* tests/seclabeltest.c (main): Likewise.
* tests/securityselinuxlabeltest.c (mymain): Likewise.
* tests/securityselinuxtest.c (mymain): Likewise.
* tests/testutils.h (VIRT_TEST_MAIN_PRELOAD): Likewise.
* tests/testutils.c (virtTestMain): Likewise.
(virtTestCaptureProgramOutput): Use symbolic name.
2013-02-25 17:38:11 -07:00
Eric Blake
f20b047691 tests: don't test json when not compiled in
Now that the segfault is solved, we can skip instead of fail
the test when yajl is not present.

* tests/qemumonitorjsontest.c (mymain): Skip if no yajl.
2013-02-25 17:38:05 -07:00
Daniel P. Berrange
fed92f08db Turn virCapabilities into a virObject
To enable virCapabilities instances to be reference counted,
turn it into a virObject. All cases of virCapabilitiesFree
turn into virObjectUnref

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-02-08 11:34:26 +00:00
John Ferlan
3f5250ff8e qemumonitorjsontest: Resolve resource leaks found by Valgrind
The 'package' string returned by qemuMonitorGetVersion() needs to
be VIR_FREE()'d.

testQemuMonitorJSONGetMachines(), testQemuMonitorJSONGetCPUDefinitions(),
and testQemuMonitorJSONGetCommands() did not VIR_FREE() the array and
array elements allocated by their respective qemuMonitorGet* routines.
2013-02-07 14:08:14 -05:00
Daniel P. Berrange
f24404a324 Rename virterror.c virterror_internal.h to virerror.{c,h} 2012-12-21 11:19:50 +00:00
Daniel P. Berrange
404174cad3 Rename threads.{c,h} to virthread.{c,h} 2012-12-21 11:19:49 +00:00
Daniel P. Berrange
c70a6154b6 Add a qemuMonitorGetCommands() method for QMP query-commands command
Add a new qemuMonitorGetCPUCommands() method to support invocation
of the 'query-commands' JSON monitor command. No HMP equivalent
is required, since this will only be used when JSON is available

The existing qemuMonitorJSONCheckCommands() method is refactored
to use this new method

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-27 11:04:32 +01:00
Daniel P. Berrange
2ecec6e206 Add a qemuMonitorGetCPUDefinitions method for QMP query-cpu-definitions command
Add a new qemuMonitorGetCPUDefinitions() method to support invocation
of the 'query-cpu-definitions' JSON monitor command. No HMP equivalent
is required, since this will only be present for QEMU >= 1.2

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-27 10:53:24 +01:00
Daniel P. Berrange
3999372182 Add a qemuMonitorGetMachines() method for QMP query-machines command
Add a new qemuMonitorGetMachines() method to support invocation
of the 'query-machines' JSON monitor command. No HMP equivalent
is required, since this will only be present for QEMU >= 1.2

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-09-27 10:47:16 +01:00