summaryrefslogtreecommitdiff
path: root/tests/virtio-9p-test.c
AgeCommit message (Collapse)AuthorFilesLines
2018-02-14libqos: Use explicit QTestState for remaining libqos operationsEric Blake1-0/+1
Drop one more client of global_qtest by teaching all remaining libqos stragglers to pass in an explicit QTestState. Change the setting of global_qtest from being implicit in libqos' call to qtest_start() to instead be explicit in all clients that are still relying on global_qtest. Note that qmp_execute() can be greatly simplified in the process, and that we also get rid of interpolation of a JSON string into a temporary variable when qtest_qmp() can do it more reliably. Signed-off-by: Eric Blake <eblake@redhat.com> Acked-by: Greg Kurz <groug@kaod.org> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2018-02-02tests/virtio-9p: explicitly handle potential integer overflowsGreg Kurz1-10/+21
Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-02-02tests: virtio-9p: add FLUSH operation testGreg Kurz1-13/+104
The idea is to send a victim request that will possibly block in the server and to send a flush request to cancel the victim request. This patch adds two test to verifiy that: - the server does not reply to a victim request that was actually cancelled - the server replies to the flush request after replying to the victim request if it could not cancel it 9p request cancellation reference: http://man.cat-v.org/plan_9/5/flush Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> (groug, change the test to only write a single byte to avoid any alignment or endianess consideration)
2018-02-02libqos/virtio: return length written into used descriptorGreg Kurz1-1/+1
When a 9p request is flushed (ie, cancelled) by the guest, the device is expected to simply mark the request as used, without sending a 9p reply (ie, without writing anything into the used buffer). To be able to test this, we need access to the length written by the device into the used descriptor. This patch adds a uint32_t * argument to qvirtqueue_get_buf() and qvirtio_wait_used_elem() for this purpose. All existing users are updated accordingly. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-02-01tests: virtio-9p: add WRITE operation testGreg Kurz1-0/+63
Trivial test of a successful write. Signed-off-by: Greg Kurz <groug@kaod.org> (groug, handle potential overflow when computing request size, add missing g_free(buf), backend handles one written byte at a time to validate the server doesn't do short-reads) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-02-01tests: virtio-9p: add LOPEN operation testGreg Kurz1-0/+47
Trivial test of a successful open. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-02-01tests: virtio-9p: use the synth backendGreg Kurz1-16/+6
The purpose of virtio-9p-test is to test the virtio-9p device, especially the 9p server state machine. We don't really care what fsdev backend we're using. Moreover, if we want to be able to test the flush request or a device reset with in-flights I/O, it is close to impossible to achieve with a physical backend because we cannot ask it reliably to put an I/O on hold at a specific point in time. Fortunately, we can do that with the synthetic backend, which allows to register callbacks on read/write accesses to a specific file. This will be used by a later patch to test the 9P flush request. The walk request test is converted to using the synth backend. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-02-01tests: virtio-9p: wait for completion in the test codeGreg Kurz1-2/+12
In order to test request cancellation, we will need to send multiple requests and wait for the associated replies. Since we poll the ISR to know if a request completed, we may have several replies to parse when we detect ISR was set to 1. This patch moves the waiting out of the reply parsing path, up into the functional tests. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-02-01tests: virtio-9p: move request tag to the test functionsGreg Kurz1-14/+14
It doesn't really makes sense to hide the request tag from the test functions. It prevents to test the 9p server behavior when passed a wrong tag (ie, still in use or different from P9_NOTAG for a version request). Also the spec says that a tag is reusable as soon as the corresponding request was replied or flushed: no need to always increment tags like we do now. And finaly, an upcoming test of the flush command will need to manipulate tags explicitely. This simply changes all request functions to have a tag argument. Except for the version request which needs P9_NOTAG, all other tests can pass 0 since they wait for the reply before sending another request. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-01-08tests: virtio-9p: set DRIVER_OK before using the deviceGreg Kurz1-0/+3
Signed-off-by: Greg Kurz <groug@kaod.org>
2018-01-08tests: virtio-9p: fix ISR dependenceGreg Kurz1-19/+11
Like other virtio tests, use the used ring APIs instead of assuming ISR being set means the request has completed. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2017-03-27tests/virtio-9p-test: Don't call le*_to_cpus on fields of packed structPeter Maydell1-2/+2
For a packed struct like 'P9Hdr' the fields within it may not be aligned as much as the natural alignment for their types. This means it is not valid to pass the address of such a field to a function like le32_to_cpus() which operate on uint32_t* and assume alignment. Doing this results in a SIGBUS on hosts like SPARC which have strict alignment requirements. Use ldl_le_p() instead, which is specified to correctly handle unaligned pointers. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: Greg Kurz <groug@kaod.org>
2017-03-01tests: fix virtio-9p-test leaksMarc-André Lureau1-1/+1
Spotted by ASAN. Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org>
2017-01-25tests: virtio-9p: improve error reportingGreg Kurz1-5/+19
Signed-off-by: Greg Kurz <groug@kaod.org>
2017-01-03tests: virtio-9p: ".." cannot be used to walk out of the shared directoryGreg Kurz1-0/+21
According to the 9P spec at http://man.cat-v.org/plan_9/5/intro, the parent directory of the root directory of a server's tree is itself. This test hence checks that the qid of the root directory as returned by attach is the same as the qid of ".." when walking from the root directory. Signed-off-by: Greg Kurz <groug@kaod.org>
2017-01-03tests: virtio-9p: no slash in path elements during walkGreg Kurz1-0/+24
The walk operation is expected to fail and to return ENOENT. Signed-off-by: Greg Kurz <groug@kaod.org>
2017-01-03tests: virtio-9p: add walk operation testGreg Kurz1-0/+70
The walk operation is used to traverse the directory tree and to associate paths to fids. A single walk can be used to traverse up to P9_MAXWELEM path elements at the same time. The test creates a path with P9_MAXWELEM elements on the backend (à la 'mkdir -p') and issues a walk operation. The walk is expected to succeed without error. Reference: http://man.cat-v.org/plan_9/5/walk Signed-off-by: Greg Kurz <groug@kaod.org>
2017-01-03tests: virtio-9p: add attach operation testGreg Kurz1-0/+40
The attach operation is used to establish a connection between the client and the server. After this, the client is able to access the underlying filesystem and do I/O. This test simply ensures the operation succeeds without error. Reference: http://man.cat-v.org/plan_9/5/attach Signed-off-by: Greg Kurz <groug@kaod.org>
2017-01-03tests: virtio-9p: add version operation testGreg Kurz1-0/+222
This patch lays the foundations to be able to test 9P operations and provides a test for the version operation as a first example. A 9P request is composed of a T-message sent by the client (guest) to the server (QEMU), and a R-message sent by the server back to the client. The following general calls are available to implement requests for any 9P operations: v9fs_req_init(): allocates the request structure and the guest memory for the T-message v9fs_req_send(): allocates the guest memory for the R-message and sends the T-message to QEMU v9fs_req_recv(): waits for QEMU to answer and does some sanity checks on the returned R-message header v9fs_req_free(): releases the guest memory and the request structure Helpers are provided, to be used by each specific 9P operation to copy data to/from the guest memory. The version operation is used to negotiate the 9P protocol version to be used and the maximum buffer size for exchanged data. It is necessarily the first message of a 9P session. For simplicity, the maximum buffer size is hardcoded to 4k, which should be enough for functional tests. The test simply advertises the "9P2000.L" version to QEMU and expects QEMU to answer it is supported. References: http://man.cat-v.org/plan_9/5/intro http://man.cat-v.org/plan_9/5/version Signed-off-by: Greg Kurz <groug@kaod.org>
2017-01-03tests: virtio-9p: code refactoringGreg Kurz1-51/+50
This moves the test_share static and the QOSState into the QVirtIO9P structure, and put PCI related code in functions with a _pci_ name. This will avoid code duplication in future tests, and allow to add support for non-PCI platforms. Signed-off-by: Greg Kurz <groug@kaod.org>
2017-01-03tests: virtio-9p: rename PCI configuration testGreg Kurz1-2/+2
Signed-off-by: Greg Kurz <groug@kaod.org>
2016-10-28libqos: Give qvirtio_config_read*() consistent semanticsDavid Gibson1-6/+2
The 'addr' parameter to qvirtio_config_read*() doesn't have a consistent meaning: when using the virtio-pci versions, it's a full PCI space address, but for virtio-mmio, it's an offset from the device's base mmio address. This means that the callers need to do different things to calculate the addresses in the two cases, which rather defeats the purpose of function pointer backends. All the current users of these functions are using them to retrieve variables from the device specific portion of the virtio config space. So, this patch alters the semantics to always be an offset into that device specific config area. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org>
2016-10-28tests: enable virtio tests on SPAPRLaurent Vivier1-1/+11
but disable MSI-X tests on SPAPR as we can't check the result (the memory region used on PC is not readable on SPAPR). Signed-off-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-28tests: use qtest_pc_boot()/qtest_shutdown() in virtio testsLaurent Vivier1-28/+22
This patch replaces calls to qtest_start() and qtest_end() by calls to qtest_pc_boot() and qtest_shutdown(). This allows to initialize memory allocator and PCI interface functions. This will ease to enable virtio tests on other architectures by only adding a specific qtest_XXX_boot() (like qtest_spapr_boot()). Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-28tests: move QVirtioBus pointer into QVirtioDeviceLaurent Vivier1-8/+7
This allows to not have to pass bus and device for every virtio functions. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> Reviewed-by: Thomas Huth <thuth@redhat.com> [dwg: Fix style nit] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-06libqos: add PCI management in qtest_vboot()/qtest_shutdown()Laurent Vivier1-1/+1
Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-09-16tests: virtio-9p: add basic configuration testGreg Kurz1-0/+77
This adds PCI init code and a basic test that checks the device config matches what is passed on the command line. Signed-off-by: Greg Kurz <groug@kaod.org> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-09-16tests: virtio-9p: introduce start/stop functionsGreg Kurz1-17/+25
First step to be able to run several functional steps. Signed-off-by: Greg Kurz <groug@kaod.org> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-06-07tests: Remove unnecessary glib.h includesPeter Maydell1-1/+0
Remove glib.h includes, as it is provided by osdep.h. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2016-01-299pfs: Clean up includesPeter Maydell1-3/+1
Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1453832250-766-18-git-send-email-peter.maydell@linaro.org
2014-03-31tests: Add virtio-9p qtestAndreas Färber1-0/+46
Make it conditional to 9p availability. Create a temporary directory to share. Signed-off-by: Andreas Färber <afaerber@suse.de>