tests: virtio-9p: add version operation test
commit6cc9906b4c4a659841485ac483f608dea31dfa63
authorGreg Kurz <groug@kaod.org>
Tue, 3 Jan 2017 16:28:44 +0000 (3 17:28 +0100)
committerGreg Kurz <groug@kaod.org>
Tue, 3 Jan 2017 16:28:44 +0000 (3 17:28 +0100)
tree2cc8d633236e2ee473434f8a28ffdcb64a0baf2d
parentbaecbde6d75076c6631a58475866b2330391b819
tests: virtio-9p: add version operation test

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>
tests/virtio-9p-test.c