aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-01-08 22:14:24 +0000
committerPeter Maydell <peter.maydell@linaro.org>2018-01-08 22:14:24 +0000
commitee98a6b089d363ddcd006d3d179afad220b09cac (patch)
treea839fcdee8896943d243fc62860e54e8acd538ac /tests
parent232e5537e476c463f5e6e2e9ae31f6e2da9ebfe9 (diff)
parentffcfb446db1776198a3fe02b75bfecfa1d0b7ab3 (diff)
downloadqemu-ee98a6b089d363ddcd006d3d179afad220b09cac.zip
qemu-ee98a6b089d363ddcd006d3d179afad220b09cac.tar.gz
qemu-ee98a6b089d363ddcd006d3d179afad220b09cac.tar.bz2
Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging
- Aneesh no longer listed in MAINTAINERS, - deprecation of the handle backend, - improved error reporting, especially when the local backend fails to open the VirtFS root, - virtio-9p-test to behave more like a real virtio guest driver: set DRIVER_OK when ready to use the device and process the used ring for completed requests, - cosmetic fixes (mostly coding style related). # gpg: Signature made Mon 08 Jan 2018 10:19:18 GMT # gpg: using RSA key 0x71D4D5E5822F73D6 # gpg: Good signature from "Greg Kurz <groug@kaod.org>" # gpg: aka "Gregory Kurz <gregory.kurz@free.fr>" # gpg: aka "[jpeg image of size 3330]" # Primary key fingerprint: B482 8BAF 9431 40CE F2A3 4910 71D4 D5E5 822F 73D6 * remotes/gkurz/tags/for-upstream: MAINTAINERS: Drop Aneesh as 9pfs maintainer 9pfs: deprecate handle backend fsdev: improve error handling of backend init fsdev: improve error handling of backend opts parsing tests: virtio-9p: set DRIVER_OK before using the device tests: virtio-9p: fix ISR dependence 9pfs: make pdu_marshal() and pdu_unmarshal() static functions 9pfs: fix error path in pdu_submit() 9pfs: fix type in *_parse_opts declarations 9pfs: handle: fix type definition 9pfs: fix some type definitions fsdev: fix some type definitions 9pfs: fix XattrOperations typedef virtio-9p: move unrealize/realize after virtio_9p_transport definition Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/virtio-9p-test.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index ad33d96..00f00f7 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -18,6 +18,8 @@
#include "standard-headers/linux/virtio_pci.h"
#include "hw/9pfs/9p.h"
+#define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000)
+
static const char mount_tag[] = "qtest";
typedef struct {
@@ -73,6 +75,9 @@ static QVirtIO9P *qvirtio_9p_pci_start(void)
qvirtio_set_driver(v9p->dev);
v9p->vq = qvirtqueue_setup(v9p->dev, v9p->qs->alloc, 0);
+
+ qvirtio_set_driver_ok(v9p->dev);
+
return v9p;
}
@@ -111,6 +116,7 @@ typedef struct {
/* No r_size, it is hardcoded to P9_MAX_SIZE */
size_t t_off;
size_t r_off;
+ uint32_t free_head;
} P9Req;
static void v9fs_memwrite(P9Req *req, const void *addr, size_t len)
@@ -124,11 +130,6 @@ static void v9fs_memskip(P9Req *req, size_t len)
req->r_off += len;
}
-static void v9fs_memrewind(P9Req *req, size_t len)
-{
- req->r_off -= len;
-}
-
static void v9fs_memread(P9Req *req, void *addr, size_t len)
{
memread(req->r_msg + req->r_off, addr, len);
@@ -227,12 +228,12 @@ static P9Req *v9fs_req_init(QVirtIO9P *v9p, uint32_t size, uint8_t id,
static void v9fs_req_send(P9Req *req)
{
QVirtIO9P *v9p = req->v9p;
- uint32_t free_head;
req->r_msg = guest_alloc(v9p->qs->alloc, P9_MAX_SIZE);
- free_head = qvirtqueue_add(v9p->vq, req->t_msg, req->t_size, false, true);
+ req->free_head = qvirtqueue_add(v9p->vq, req->t_msg, req->t_size, false,
+ true);
qvirtqueue_add(v9p->vq, req->r_msg, P9_MAX_SIZE, true, false);
- qvirtqueue_kick(v9p->dev, v9p->vq, free_head);
+ qvirtqueue_kick(v9p->dev, v9p->vq, req->free_head);
req->t_off = 0;
}
@@ -250,19 +251,13 @@ static void v9fs_req_recv(P9Req *req, uint8_t id)
{
QVirtIO9P *v9p = req->v9p;
P9Hdr hdr;
- int i;
- for (i = 0; i < 10; i++) {
- qvirtio_wait_queue_isr(v9p->dev, v9p->vq, 1000 * 1000);
+ qvirtio_wait_used_elem(v9p->dev, v9p->vq, req->free_head,
+ QVIRTIO_9P_TIMEOUT_US);
- v9fs_memread(req, &hdr, 7);
- hdr.size = ldl_le_p(&hdr.size);
- hdr.tag = lduw_le_p(&hdr.tag);
- if (hdr.size >= 7) {
- break;
- }
- v9fs_memrewind(req, 7);
- }
+ v9fs_memread(req, &hdr, 7);
+ hdr.size = ldl_le_p(&hdr.size);
+ hdr.tag = lduw_le_p(&hdr.tag);
g_assert_cmpint(hdr.size, >=, 7);
g_assert_cmpint(hdr.size, <=, P9_MAX_SIZE);