summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tests: fix cdrom_pio_impl in ide-testPeter Lieven2015-11-201-8/+8
| | | | | | | | | | | | | | | | | | The check for the cleared BSY flag has to be performed before each data transfer and not just before the first one. Commit 5f81724d revealed this glitch as the BSY flag was not set in ATAPI PIO transfers before. While at it fix the descriptions and add a comment before the nested for loop that transfers the data. Signed-off-by: Peter Lieven <pl@kamp.de> Message-id: 1448029742-19771-1-git-send-email-pl@kamp.de Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' ↵Peter Maydell2015-11-191-0/+205
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into staging QOM infrastructure fixes and device conversions * Fix for properties on objects > 4 GiB * Performance improvements for QOM property handling * Assertion cleanups * MAINTAINERS additions # gpg: Signature made Thu 19 Nov 2015 14:32:16 GMT using RSA key ID 3E7E013F # gpg: Good signature from "Andreas Färber <afaerber@suse.de>" # gpg: aka "Andreas Färber <afaerber@suse.com>" * remotes/afaerber/tags/qom-devices-for-peter: MAINTAINERS: Add check-qom-{interface,proplist} to QOM qom: Clean up assertions to display values on failure qom: Replace object property list with GHashTable qom: Add a test case for complex property finalization net: Convert net filter code to use object property iterators ppc: Convert spapr code to use object property iterators vl: Convert machine help code to use object property iterators qmp: Convert QMP code to use object property iterators qom: Introduce ObjectPropertyIterator struct for iteration qdev: Change Property::offset field to ptrdiff_t type Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * qom: Add a test case for complex property finalizationDaniel P. Berrange2015-11-181-0/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Devices have some quite complex object child/link relationships which place some requirements on the object_property_del_all() function to consider that properties can be modified while being iterated over. This extends the QOM property test case to replicate the device like structure and expose any potential bugs in the object_property_del_all() function. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
| * qom: Introduce ObjectPropertyIterator struct for iterationDaniel P. Berrange2015-11-181-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some users of QOM need to be able to iterate over properties defined against an object instance. Currently they are just directly using the QTAIL macros against the object properties data structure. This is bad because it exposes them to changes in the data structure used to store properties, as well as changes in functionality such as ability to register properties against the class. This provides an ObjectPropertyIterator struct which will insulate the callers from the particular data structure used to store properties. It can be used thus ObjectProperty *prop; ObjectPropertyIterator *iter; iter = object_property_iter_init(obj); while ((prop = object_property_iter_next(iter))) { ... do something with prop ... } object_property_iter_free(iter); Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Tested-by: Pavel Fedin <p.fedin@samsung.com> [AF: Fixed examples, style cleanups] Signed-off-by: Andreas Färber <afaerber@suse.de>
* | Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into stagingPeter Maydell2015-11-193-29/+203
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vhost, pc: fixes for 2.5 Fixes all over the place. This also re-enables a test we disabled in 2.5 cycle now that there's a way not to get a warning from it. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Thu 19 Nov 2015 13:27:43 GMT using RSA key ID D28D5469 # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" # gpg: aka "Michael S. Tsirkin <mst@redhat.com>" * remotes/mst/tags/for_upstream: exec: silence hugetlbfs warning under qtest tests: re-enable vhost-user-test acpi: fix buffer overrun on migration vhost-user: fix log size vhost-user: ignore qemu-only features specs/vhost-user: fix spec to match reality tests/vhost-user-bridge: implement logging of dirty pages i440fx: print an error message if user tries to enable iommu q35: Check propery to determine if iommu is set vhost-user: start/stop all rings vhost-user: print original request on error vhost-user-test: support VHOST_USER_SET_VRING_ENABLE vhost-user: update spec description vhost: don't send RESET_OWNER at stop vhost: let SET_VRING_ENABLE message depends on protocol feature Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * | tests: re-enable vhost-user-testMarc-André Lureau2015-11-191-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 7fe34ca9c2e actually disabled vhost-user-test altogether, since CONFIG_VHOST_NET is a per-target config variable. tests/vhost-user-test is already x86/x64 softmmu specific test, in order to enable it correctly, kvm & vhost-net are also conditions. To check that, set CONFIG_VHOST_NET_TEST_$target when kvm is also enabled. Since "check-qtest-x86_64-y = $(check-qtest-i386-y)", avoid duplication when both x86 & x64 are enabled. Other targets than x86 aren't enabled yet, and is intentionally left as a future improvement, since I can't easily test those. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * | tests/vhost-user-bridge: implement logging of dirty pagesVictor Kaplansky2015-11-171-25/+195
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During migration devices continue writing to the guest's memory. The writes has to be reported to QEMU. This change implements minimal support in vhost-user-bridge required for successful migration of a guest with virtio-net device. Signed-off-by: Victor Kaplansky <victork@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
| * | vhost-user-test: support VHOST_USER_SET_VRING_ENABLEMichael S. Tsirkin2015-11-161-2/+5
| |/ | | | | | | | | | | | | | | vhost-user-test is broken now: it assumes QEMU sends RESET_OWNER, and we stopped doing that. Wait for ENABLE_RING with 0 instead. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into stagingPeter Maydell2015-11-181-1/+4
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Block layer patches # gpg: Signature made Wed 18 Nov 2015 15:28:32 GMT using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: block: Call external_snapshot_clean after blockdev-snapshot blockdev: Add missing bdrv_unref() in drive-backup iotests: fix race in 030 nand: fix address overflow Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * | iotests: fix race in 030John Snow2015-11-181-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the stop_test case tests that we can resume a block-stream command after it has stopped/paused due to error. We cannot always reliably query it before it finishes after resume, though, so make this a conditional. The important thing is that we are still testing that it has stopped, and that it finishes successfully after we send a resume command. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* | | crypto: fix leaks in TLS x509 helper functionsDaniel P. Berrange2015-11-181-0/+2
|/ / | | | | | | | | | | | | | | | | | | The test_tls_get_ipaddr() method forgot to free the returned data from getaddrinfo(). The test_tls_write_cert_chain() method forgot to free the allocated buffer holding the certificate data after writing it out to a file. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* | block: make 'stats-interval' an array of ints instead of a stringAlberto Garcia2015-11-171-1/+1
| | | | | | | | | | | | | | | | | | This is the natural JSON representation and prevents us from having to decode the list manually. Signed-off-by: Alberto Garcia <berto@igalia.com> Message-id: 0e3da8fa206f4ab534ae3ce6086e75fe84f1557e.1447665472.git.berto@igalia.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* | tests: Ignore recent test binariesEric Blake2015-11-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | Commits 6c6f312d and bd797fc1 added new tests (test-blockjob-txn and test-timed-average, respectively), but did not mark them for exclusion in .gitignore. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 1447386423-13160-1-git-send-email-eblake@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* | qtest/ahci: use raw format when qemu-img is absentJohn Snow2015-11-131-9/+32
| | | | | | | | | | | | | | | | If we don't have the qemu-img tool, use the raw format for tests and skip the high-sector LBA48 tests. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1447439479-16775-4-git-send-email-jsnow@redhat.com
* | libqos: add qemu-img presence checkJohn Snow2015-11-132-5/+24
| | | | | | | | | | | | | | | | | | To allow tests to optionally exercise additional tests that require the qemu-img tool that may not be present in all builds. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1447439479-16775-3-git-send-email-jsnow@redhat.com
* | qtest/ahci: always specify image formatJohn Snow2015-11-131-22/+29
| | | | | | | | | | Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1447439479-16775-2-git-send-email-jsnow@redhat.com
* | ahci/qtest: don't use tcp sockets for migration testsJohn Snow2015-11-131-5/+20
|/ | | | | Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1447108074-20609-1-git-send-email-jsnow@redhat.com
* Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into stagingPeter Maydell2015-11-128-3/+885
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Block layer patches (rebased Stefan's pull request) # gpg: Signature made Thu 12 Nov 2015 15:34:16 GMT using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (43 commits) block: Update copyright of the accounting code scsi-disk: Account for failed operations macio: Account for failed operations ide: Account for failed and invalid operations atapi: Account for failed and invalid operations xen_disk: Account for failed and invalid operations virtio-blk: Account for failed and invalid operations nvme: Account for failed and invalid operations iotests: Add test for the block device statistics block: Use QEMU_CLOCK_VIRTUAL for the accounting code in qtest mode qemu-io: Account for failed, invalid and flush operations block: New option to define the intervals for collecting I/O statistics block: Add average I/O queue depth to BlockDeviceTimedStats block: Compute minimum, maximum and average I/O latencies block: Allow configuring whether to account failed and invalid ops block: Add statistics for failed and invalid I/O operations block: Add idle_time_ns to BlockDeviceStats util: Infrastructure for computing recent averages block: define 'clock_type' for the accounting code ide: Account for write operations correctly ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * iotests: Add test for the block device statisticsAlberto Garcia2015-11-123-0/+355
| | | | | | | | | | | | | | Signed-off-by: Alberto Garcia <berto@igalia.com> Message-id: 0fb8501bbf3666b3d5d3f67fa899729c88f21baf.1446044838.git.berto@igalia.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * util: Infrastructure for computing recent averagesAlberto Garcia2015-11-122-0/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This module computes the average of a set of values within a time window, keeping also track of the minimum and maximum values. In order to produce more accurate results it works internally by creating two time windows of the same period, offsetted by half of that period. Values are accounted on both windows and the data is always returned from the oldest one. [Add missing util/replay.o to test-timed-average dependencies to fix the build. --Stefan] Signed-off-by: Alberto Garcia <berto@igalia.com> Message-id: 201b09c21bbc9c329779d2b2365ee2b9c80dceeb.1446044837.git.berto@igalia.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * tests: add BlockJobTxn unit testStefan Hajnoczi2015-11-122-0/+253
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BlockJobTxn unit test verifies that both single jobs and pairs of jobs behave as a transaction group. Either all jobs complete successfully or the group is cancelled. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1446765200-3054-15-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * iotests: 124 - transactional failure testJohn Snow2015-11-122-4/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use a transaction to request an incremental backup across two drives. Coerce one of the jobs to fail, and then re-run the transaction. Verify that no bitmap data was lost due to the partial transaction failure. To support the 'err-cancel' QMP argument name it's necessary for transaction_action() to convert underscores in Python argument names to hyphens for QMP argument names. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Message-id: 1446765200-3054-14-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * iotests: add transactional incremental backup testJohn Snow2015-11-122-2/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Test simple usage cases for using transactions to create and synchronize incremental backups. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Message-id: 1446765200-3054-3-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* | vhost: rename RESET_DEVICE backto RESET_OWNERYuanhan Liu2015-11-122-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch basically reverts commit d1f8b30e. It turned out that it breaks stuff, so revert it: http://lists.nongnu.org/archive/html/qemu-devel/2015-10/msg00949.html CC: "Michael S. Tsirkin" <mst@redhat.com> Reported-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* | vhost-user: modify SET_LOG_BASE to pass mmap size and offsetVictor Kaplansky2015-11-121-0/+8
|/ | | | | | | | | | | | Unlike the kernel, vhost-user application accesses log table by mmaping it to its user space. This change adds two new fields to VhostUserMsg payload: mmap_size, and mmap_offset and make QEMU to pass the to vhost-user application in VHOST_USER_SET_LOG_BASE request. Signed-off-by: Victor Kaplansky <victork@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* tests: classify some ivshmem tests as slowMarc-André Lureau2015-11-121-2/+4
| | | | | | | | | | | | | Some tests may take long to run, move them under g_test_slow() condition. The 5s timeout for the "server" test will have to be adjusted to the worst known time (for the records, it takes ~0.2s on my host). The "pair" test takes ~1.7, a quickest version could be implemented. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 1447326618-11686-1-git-send-email-marcandre.lureau@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* iotests: Check for quorum support in test 139Alberto Garcia2015-11-111-0/+2
| | | | | | | | | | | The quorum driver is always built in, but it is disabled during run-time if there's no SHA256 support available (see commit e94867e). This patch skips the quorum test in iotest 139 in that case. Signed-off-by: Alberto Garcia <berto@igalia.com> Message-id: 1447172891-20410-1-git-send-email-berto@igalia.com Signed-off-by: Max Reitz <mreitz@redhat.com>
* iotests: Add tests for the x-blockdev-del commandAlberto Garcia2015-11-113-0/+420
| | | | | | | Signed-off-by: Alberto Garcia <berto@igalia.com> Message-id: 57c3b0d4d0c73ddadd19e5bded9492c359cc4568.1446475331.git.berto@igalia.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* qemu-iotests: fix -valgrind option for checkJeff Cody2015-11-116-26/+59
| | | | | | | | | | | | | | | | | | | Commit 934659c switched the iotests to run qemu-io from a bash subshell, in order to catch segfaults. This method is incompatible with the current valgrind_qemu_io() bash function. Move the valgrind usage into the exec subshell in _qemu_io_wrapper(), while making sure the original return value is passed back to the caller. Update test output for tests 039, 061, and 137 as it looks for the specific subshell command when the process is terminated. Reported-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Message-id: 0066fd85d26ca641a1c25135ff2479b7985701cf.1446232490.git.jcody@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
* qemu-iotests: fix cleanup of background processesJeff Cody2015-11-114-15/+37
| | | | | | | | | | | | | | | | | | | | | Commit 934659c switched the iotests to run qemu and qemu-nbd from a bash subshell, in order to catch segfaults. Unfortunately, this means the process PID cannot be captured via '$!'. We stopped killing qemu and qemu-nbd processes, leaving a lot of orphaned, running qemu processes after executing iotests. Since the process is using exec in the subshell, the PID is the same as the subshell PID. Track these PIDs for cleanup using pidfiles in the $TEST_DIR. Only track the qemu PID, however, if requested - not all usage requires killing the process. Reported-by: John Snow <jsnow@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Message-id: 9e4f958b3895b7259b98d845bb46f000ba362869.1446232490.git.jcody@redhat.com [mreitz@redhat.com: Replaced '! -z "..."' by '-n "..."'] Signed-off-by: Max Reitz <mreitz@redhat.com>
* block: test 'blockdev-snapshot' using a file BDS as the overlayAlberto Garcia2015-11-112-1/+15
| | | | | | | | | This test checks that it is not possible to create a snapshot if the requested overlay node is a BDS which does not support backing images. Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Remove inner quotation marks in iotest 085Alberto Garcia2015-11-111-8/+8
| | | | | | | | | | This patch removes the inner quotation marks in all cases like this: cmd=" ... "${variable}" ... " Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-iotests: Test the reopening of overlay_bs in 'block-commit'Alberto Garcia2015-11-112-2/+32
| | | | | | | | | | | | | The 'block-commit' command needs the overlay image of 'top' to be opened in read-write mode in order to update the backing file string. If 'top' is not the active layer or its backing file then its overlay needs to be reopened during the block job. This is a test case for that scenario. Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: add tests for the 'blockdev-snapshot' commandAlberto Garcia2015-11-112-8/+128
| | | | | | | Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* iotests: Add test for change-related QMP commandsMax Reitz2015-11-113-0/+726
| | | | | Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qapi: More tests of input arraysEric Blake2015-11-101-0/+52
| | | | | | | | | | | | | | | | | | Our testsuite had no coverage of empty arrays, nor of what happens when the input does not match the expected type. Useful to have, especially if we start changing the visitor contracts. I did not think it worth duplicating these additions to test-qmp-input-strict; since all strict mode does is add the ability to reject JSON input that has more keys than what the visitor expects, yet the additions in this patch error out earlier than that point regardless of whether strict mode was requested. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1446791754-23823-11-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: Test failure in middle of array parseEric Blake2015-11-101-1/+9
| | | | | | | | | | | | | | | | | | Our generated list visitors have the same problem as has been mentioned elsewhere (see commit 2f52e20): they allocate data even on failure. An upcoming patch will correct things to provide saner guarantees, but first we need to expose the behavior in the testsuite to ensure we aren't introducing any memory usage bugs. There are more test cases throughout the test-qmp-input-* tests that already deal with partial allocation; a later commit will clean up all visit_type_FOO(), without marking all of the tests with FIXME at this time. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1446791754-23823-10-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: More tests of alternate outputEric Blake2015-11-101-1/+15
| | | | | | | | | | | | | | The testsuite was only covering that we could output the 'int' branch of an alternate (no additional allocation/cleanup required). Add a test of the 'str' branch, to make sure that things still work even when a branch involves allocation. Update to modern style of g_new0() over g_malloc0() while touching it. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1446791754-23823-9-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: Simplify error cleanup in test-qmp-*Eric Blake2015-11-103-35/+15
| | | | | | | | | | | | | | | | | | | | We have several tests that perform multiple sub-actions that are expected to fail. Asserting that an error occurred, then clearing it up to prepare for the next action, turned into enough boilerplate that it was sometimes forgotten (for example, a number of tests added to test-qmp-input-visitor.c in d88f5fd leaked err). Worse, if an error is not reset to NULL, we risk invalidating later use of that error (passing a non-NULL err into a function is generally a bad idea). Encapsulate the boilerplate into a single helper function error_free_or_abort(), and consistently use it. The new function is added into error.c for use everywhere, although it is anticipated that testsuites will be the main client. Signed-off-by: Eric Blake <eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: Simplify non-error testing in test-qmp-*Eric Blake2015-11-094-135/+53
| | | | | | | | | | | | | | | | | | | By using &error_abort, we can avoid a local err variable in situations where we expect success. It also has the nice effect that if the test breaks, the error message from error_abort tends to be nicer than that of g_assert(). This patch has an additional bonus of fixing several call sites that were passing &err to two different functions without checking it in between. In general that is unsafe practice; because if the first function sets an error, the second function could abort() if it tries to set a different error. We got away with it because we were asserting that err was NULL through the entire chain, but switching to &error_abort avoids the questionable practice up front. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1446791754-23823-7-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: Plug leaks in test-qmp-*Eric Blake2015-11-093-35/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make valgrind happy with the current state of the tests, so that it is easier to see if future patches introduce new memory problems without being drowned in noise. Many of the leaks were due to calling a second init without tearing down the data from an earlier visit. But since teardown is already idempotent, and we already register teardown as part of input_visitor_test_add(), it is nicer to just make init() safe to call multiple times than it is to have to make all tests call teardown. Another common leak was forgetting to clean up an error object, after testing that an error was raised. Another leak was in test_visitor_in_struct_nested(), failing to clean the base member of UserDefTwo. Cleaning that up left check_and_free_str() as dead code (since using the qapi_free_* takes care of recursion, and we don't want double frees). A final leak was in test_visitor_out_any(), which was reassigning the qobj local variable to a subset of the overall structure needing freeing; it did not result in a use-after-free, but was not cleaning up all the qdict. test-qmp-event and test-qmp-commands were already clean. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1446791754-23823-6-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: Share test_init code in test-qmp-input*Eric Blake2015-11-092-51/+46
| | | | | | | | | | | | | | | | | Rather than duplicate the body of two functions just to decide between qobject_from_jsonv() and qobject_from_json(), exploit the fact that qobject_from_jsonv() intentionally takes 'va_list *' instead of the more common 'va_list', and that qobject_from_json() just calls qobject_from_jsonv(,NULL). For each file, our two existing init functions then become thin wrappers around a new internal function, and future updates to initialization don't have to be duplicated. Suggested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1446791754-23823-5-git-send-email-eblake@redhat.com> [Two old comment typos fixed] Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: Strengthen test of TestStructListEric Blake2015-11-091-11/+7
| | | | | | | | | | | | Make each list element different, to ensure that order is preserved, and use the generated free function instead of hand-rolling our own to ensure (under valgrind) that the list is properly cleaned. Suggested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1446791754-23823-3-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: Use generated TestStruct machinery in testsEric Blake2015-11-096-162/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit d88f5fd and friends first introduced the various test-qmp-* tests in 2011, with duplicated hand-rolled TestStruct machinery, to make sure the qapi visitor interface was tested. Later, commit 4f193e3 in 2013 added a .json file for further testing use by the files, but without consolidating any of the existing hand-rolled visitors. And with four copies, subtle differences have crept in, between the tests themselves (mainly whitespace differences, but also a question of whether to use NULL or "TestStruct" when calling visit_start_struct()) and from what the generator produces (the hand-rolled versions did not cater to partially-allocated objects, because they did not have a deallocation usage). Of course, just because the visitor interface is tested does not mean it is a sane interface; and future patches will be changing some of the visitor contracts. Rather than having to duplicate the cleanup work in each copy of the TestStruct visitor, and keep each hand-rolled copy in sync with what the generator supplies, we might as well just test what the generator should give us in the first place. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1446791754-23823-2-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* tests/i44fx-test: No need for zeroing memory before memsetThomas Huth2015-11-061-1/+1
| | | | | | | | | Change a g_malloc0 into g_malloc since the following memset fills the whole buffer anyway. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* tests: ignore test-qgaEric Blake2015-11-061-0/+1
| | | | | | | | Commit 62c39b30 added a new test, but did not mark it for exclusion in .gitignore. Signed-off-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* qapi: Reserve 'u' member nameEric Blake2015-11-025-0/+10
| | | | | | | | | | | | | | | | | | | | | | Now that we have separated union tag values from colliding with non-variant C names, by naming the union 'u', we should reserve this name for our use. Note that we want to forbid 'u' even in a struct with no variants, because it is possible for a future qemu release to extend QMP in a backwards-compatible manner while converting from a struct to a flat union. Fortunately, no existing clients were using this member name. If we ever find the need for QMP to have a member 'u', we could at that time relax things, perhaps by having c_name() munge the QMP member to 'q_u'. Note that we cannot forbid 'u' everywhere (by adding the rejection code to check_name()), because the existing QKeyCode enum already uses it; therefore we only reserve it as a struct type member name. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1445898903-12082-24-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* tests: Convert to new qapi union layoutEric Blake2015-11-023-62/+62
| | | | | | | | | | | | | | | | | We have two issues with our qapi union layout: 1) Even though the QMP wire format spells the tag 'type', the C code spells it 'kind', requiring some hacks in the generator. 2) The C struct uses an anonymous union, which places all tag values in the same namespace as all non-variant members. This leads to spurious collisions if a tag value matches a non-variant member's name. Make the conversion to the new layout for testsuite code. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1445898903-12082-15-git-send-email-eblake@redhat.com> [Commit message tweaked slightly] Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: Unbox base membersEric Blake2015-11-0210-50/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than storing a base class as a pointer to a box, just store the fields of that base class in the same order, so that a child struct can be directly cast to its parent. This gives less malloc overhead, less pointer dereferencing, and even less generated code. Compare to the earlier commit 1e6c1616a "qapi: Generate a nicer struct for flat unions" (although that patch had fewer places to change, as less of qemu was directly using qapi structs for flat unions). It also allows us to turn on automatic type-safe wrappers for upcasting to the base class of a struct. Changes to the generated code look like this in qapi-types.h: | struct SpiceChannel { |- SpiceBasicInfo *base; |+ /* Members inherited from SpiceBasicInfo: */ |+ char *host; |+ char *port; |+ NetworkAddressFamily family; |+ /* Own members: */ | int64_t connection_id; as well as additional upcast functions like qapi_SpiceChannel_base(). Meanwhile, changes to qapi-visit.c look like: | static void visit_type_SpiceChannel_fields(Visitor *v, SpiceChannel **obj, Error **errp) | { | Error *err = NULL; | |- visit_type_implicit_SpiceBasicInfo(v, &(*obj)->base, &err); |+ visit_type_SpiceBasicInfo_fields(v, (SpiceBasicInfo **)obj, &err); | if (err) { (the cast is necessary, since our upcast wrappers only deal with a single pointer, not pointer-to-pointer); plus the wholesale elimination of some now-unused visit_type_implicit_FOO() functions. Without boxing, the corner case of one empty struct having another empty struct as its base type now requires inserting a dummy member (previously, the 'Base *base' member sufficed). And now that we no longer consume a 'base' member in the generated C struct, we can delete the former negative struct-base-clash-base test. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1445898903-12082-11-git-send-email-eblake@redhat.com> [Commit message tweaked slightly] Signed-off-by: Markus Armbruster <armbru@redhat.com>
* qapi: Prefer typesafe upcasts to qapi base classesEric Blake2015-11-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous patch (commit 1e6c1616) made it possible to directly cast from a qapi flat union type to its base type. However, it requires the use of a C cast, which turns off compiler type-safety checks. Fortunately, no such casts exist, just yet. Regardless, add inline type-safe wrappers named qapi_FOO_base() for any union type FOO that has a base, which can be used for a safer upcast, and enhance the testsuite to cover the new functionality. A future patch will extend the upcast support to structs, where such conversions do exist already. Note that C makes const-correct upcasts annoying because it lacks overloads; these functions cast away const so that they can accept user pointers whether const or not, and the result in turn can be assigned to normal or const pointers. Alternatively, this could have been done with macros, but type-safe macros are hairy, and not worthwhile here. This patch just adds upcasts. None of our code needed to downcast from a base qapi class to a child. Also, in the case of grandchildren (such as BlockdevOptionsQcow2), the caller will need to call two functions to get to the inner base (although it wouldn't be too hard to generate a qapi_FOO_base_base() if desired). If a user changes qapi to alter the base class hierarchy, such as going from 'A -> C' to 'A -> B -> C', it will change the type of 'qapi_C_base()', and the compiler will point out the places that are affected by the new base. One alternative was proposed, but was deemed too ugly to use in practice: the generators could output redundant information using anonymous types: | struct Child { | union { | struct { | Type1 parent_member1; | Type2 parent_member2; | }; | Parent base; | }; | }; With that ugly proposal, for a given qapi type, obj->member and obj->base.member would refer to the same storage; allowing convenience in working with members without needing 'base.' allowing typesafe upcast without needing a C cast by accessing '&obj->base', and allowing downcasts from the parent back to the child possible through container_of(obj, Child, base). Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1445898903-12082-10-git-send-email-eblake@redhat.com> [Commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
OpenPOWER on IntegriCloud