* [PULL v2 04/16] tests/9pfs: Factor out do_version() helper
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
@ 2020-10-20 16:09 ` Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 07/16] tests/9pfs: Turn fs_readdir_split() into a helper Christian Schoenebeck
` (14 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-20 16:09 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
From: Greg Kurz <groug@kaod.org>
fs_version() is a top level test function. Factor out the reusable
code to a separate helper instead of hijacking it in other tests.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <160321015403.266767.4533967728943968456.stgit@bahia.lan>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index c15908f27b..59bcea4c30 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -567,10 +567,8 @@ static void v9fs_rflush(P9Req *req)
v9fs_req_free(req);
}
-static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc)
+static void do_version(QVirtio9P *v9p)
{
- QVirtio9P *v9p = obj;
- alloc = t_alloc;
const char *version = "9P2000.L";
uint16_t server_len;
char *server_version;
@@ -585,13 +583,19 @@ static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(server_version);
}
+static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc)
+{
+ alloc = t_alloc;
+ do_version(obj);
+}
+
static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc)
{
QVirtio9P *v9p = obj;
alloc = t_alloc;
P9Req *req;
- fs_version(v9p, NULL, t_alloc);
+ do_version(v9p);
req = v9fs_tattach(v9p, 0, getuid(), 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rattach(req, NULL);
@@ -831,7 +835,7 @@ static void fs_walk_dotdot(void *obj, void *data, QGuestAllocator *t_alloc)
v9fs_qid root_qid, *wqid;
P9Req *req;
- fs_version(v9p, NULL, t_alloc);
+ do_version(v9p);
req = v9fs_tattach(v9p, 0, getuid(), 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rattach(req, &root_qid);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 07/16] tests/9pfs: Turn fs_readdir_split() into a helper
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 04/16] tests/9pfs: Factor out do_version() helper Christian Schoenebeck
@ 2020-10-20 16:09 ` Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 05/16] tests/9pfs: Set alloc in fs_create_dir() Christian Schoenebeck
` (13 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-20 16:09 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
From: Greg Kurz <groug@kaod.org>
fs_readdir_split() isn't a top level test function and thus shouldn't
take the "void *obj, void *data, QGuestAllocator *t_alloc" arguments.
Turn it into a helper to be used by test functions.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <160321016084.266767.9501523425012383531.stgit@bahia.lan>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index e07292bdb8..3c187cdc08 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -731,11 +731,8 @@ static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc)
}
/* readdir test where overall request is split over several messages */
-static void fs_readdir_split(void *obj, void *data, QGuestAllocator *t_alloc,
- uint32_t count)
+static void do_readdir_split(QVirtio9P *v9p, uint32_t count)
{
- QVirtio9P *v9p = obj;
- alloc = t_alloc;
char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_READDIR_DIR) };
uint16_t nqid;
v9fs_qid qid;
@@ -1002,19 +999,22 @@ static void fs_mkdir(void *obj, void *data, QGuestAllocator *t_alloc,
static void fs_readdir_split_128(void *obj, void *data,
QGuestAllocator *t_alloc)
{
- fs_readdir_split(obj, data, t_alloc, 128);
+ alloc = t_alloc;
+ do_readdir_split(obj, 128);
}
static void fs_readdir_split_256(void *obj, void *data,
QGuestAllocator *t_alloc)
{
- fs_readdir_split(obj, data, t_alloc, 256);
+ alloc = t_alloc;
+ do_readdir_split(obj, 256);
}
static void fs_readdir_split_512(void *obj, void *data,
QGuestAllocator *t_alloc)
{
- fs_readdir_split(obj, data, t_alloc, 512);
+ alloc = t_alloc;
+ do_readdir_split(obj, 512);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 05/16] tests/9pfs: Set alloc in fs_create_dir()
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 04/16] tests/9pfs: Factor out do_version() helper Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 07/16] tests/9pfs: Turn fs_readdir_split() into a helper Christian Schoenebeck
@ 2020-10-20 16:09 ` Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 06/16] tests/9pfs: Factor out do_attach() helper Christian Schoenebeck
` (12 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-20 16:09 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
From: Greg Kurz <groug@kaod.org>
fs_create_dir() is a top level test function. It should set alloc.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <160321016764.266767.3763279057643874020.stgit@bahia.lan>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 59bcea4c30..93a2a4cd76 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -1019,6 +1019,7 @@ static void fs_readdir_split_512(void *obj, void *data,
static void fs_create_dir(void *obj, void *data, QGuestAllocator *t_alloc)
{
QVirtio9P *v9p = obj;
+ alloc = t_alloc;
struct stat st;
char *root_path = virtio_9p_test_path("");
char *new_dir = virtio_9p_test_path("01");
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 06/16] tests/9pfs: Factor out do_attach() helper
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (2 preceding siblings ...)
2020-10-20 16:09 ` [PULL v2 05/16] tests/9pfs: Set alloc in fs_create_dir() Christian Schoenebeck
@ 2020-10-20 16:09 ` Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 08/16] tests/9pfs: Turn fs_mkdir() into a helper Christian Schoenebeck
` (11 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-20 16:09 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
From: Greg Kurz <groug@kaod.org>
fs_attach() is a top level test function. Factor out the reusable
code to a separate helper instead of hijacking it in other tests.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <160321017450.266767.17377192504263871186.stgit@bahia.lan>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 93a2a4cd76..e07292bdb8 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -589,10 +589,8 @@ static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc)
do_version(obj);
}
-static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc)
+static void do_attach(QVirtio9P *v9p)
{
- QVirtio9P *v9p = obj;
- alloc = t_alloc;
P9Req *req;
do_version(v9p);
@@ -601,6 +599,12 @@ static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc)
v9fs_rattach(req, NULL);
}
+static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc)
+{
+ alloc = t_alloc;
+ do_attach(obj);
+}
+
static void fs_walk(void *obj, void *data, QGuestAllocator *t_alloc)
{
QVirtio9P *v9p = obj;
@@ -615,7 +619,7 @@ static void fs_walk(void *obj, void *data, QGuestAllocator *t_alloc)
wnames[i] = g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i);
}
- fs_attach(v9p, NULL, t_alloc);
+ do_attach(v9p);
req = v9fs_twalk(v9p, 0, 1, P9_MAXWELEM, wnames, 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rwalk(req, &nwqid, &wqid);
@@ -684,7 +688,7 @@ static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc)
struct V9fsDirent *entries = NULL;
P9Req *req;
- fs_attach(v9p, NULL, t_alloc);
+ do_attach(v9p);
req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rwalk(req, &nqid, NULL);
@@ -741,7 +745,7 @@ static void fs_readdir_split(void *obj, void *data, QGuestAllocator *t_alloc,
int fid;
uint64_t offset;
- fs_attach(v9p, NULL, t_alloc);
+ do_attach(v9p);
fid = 1;
offset = 0;
@@ -817,7 +821,7 @@ static void fs_walk_no_slash(void *obj, void *data, QGuestAllocator *t_alloc)
P9Req *req;
uint32_t err;
- fs_attach(v9p, NULL, t_alloc);
+ do_attach(v9p);
req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rlerror(req, &err);
@@ -857,7 +861,7 @@ static void fs_lopen(void *obj, void *data, QGuestAllocator *t_alloc)
char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_LOPEN_FILE) };
P9Req *req;
- fs_attach(v9p, NULL, t_alloc);
+ do_attach(v9p);
req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rwalk(req, NULL, NULL);
@@ -879,7 +883,7 @@ static void fs_write(void *obj, void *data, QGuestAllocator *t_alloc)
uint32_t count;
P9Req *req;
- fs_attach(v9p, NULL, t_alloc);
+ do_attach(v9p);
req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rwalk(req, NULL, NULL);
@@ -906,7 +910,7 @@ static void fs_flush_success(void *obj, void *data, QGuestAllocator *t_alloc)
uint32_t reply_len;
uint8_t should_block;
- fs_attach(v9p, NULL, t_alloc);
+ do_attach(v9p);
req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rwalk(req, NULL, NULL);
@@ -943,7 +947,7 @@ static void fs_flush_ignored(void *obj, void *data, QGuestAllocator *t_alloc)
uint32_t count;
uint8_t should_block;
- fs_attach(v9p, NULL, t_alloc);
+ do_attach(v9p);
req = v9fs_twalk(v9p, 0, 1, 1, wnames, 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rwalk(req, NULL, NULL);
@@ -1026,7 +1030,7 @@ static void fs_create_dir(void *obj, void *data, QGuestAllocator *t_alloc)
g_assert(root_path != NULL);
- fs_attach(v9p, NULL, t_alloc);
+ do_attach(v9p);
fs_mkdir(v9p, data, t_alloc, "/", "01");
/* check if created directory really exists now ... */
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 08/16] tests/9pfs: Turn fs_mkdir() into a helper
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (3 preceding siblings ...)
2020-10-20 16:09 ` [PULL v2 06/16] tests/9pfs: Factor out do_attach() helper Christian Schoenebeck
@ 2020-10-20 16:09 ` Christian Schoenebeck
2020-10-21 12:06 ` [PULL v2 09/16] tests/9pfs: simplify do_mkdir() Christian Schoenebeck
` (10 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-20 16:09 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
From: Greg Kurz <groug@kaod.org>
fs_mkdir() isn't a top level test function and thus shouldn't take
the "void *obj, void *data, QGuestAllocator *t_alloc" arguments.
Turn it into a helper to be used by test functions.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <160321018148.266767.15959608711038504029.stgit@bahia.lan>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 3c187cdc08..2ea555fa04 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -972,11 +972,8 @@ static void fs_flush_ignored(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(wnames[0]);
}
-static void fs_mkdir(void *obj, void *data, QGuestAllocator *t_alloc,
- const char *path, const char *cname)
+static void do_mkdir(QVirtio9P *v9p, const char *path, const char *cname)
{
- QVirtio9P *v9p = obj;
- alloc = t_alloc;
char **wnames;
char *const name = g_strdup(cname);
P9Req *req;
@@ -1031,7 +1028,7 @@ static void fs_create_dir(void *obj, void *data, QGuestAllocator *t_alloc)
g_assert(root_path != NULL);
do_attach(v9p);
- fs_mkdir(v9p, data, t_alloc, "/", "01");
+ do_mkdir(v9p, "/", "01");
/* check if created directory really exists now ... */
g_assert(stat(new_dir, &st) == 0);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 09/16] tests/9pfs: simplify do_mkdir()
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (4 preceding siblings ...)
2020-10-20 16:09 ` [PULL v2 08/16] tests/9pfs: Turn fs_mkdir() into a helper Christian Schoenebeck
@ 2020-10-21 12:06 ` Christian Schoenebeck
2020-10-21 12:17 ` [PULL v2 10/16] tests/9pfs: add local Tunlinkat directory test Christian Schoenebeck
` (9 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-21 12:06 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
Split out walking a directory path to a separate new utility function
do_walk() and use that function in do_mkdir().
The code difference saved this way is not much, but we'll use that new
do_walk() function in the upcoming patches, so it will avoid quite
some code duplication after all.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <4d7275b2363f122438a443ce079cbb355285e9d6.1603285620.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 2ea555fa04..21807037df 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -583,6 +583,23 @@ static void do_version(QVirtio9P *v9p)
g_free(server_version);
}
+/* utility function: walk to requested dir and return fid for that dir */
+static uint32_t do_walk(QVirtio9P *v9p, const char *path)
+{
+ char **wnames;
+ P9Req *req;
+ const uint32_t fid = genfid();
+
+ int nwnames = split(path, "/", &wnames);
+
+ req = v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0);
+ v9fs_req_wait_for_reply(req, NULL);
+ v9fs_rwalk(req, NULL, NULL);
+
+ split_free(&wnames);
+ return fid;
+}
+
static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc)
{
alloc = t_alloc;
@@ -974,23 +991,17 @@ static void fs_flush_ignored(void *obj, void *data, QGuestAllocator *t_alloc)
static void do_mkdir(QVirtio9P *v9p, const char *path, const char *cname)
{
- char **wnames;
char *const name = g_strdup(cname);
+ uint32_t fid;
P9Req *req;
- const uint32_t fid = genfid();
- int nwnames = split(path, "/", &wnames);
-
- req = v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0);
- v9fs_req_wait_for_reply(req, NULL);
- v9fs_rwalk(req, NULL, NULL);
+ fid = do_walk(v9p, path);
req = v9fs_tmkdir(v9p, fid, name, 0750, 0, 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rmkdir(req, NULL);
g_free(name);
- split_free(&wnames);
}
static void fs_readdir_split_128(void *obj, void *data,
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 10/16] tests/9pfs: add local Tunlinkat directory test
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (5 preceding siblings ...)
2020-10-21 12:06 ` [PULL v2 09/16] tests/9pfs: simplify do_mkdir() Christian Schoenebeck
@ 2020-10-21 12:17 ` Christian Schoenebeck
2020-10-21 12:25 ` [PULL v2 11/16] tests/9pfs: add local Tlcreate test Christian Schoenebeck
` (8 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-21 12:17 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
This test case uses a Tunlinkat 9p request with flag AT_REMOVEDIR
(see 'man 2 unlink') to remove a directory from host's test directory.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <3c7c65b476ba44bea6afd0b378b5287e1c671a32.1603285620.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 71 ++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 21807037df..abd7e44648 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -258,6 +258,7 @@ static const char *rmessage_name(uint8_t id)
id == P9_RLOPEN ? "RLOPEN" :
id == P9_RWRITE ? "RWRITE" :
id == P9_RMKDIR ? "RMKDIR" :
+ id == P9_RUNLINKAT ? "RUNLINKAT" :
id == P9_RFLUSH ? "RFLUSH" :
id == P9_RREADDIR ? "READDIR" :
"<unknown>";
@@ -693,6 +694,33 @@ static void v9fs_rmkdir(P9Req *req, v9fs_qid *qid)
v9fs_req_free(req);
}
+/* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */
+static P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *name,
+ uint32_t flags, uint16_t tag)
+{
+ P9Req *req;
+
+ uint32_t body_size = 4 + 4;
+ uint16_t string_size = v9fs_string_size(name);
+
+ g_assert_cmpint(body_size, <=, UINT32_MAX - string_size);
+ body_size += string_size;
+
+ req = v9fs_req_init(v9p, body_size, P9_TUNLINKAT, tag);
+ v9fs_uint32_write(req, dirfd);
+ v9fs_string_write(req, name);
+ v9fs_uint32_write(req, flags);
+ v9fs_req_send(req);
+ return req;
+}
+
+/* size[4] Runlinkat tag[2] */
+static void v9fs_runlinkat(P9Req *req)
+{
+ v9fs_req_recv(req, P9_RUNLINKAT);
+ v9fs_req_free(req);
+}
+
/* basic readdir test where reply fits into a single response message */
static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc)
{
@@ -1004,6 +1032,22 @@ static void do_mkdir(QVirtio9P *v9p, const char *path, const char *cname)
g_free(name);
}
+static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rpath,
+ uint32_t flags)
+{
+ char *const name = g_strdup(rpath);
+ uint32_t fid;
+ P9Req *req;
+
+ fid = do_walk(v9p, atpath);
+
+ req = v9fs_tunlinkat(v9p, fid, name, flags, 0);
+ v9fs_req_wait_for_reply(req, NULL);
+ v9fs_runlinkat(req);
+
+ g_free(name);
+}
+
static void fs_readdir_split_128(void *obj, void *data,
QGuestAllocator *t_alloc)
{
@@ -1050,6 +1094,32 @@ static void fs_create_dir(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(root_path);
}
+static void fs_unlinkat_dir(void *obj, void *data, QGuestAllocator *t_alloc)
+{
+ QVirtio9P *v9p = obj;
+ alloc = t_alloc;
+ struct stat st;
+ char *root_path = virtio_9p_test_path("");
+ char *new_dir = virtio_9p_test_path("02");
+
+ g_assert(root_path != NULL);
+
+ do_attach(v9p);
+ do_mkdir(v9p, "/", "02");
+
+ /* check if created directory really exists now ... */
+ g_assert(stat(new_dir, &st) == 0);
+ /* ... and is actually a directory */
+ g_assert((st.st_mode & S_IFMT) == S_IFDIR);
+
+ do_unlinkat(v9p, "/", "02", AT_REMOVEDIR);
+ /* directory should be gone now */
+ g_assert(stat(new_dir, &st) != 0);
+
+ g_free(new_dir);
+ g_free(root_path);
+}
+
static void *assign_9p_local_driver(GString *cmd_line, void *arg)
{
virtio_9p_assign_local_driver(cmd_line, "security_model=mapped-xattr");
@@ -1090,6 +1160,7 @@ static void register_virtio_9p_test(void)
opts.before = assign_9p_local_driver;
qos_add_test("local/config", "virtio-9p", pci_config, &opts);
qos_add_test("local/create_dir", "virtio-9p", fs_create_dir, &opts);
+ qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts);
}
libqos_init(register_virtio_9p_test);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 11/16] tests/9pfs: add local Tlcreate test
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (6 preceding siblings ...)
2020-10-21 12:17 ` [PULL v2 10/16] tests/9pfs: add local Tunlinkat directory test Christian Schoenebeck
@ 2020-10-21 12:25 ` Christian Schoenebeck
2020-10-21 12:28 ` [PULL v2 12/16] tests/9pfs: add local Tunlinkat file test Christian Schoenebeck
` (7 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-21 12:25 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
This test case uses a Tlcreate 9p request to create a regular file inside
host's test directory.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <269cae0c00af941a3a4ae78f1e319f93462a7eb4.1603285620.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 77 ++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index abd7e44648..c030bc2a6c 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -258,6 +258,7 @@ static const char *rmessage_name(uint8_t id)
id == P9_RLOPEN ? "RLOPEN" :
id == P9_RWRITE ? "RWRITE" :
id == P9_RMKDIR ? "RMKDIR" :
+ id == P9_RLCREATE ? "RLCREATE" :
id == P9_RUNLINKAT ? "RUNLINKAT" :
id == P9_RFLUSH ? "RFLUSH" :
id == P9_RREADDIR ? "READDIR" :
@@ -694,6 +695,44 @@ static void v9fs_rmkdir(P9Req *req, v9fs_qid *qid)
v9fs_req_free(req);
}
+/* size[4] Tlcreate tag[2] fid[4] name[s] flags[4] mode[4] gid[4] */
+static P9Req *v9fs_tlcreate(QVirtio9P *v9p, uint32_t fid, const char *name,
+ uint32_t flags, uint32_t mode, uint32_t gid,
+ uint16_t tag)
+{
+ P9Req *req;
+
+ uint32_t body_size = 4 + 4 + 4 + 4;
+ uint16_t string_size = v9fs_string_size(name);
+
+ g_assert_cmpint(body_size, <=, UINT32_MAX - string_size);
+ body_size += string_size;
+
+ req = v9fs_req_init(v9p, body_size, P9_TLCREATE, tag);
+ v9fs_uint32_write(req, fid);
+ v9fs_string_write(req, name);
+ v9fs_uint32_write(req, flags);
+ v9fs_uint32_write(req, mode);
+ v9fs_uint32_write(req, gid);
+ v9fs_req_send(req);
+ return req;
+}
+
+/* size[4] Rlcreate tag[2] qid[13] iounit[4] */
+static void v9fs_rlcreate(P9Req *req, v9fs_qid *qid, uint32_t *iounit)
+{
+ v9fs_req_recv(req, P9_RLCREATE);
+ if (qid) {
+ v9fs_memread(req, qid, 13);
+ } else {
+ v9fs_memskip(req, 13);
+ }
+ if (iounit) {
+ v9fs_uint32_read(req, iounit);
+ }
+ v9fs_req_free(req);
+}
+
/* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */
static P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *name,
uint32_t flags, uint16_t tag)
@@ -1032,6 +1071,24 @@ static void do_mkdir(QVirtio9P *v9p, const char *path, const char *cname)
g_free(name);
}
+/* create a regular file with Tlcreate and return file's fid */
+static uint32_t do_lcreate(QVirtio9P *v9p, const char *path,
+ const char *cname)
+{
+ char *const name = g_strdup(cname);
+ uint32_t fid;
+ P9Req *req;
+
+ fid = do_walk(v9p, path);
+
+ req = v9fs_tlcreate(v9p, fid, name, 0, 0750, 0, 0);
+ v9fs_req_wait_for_reply(req, NULL);
+ v9fs_rlcreate(req, NULL, NULL);
+
+ g_free(name);
+ return fid;
+}
+
static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rpath,
uint32_t flags)
{
@@ -1120,6 +1177,25 @@ static void fs_unlinkat_dir(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(root_path);
}
+static void fs_create_file(void *obj, void *data, QGuestAllocator *t_alloc)
+{
+ QVirtio9P *v9p = obj;
+ alloc = t_alloc;
+ struct stat st;
+ char *new_file = virtio_9p_test_path("03/1st_file");
+
+ do_attach(v9p);
+ do_mkdir(v9p, "/", "03");
+ do_lcreate(v9p, "03", "1st_file");
+
+ /* check if created file exists now ... */
+ g_assert(stat(new_file, &st) == 0);
+ /* ... and is a regular file */
+ g_assert((st.st_mode & S_IFMT) == S_IFREG);
+
+ g_free(new_file);
+}
+
static void *assign_9p_local_driver(GString *cmd_line, void *arg)
{
virtio_9p_assign_local_driver(cmd_line, "security_model=mapped-xattr");
@@ -1161,6 +1237,7 @@ static void register_virtio_9p_test(void)
qos_add_test("local/config", "virtio-9p", pci_config, &opts);
qos_add_test("local/create_dir", "virtio-9p", fs_create_dir, &opts);
qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts);
+ qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts);
}
libqos_init(register_virtio_9p_test);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 12/16] tests/9pfs: add local Tunlinkat file test
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (7 preceding siblings ...)
2020-10-21 12:25 ` [PULL v2 11/16] tests/9pfs: add local Tlcreate test Christian Schoenebeck
@ 2020-10-21 12:28 ` Christian Schoenebeck
2020-10-21 12:33 ` [PULL v2 13/16] tests/9pfs: add local Tsymlink test Christian Schoenebeck
` (6 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-21 12:28 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
This test case uses a Tunlinkat request to remove a regular file using
the 9pfs 'local' fs driver.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <4eabeed7f662721dd5664cb77fe36ea0aa08b1ec.1603285620.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index c030bc2a6c..6b74a1fd7e 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -1196,6 +1196,29 @@ static void fs_create_file(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(new_file);
}
+static void fs_unlinkat_file(void *obj, void *data, QGuestAllocator *t_alloc)
+{
+ QVirtio9P *v9p = obj;
+ alloc = t_alloc;
+ struct stat st;
+ char *new_file = virtio_9p_test_path("04/doa_file");
+
+ do_attach(v9p);
+ do_mkdir(v9p, "/", "04");
+ do_lcreate(v9p, "04", "doa_file");
+
+ /* check if created file exists now ... */
+ g_assert(stat(new_file, &st) == 0);
+ /* ... and is a regular file */
+ g_assert((st.st_mode & S_IFMT) == S_IFREG);
+
+ do_unlinkat(v9p, "04", "doa_file", 0);
+ /* file should be gone now */
+ g_assert(stat(new_file, &st) != 0);
+
+ g_free(new_file);
+}
+
static void *assign_9p_local_driver(GString *cmd_line, void *arg)
{
virtio_9p_assign_local_driver(cmd_line, "security_model=mapped-xattr");
@@ -1238,6 +1261,7 @@ static void register_virtio_9p_test(void)
qos_add_test("local/create_dir", "virtio-9p", fs_create_dir, &opts);
qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts);
qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts);
+ qos_add_test("local/unlinkat_file", "virtio-9p", fs_unlinkat_file, &opts);
}
libqos_init(register_virtio_9p_test);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 13/16] tests/9pfs: add local Tsymlink test
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (8 preceding siblings ...)
2020-10-21 12:28 ` [PULL v2 12/16] tests/9pfs: add local Tunlinkat file test Christian Schoenebeck
@ 2020-10-21 12:33 ` Christian Schoenebeck
2020-10-21 12:36 ` [PULL v2 14/16] tests/9pfs: add local Tunlinkat symlink test Christian Schoenebeck
` (5 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-21 12:33 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
This test case uses a Tsymlink 9p request to create a symbolic link using
the 9pfs 'local' fs driver.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <84ac76937855bf441242372cc3e62df42f0a3dc4.1603285620.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 77 ++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 6b74a1fd7e..0c11417236 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -259,6 +259,7 @@ static const char *rmessage_name(uint8_t id)
id == P9_RWRITE ? "RWRITE" :
id == P9_RMKDIR ? "RMKDIR" :
id == P9_RLCREATE ? "RLCREATE" :
+ id == P9_RSYMLINK ? "RSYMLINK" :
id == P9_RUNLINKAT ? "RUNLINKAT" :
id == P9_RFLUSH ? "RFLUSH" :
id == P9_RREADDIR ? "READDIR" :
@@ -733,6 +734,39 @@ static void v9fs_rlcreate(P9Req *req, v9fs_qid *qid, uint32_t *iounit)
v9fs_req_free(req);
}
+/* size[4] Tsymlink tag[2] fid[4] name[s] symtgt[s] gid[4] */
+static P9Req *v9fs_tsymlink(QVirtio9P *v9p, uint32_t fid, const char *name,
+ const char *symtgt, uint32_t gid, uint16_t tag)
+{
+ P9Req *req;
+
+ uint32_t body_size = 4 + 4;
+ uint16_t string_size = v9fs_string_size(name) + v9fs_string_size(symtgt);
+
+ g_assert_cmpint(body_size, <=, UINT32_MAX - string_size);
+ body_size += string_size;
+
+ req = v9fs_req_init(v9p, body_size, P9_TSYMLINK, tag);
+ v9fs_uint32_write(req, fid);
+ v9fs_string_write(req, name);
+ v9fs_string_write(req, symtgt);
+ v9fs_uint32_write(req, gid);
+ v9fs_req_send(req);
+ return req;
+}
+
+/* size[4] Rsymlink tag[2] qid[13] */
+static void v9fs_rsymlink(P9Req *req, v9fs_qid *qid)
+{
+ v9fs_req_recv(req, P9_RSYMLINK);
+ if (qid) {
+ v9fs_memread(req, qid, 13);
+ } else {
+ v9fs_memskip(req, 13);
+ }
+ v9fs_req_free(req);
+}
+
/* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */
static P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *name,
uint32_t flags, uint16_t tag)
@@ -1089,6 +1123,25 @@ static uint32_t do_lcreate(QVirtio9P *v9p, const char *path,
return fid;
}
+/* create symlink named @a clink in directory @a path pointing to @a to */
+static void do_symlink(QVirtio9P *v9p, const char *path, const char *clink,
+ const char *to)
+{
+ char *const name = g_strdup(clink);
+ char *const dst = g_strdup(to);
+ uint32_t fid;
+ P9Req *req;
+
+ fid = do_walk(v9p, path);
+
+ req = v9fs_tsymlink(v9p, fid, name, dst, 0, 0);
+ v9fs_req_wait_for_reply(req, NULL);
+ v9fs_rsymlink(req, NULL);
+
+ g_free(dst);
+ g_free(name);
+}
+
static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rpath,
uint32_t flags)
{
@@ -1219,6 +1272,29 @@ static void fs_unlinkat_file(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(new_file);
}
+static void fs_symlink_file(void *obj, void *data, QGuestAllocator *t_alloc)
+{
+ QVirtio9P *v9p = obj;
+ alloc = t_alloc;
+ struct stat st;
+ char *real_file = virtio_9p_test_path("05/real_file");
+ char *symlink_file = virtio_9p_test_path("05/symlink_file");
+
+ do_attach(v9p);
+ do_mkdir(v9p, "/", "05");
+ do_lcreate(v9p, "05", "real_file");
+ g_assert(stat(real_file, &st) == 0);
+ g_assert((st.st_mode & S_IFMT) == S_IFREG);
+
+ do_symlink(v9p, "05", "symlink_file", "real_file");
+
+ /* check if created link exists now */
+ g_assert(stat(symlink_file, &st) == 0);
+
+ g_free(symlink_file);
+ g_free(real_file);
+}
+
static void *assign_9p_local_driver(GString *cmd_line, void *arg)
{
virtio_9p_assign_local_driver(cmd_line, "security_model=mapped-xattr");
@@ -1262,6 +1338,7 @@ static void register_virtio_9p_test(void)
qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts);
qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts);
qos_add_test("local/unlinkat_file", "virtio-9p", fs_unlinkat_file, &opts);
+ qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts);
}
libqos_init(register_virtio_9p_test);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 14/16] tests/9pfs: add local Tunlinkat symlink test
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (9 preceding siblings ...)
2020-10-21 12:33 ` [PULL v2 13/16] tests/9pfs: add local Tsymlink test Christian Schoenebeck
@ 2020-10-21 12:36 ` Christian Schoenebeck
2020-10-21 12:51 ` [PULL v2 15/16] tests/9pfs: add local Tlink test Christian Schoenebeck
` (4 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-21 12:36 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
This test case uses a Tunlinkat request to remove a symlink using
the 9pfs 'local' fs driver.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <a23cd4d2ab6d8d3048addab8cbf0416fe5ead43e.1603285620.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 0c11417236..33cba24b18 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -1295,6 +1295,32 @@ static void fs_symlink_file(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(real_file);
}
+static void fs_unlinkat_symlink(void *obj, void *data,
+ QGuestAllocator *t_alloc)
+{
+ QVirtio9P *v9p = obj;
+ alloc = t_alloc;
+ struct stat st;
+ char *real_file = virtio_9p_test_path("06/real_file");
+ char *symlink_file = virtio_9p_test_path("06/symlink_file");
+
+ do_attach(v9p);
+ do_mkdir(v9p, "/", "06");
+ do_lcreate(v9p, "06", "real_file");
+ g_assert(stat(real_file, &st) == 0);
+ g_assert((st.st_mode & S_IFMT) == S_IFREG);
+
+ do_symlink(v9p, "06", "symlink_file", "real_file");
+ g_assert(stat(symlink_file, &st) == 0);
+
+ do_unlinkat(v9p, "06", "symlink_file", 0);
+ /* symlink should be gone now */
+ g_assert(stat(symlink_file, &st) != 0);
+
+ g_free(symlink_file);
+ g_free(real_file);
+}
+
static void *assign_9p_local_driver(GString *cmd_line, void *arg)
{
virtio_9p_assign_local_driver(cmd_line, "security_model=mapped-xattr");
@@ -1339,6 +1365,8 @@ static void register_virtio_9p_test(void)
qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts);
qos_add_test("local/unlinkat_file", "virtio-9p", fs_unlinkat_file, &opts);
qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts);
+ qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlink,
+ &opts);
}
libqos_init(register_virtio_9p_test);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 15/16] tests/9pfs: add local Tlink test
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (10 preceding siblings ...)
2020-10-21 12:36 ` [PULL v2 14/16] tests/9pfs: add local Tunlinkat symlink test Christian Schoenebeck
@ 2020-10-21 12:51 ` Christian Schoenebeck
2020-10-21 12:55 ` [PULL v2 16/16] tests/9pfs: add local Tunlinkat hard link test Christian Schoenebeck
` (3 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-21 12:51 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
This test case uses a Tlink request to create a hard link to a regular
file using the 9pfs 'local' fs driver.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <f0d869770ad23ee5ce10f7da90fdb742cadcad72.1603285620.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 71 ++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 33cba24b18..460fa49fe3 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -260,6 +260,7 @@ static const char *rmessage_name(uint8_t id)
id == P9_RMKDIR ? "RMKDIR" :
id == P9_RLCREATE ? "RLCREATE" :
id == P9_RSYMLINK ? "RSYMLINK" :
+ id == P9_RLINK ? "RLINK" :
id == P9_RUNLINKAT ? "RUNLINKAT" :
id == P9_RFLUSH ? "RFLUSH" :
id == P9_RREADDIR ? "READDIR" :
@@ -767,6 +768,33 @@ static void v9fs_rsymlink(P9Req *req, v9fs_qid *qid)
v9fs_req_free(req);
}
+/* size[4] Tlink tag[2] dfid[4] fid[4] name[s] */
+static P9Req *v9fs_tlink(QVirtio9P *v9p, uint32_t dfid, uint32_t fid,
+ const char *name, uint16_t tag)
+{
+ P9Req *req;
+
+ uint32_t body_size = 4 + 4;
+ uint16_t string_size = v9fs_string_size(name);
+
+ g_assert_cmpint(body_size, <=, UINT32_MAX - string_size);
+ body_size += string_size;
+
+ req = v9fs_req_init(v9p, body_size, P9_TLINK, tag);
+ v9fs_uint32_write(req, dfid);
+ v9fs_uint32_write(req, fid);
+ v9fs_string_write(req, name);
+ v9fs_req_send(req);
+ return req;
+}
+
+/* size[4] Rlink tag[2] */
+static void v9fs_rlink(P9Req *req)
+{
+ v9fs_req_recv(req, P9_RLINK);
+ v9fs_req_free(req);
+}
+
/* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */
static P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *name,
uint32_t flags, uint16_t tag)
@@ -1142,6 +1170,21 @@ static void do_symlink(QVirtio9P *v9p, const char *path, const char *clink,
g_free(name);
}
+/* create a hard link named @a clink in directory @a path pointing to @a to */
+static void do_hardlink(QVirtio9P *v9p, const char *path, const char *clink,
+ const char *to)
+{
+ uint32_t dfid, fid;
+ P9Req *req;
+
+ dfid = do_walk(v9p, path);
+ fid = do_walk(v9p, to);
+
+ req = v9fs_tlink(v9p, dfid, fid, clink, 0);
+ v9fs_req_wait_for_reply(req, NULL);
+ v9fs_rlink(req);
+}
+
static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rpath,
uint32_t flags)
{
@@ -1321,6 +1364,33 @@ static void fs_unlinkat_symlink(void *obj, void *data,
g_free(real_file);
}
+static void fs_hardlink_file(void *obj, void *data, QGuestAllocator *t_alloc)
+{
+ QVirtio9P *v9p = obj;
+ alloc = t_alloc;
+ struct stat st_real, st_link;
+ char *real_file = virtio_9p_test_path("07/real_file");
+ char *hardlink_file = virtio_9p_test_path("07/hardlink_file");
+
+ do_attach(v9p);
+ do_mkdir(v9p, "/", "07");
+ do_lcreate(v9p, "07", "real_file");
+ g_assert(stat(real_file, &st_real) == 0);
+ g_assert((st_real.st_mode & S_IFMT) == S_IFREG);
+
+ do_hardlink(v9p, "07", "hardlink_file", "07/real_file");
+
+ /* check if link exists now ... */
+ g_assert(stat(hardlink_file, &st_link) == 0);
+ /* ... and it's a hard link, right? */
+ g_assert((st_link.st_mode & S_IFMT) == S_IFREG);
+ g_assert(st_link.st_dev == st_real.st_dev);
+ g_assert(st_link.st_ino == st_real.st_ino);
+
+ g_free(hardlink_file);
+ g_free(real_file);
+}
+
static void *assign_9p_local_driver(GString *cmd_line, void *arg)
{
virtio_9p_assign_local_driver(cmd_line, "security_model=mapped-xattr");
@@ -1367,6 +1437,7 @@ static void register_virtio_9p_test(void)
qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts);
qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlink,
&opts);
+ qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &opts);
}
libqos_init(register_virtio_9p_test);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 16/16] tests/9pfs: add local Tunlinkat hard link test
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (11 preceding siblings ...)
2020-10-21 12:51 ` [PULL v2 15/16] tests/9pfs: add local Tlink test Christian Schoenebeck
@ 2020-10-21 12:55 ` Christian Schoenebeck
2020-10-30 12:07 ` [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests Christian Schoenebeck
` (2 subsequent siblings)
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-21 12:55 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
This test case uses a Tunlinkat request to remove a previously hard
linked file by using the 9pfs 'local' fs driver.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <9bec33a7d8f006ef8f80517985d0d6ac48650d53.1603285620.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 460fa49fe3..23433913bb 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -1391,6 +1391,34 @@ static void fs_hardlink_file(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(real_file);
}
+static void fs_unlinkat_hardlink(void *obj, void *data,
+ QGuestAllocator *t_alloc)
+{
+ QVirtio9P *v9p = obj;
+ alloc = t_alloc;
+ struct stat st_real, st_link;
+ char *real_file = virtio_9p_test_path("08/real_file");
+ char *hardlink_file = virtio_9p_test_path("08/hardlink_file");
+
+ do_attach(v9p);
+ do_mkdir(v9p, "/", "08");
+ do_lcreate(v9p, "08", "real_file");
+ g_assert(stat(real_file, &st_real) == 0);
+ g_assert((st_real.st_mode & S_IFMT) == S_IFREG);
+
+ do_hardlink(v9p, "08", "hardlink_file", "08/real_file");
+ g_assert(stat(hardlink_file, &st_link) == 0);
+
+ do_unlinkat(v9p, "08", "hardlink_file", 0);
+ /* symlink should be gone now */
+ g_assert(stat(hardlink_file, &st_link) != 0);
+ /* and old file should still exist */
+ g_assert(stat(real_file, &st_real) == 0);
+
+ g_free(hardlink_file);
+ g_free(real_file);
+}
+
static void *assign_9p_local_driver(GString *cmd_line, void *arg)
{
virtio_9p_assign_local_driver(cmd_line, "security_model=mapped-xattr");
@@ -1438,6 +1466,8 @@ static void register_virtio_9p_test(void)
qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlink,
&opts);
qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &opts);
+ qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardlink,
+ &opts);
}
libqos_init(register_virtio_9p_test);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 02/16] tests/9pfs: fix coverity error in create_local_test_dir()
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (13 preceding siblings ...)
2020-10-30 12:07 ` [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests Christian Schoenebeck
@ 2020-10-30 12:07 ` Christian Schoenebeck
2020-10-30 12:46 ` [PULL v2 03/16] tests/9pfs: Force removing of local 9pfs test directory Christian Schoenebeck
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-30 12:07 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
Coverity wants the return value of mkdir() to be checked:
/qemu/tests/qtest/libqos/virtio-9p.c: 48 in create_local_test_dir()
42 /* Creates the directory for the 9pfs 'local' filesystem driver to
access. */
43 static void create_local_test_dir(void)
44 {
45 struct stat st;
46
47 g_assert(local_test_path != NULL);
>>> CID 1435963: Error handling issues (CHECKED_RETURN)
>>> Calling "mkdir(local_test_path, 511U)" without checking return value.
This library function may fail and return an error code.
48 mkdir(local_test_path, 0777);
49
50 /* ensure test directory exists now ... */
51 g_assert(stat(local_test_path, &st) == 0);
52 /* ... and is actually a directory */
53 g_assert((st.st_mode & S_IFMT) == S_IFDIR);
So let's just do that and log an info-level message at least, because we
actually only care if the required directory exists and we do have an
existence check for that in place already.
Reported-by: Coverity (CID 1435963)
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <03f68c7ec08064e20f43797f4eb4305ad21e1e8e.1604061839.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/libqos/virtio-9p.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index 6b22fa0e9a..8459a3ee58 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -48,9 +48,14 @@ static void init_local_test_path(void)
static void create_local_test_dir(void)
{
struct stat st;
+ int res;
g_assert(local_test_path != NULL);
- mkdir(local_test_path, 0777);
+ res = mkdir(local_test_path, 0777);
+ if (res < 0) {
+ g_test_message("mkdir('%s') failed: %s", local_test_path,
+ strerror(errno));
+ }
/* ensure test directory exists now ... */
g_assert(stat(local_test_path, &st) == 0);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (12 preceding siblings ...)
2020-10-21 12:55 ` [PULL v2 16/16] tests/9pfs: add local Tunlinkat hard link test Christian Schoenebeck
@ 2020-10-30 12:07 ` Christian Schoenebeck
2020-10-31 13:20 ` Christian Schoenebeck
2020-10-30 12:07 ` [PULL v2 02/16] tests/9pfs: fix coverity error in create_local_test_dir() Christian Schoenebeck
2020-10-30 12:46 ` [PULL v2 03/16] tests/9pfs: Force removing of local 9pfs test directory Christian Schoenebeck
15 siblings, 1 reply; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-30 12:07 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
Use mkdtemp() to generate a unique directory for the 9p 'local' tests.
This fixes occasional 9p test failures when running 'make check -jN' if
QEMU was compiled for multiple target architectures, because the individual
architecture's test suites would run in parallel and interfere with each
other's data as the test directory was previously hard coded and hence the
same directory was used by all of them simultaniously.
This also requires a change how the test directory is created and deleted:
As the test path is now randomized and virtio_9p_register_nodes() being
called in a somewhat undeterministic way, that's no longer an appropriate
place to create and remove the test directory. Use a constructor and
destructor function for creating and removing the test directory instead.
Unfortunately libqos currently does not support setup/teardown callbacks
to handle this more cleanly.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Tested-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <a37fbc713614f7615b11d0a3cb8d9adc3b8fba4b.1604061839.git.qemu_oss@crudebyte.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/libqos/virtio-9p.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index d43647b3b7..6b22fa0e9a 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -35,7 +35,12 @@ static char *concat_path(const char* a, const char* b)
static void init_local_test_path(void)
{
char *pwd = g_get_current_dir();
- local_test_path = concat_path(pwd, "qtest-9p-local");
+ char *template = concat_path(pwd, "qtest-9p-local-XXXXXX");
+ local_test_path = mkdtemp(template);
+ if (!local_test_path) {
+ g_test_message("mkdtemp('%s') failed: %s", template, strerror(errno));
+ }
+ g_assert(local_test_path);
g_free(pwd);
}
@@ -246,11 +251,6 @@ static void virtio_9p_register_nodes(void)
const char *str_simple = "fsdev=fsdev0,mount_tag=" MOUNT_TAG;
const char *str_addr = "fsdev=fsdev0,addr=04.0,mount_tag=" MOUNT_TAG;
- /* make sure test dir for the 'local' tests exists and is clean */
- init_local_test_path();
- remove_local_test_dir();
- create_local_test_dir();
-
QPCIAddress addr = {
.devfn = QPCI_DEVFN(4, 0),
};
@@ -278,3 +278,16 @@ static void virtio_9p_register_nodes(void)
}
libqos_init(virtio_9p_register_nodes);
+
+static void __attribute__((constructor)) construct_virtio_9p(void)
+{
+ /* make sure test dir for the 'local' tests exists */
+ init_local_test_path();
+ create_local_test_dir();
+}
+
+static void __attribute__((destructor)) destruct_virtio_9p(void)
+{
+ /* remove previously created test dir when test suite completed */
+ remove_local_test_dir();
+}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 03/16] tests/9pfs: Force removing of local 9pfs test directory
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
` (14 preceding siblings ...)
2020-10-30 12:07 ` [PULL v2 02/16] tests/9pfs: fix coverity error in create_local_test_dir() Christian Schoenebeck
@ 2020-10-30 12:46 ` Christian Schoenebeck
15 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-30 12:46 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
From: Greg Kurz <groug@kaod.org>
No need to get a complaint from "rm" if some path disappeared for some
reason.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <160406199444.312256.8319835906008559151.stgit@bahia.lan>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
---
tests/qtest/libqos/virtio-9p.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index 8459a3ee58..580ad09a2f 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -67,7 +67,7 @@ static void create_local_test_dir(void)
static void remove_local_test_dir(void)
{
g_assert(local_test_path != NULL);
- char *cmd = g_strdup_printf("rm -r '%s'\n", local_test_path);
+ char *cmd = g_strdup_printf("rm -fr '%s'\n", local_test_path);
int res = system(cmd);
if (res < 0) {
/* ignore error, dummy check to prevent compiler error */
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PULL v2 00/16] 9p queue (previous 2020-10-23)
@ 2020-10-30 14:19 Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 04/16] tests/9pfs: Factor out do_version() helper Christian Schoenebeck
` (15 more replies)
0 siblings, 16 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-30 14:19 UTC (permalink / raw)
To: qemu-devel, Peter Maydell; +Cc: Greg Kurz
The following changes since commit a19d4bc452532a9402f90b77d2aaaed9fe1df046:
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-5.2-20201028' into staging (2020-10-29 14:30:58 +0000)
are available in the Git repository at:
https://github.com/cschoenebeck/qemu.git tags/pull-9p-20201030
for you to fetch changes up to 69067bf1436aab1c84b98b8461e81a9633ec7872:
tests/9pfs: add local Tunlinkat hard link test (2020-10-30 14:59:39 +0100)
----------------------------------------------------------------
9pfs: more tests using local fs driver
Only 9pfs test case changes this time:
* Fix occasional test failures with parallel tests.
* Fix coverity error in test code.
* Avoid error when auto removing test directory if disappeared for
some reason.
* Refactor: Rename functions to make top-level test functions fs_*()
easily distinguishable from utility test functions do_*().
* Refactor: Drop unnecessary function arguments in utility test
functions.
* More test cases using the 9pfs 'local' filesystem driver backend,
namely for the following 9p requests: Tunlinkat, Tlcreate, Tsymlink
and Tlink.
----------------------------------------------------------------
Christian Schoenebeck (10):
tests/9pfs: fix test dir for parallel tests
tests/9pfs: fix coverity error in create_local_test_dir()
tests/9pfs: simplify do_mkdir()
tests/9pfs: add local Tunlinkat directory test
tests/9pfs: add local Tlcreate test
tests/9pfs: add local Tunlinkat file test
tests/9pfs: add local Tsymlink test
tests/9pfs: add local Tunlinkat symlink test
tests/9pfs: add local Tlink test
tests/9pfs: add local Tunlinkat hard link test
Greg Kurz (6):
tests/9pfs: Force removing of local 9pfs test directory
tests/9pfs: Factor out do_version() helper
tests/9pfs: Set alloc in fs_create_dir()
tests/9pfs: Factor out do_attach() helper
tests/9pfs: Turn fs_readdir_split() into a helper
tests/9pfs: Turn fs_mkdir() into a helper
tests/qtest/libqos/virtio-9p.c | 34 ++-
tests/qtest/virtio-9p-test.c | 467 +++++++++++++++++++++++++++++++++++++----
2 files changed, 457 insertions(+), 44 deletions(-)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests
2020-10-30 12:07 ` [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests Christian Schoenebeck
@ 2020-10-31 13:20 ` Christian Schoenebeck
2020-10-31 20:34 ` Peter Maydell
2020-11-01 11:37 ` Christian Schoenebeck
0 siblings, 2 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-31 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Greg Kurz
On Freitag, 30. Oktober 2020 13:07:03 CET Christian Schoenebeck wrote:
> Use mkdtemp() to generate a unique directory for the 9p 'local' tests.
>
> This fixes occasional 9p test failures when running 'make check -jN' if
> QEMU was compiled for multiple target architectures, because the individual
> architecture's test suites would run in parallel and interfere with each
> other's data as the test directory was previously hard coded and hence the
> same directory was used by all of them simultaniously.
>
> This also requires a change how the test directory is created and deleted:
> As the test path is now randomized and virtio_9p_register_nodes() being
> called in a somewhat undeterministic way, that's no longer an appropriate
> place to create and remove the test directory. Use a constructor and
> destructor function for creating and removing the test directory instead.
> Unfortunately libqos currently does not support setup/teardown callbacks
> to handle this more cleanly.
Peter, please ignore this PR. This patch needs rework:
ERROR:../tests/qtest/test-x86-cpuid-compat.c:208:test_plus_minus: stdout of
child process (/x86/cpuid/parsing-plus-minus/subprocess [34856]) failed to
match:
stdout was:
# mkdir('/home/travis/build/cschoenebeck/qemu/build/qtest-9p-local-PwY2nQ')
failed: File exists
ERROR qtest-x86_64/test-x86-cpuid-compat - Bail out! ERROR:../tests/qtest/
test-x86-cpuid-compat.c:208:test_plus_minus: stdout of child process (/x86/
cpuid/parsing-plus-minus/subprocess [34856]) failed to match:
make: *** [Makefile.mtest:1793: run-test-222] Error 1
https://travis-ci.org/github/cschoenebeck/qemu/jobs/740199494
>
> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Tested-by: Greg Kurz <groug@kaod.org>
> Reviewed-by: Greg Kurz <groug@kaod.org>
> Message-Id:
> <a37fbc713614f7615b11d0a3cb8d9adc3b8fba4b.1604061839.git.qemu_oss@crudebyte
> .com> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> ---
> tests/qtest/libqos/virtio-9p.c | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
> index d43647b3b7..6b22fa0e9a 100644
> --- a/tests/qtest/libqos/virtio-9p.c
> +++ b/tests/qtest/libqos/virtio-9p.c
> @@ -35,7 +35,12 @@ static char *concat_path(const char* a, const char* b)
> static void init_local_test_path(void)
> {
> char *pwd = g_get_current_dir();
> - local_test_path = concat_path(pwd, "qtest-9p-local");
> + char *template = concat_path(pwd, "qtest-9p-local-XXXXXX");
> + local_test_path = mkdtemp(template);
> + if (!local_test_path) {
> + g_test_message("mkdtemp('%s') failed: %s", template,
> strerror(errno)); + }
> + g_assert(local_test_path);
> g_free(pwd);
> }
>
> @@ -246,11 +251,6 @@ static void virtio_9p_register_nodes(void)
> const char *str_simple = "fsdev=fsdev0,mount_tag=" MOUNT_TAG;
> const char *str_addr = "fsdev=fsdev0,addr=04.0,mount_tag=" MOUNT_TAG;
>
> - /* make sure test dir for the 'local' tests exists and is clean */
> - init_local_test_path();
> - remove_local_test_dir();
> - create_local_test_dir();
> -
> QPCIAddress addr = {
> .devfn = QPCI_DEVFN(4, 0),
> };
> @@ -278,3 +278,16 @@ static void virtio_9p_register_nodes(void)
> }
>
> libqos_init(virtio_9p_register_nodes);
> +
> +static void __attribute__((constructor)) construct_virtio_9p(void)
> +{
> + /* make sure test dir for the 'local' tests exists */
> + init_local_test_path();
> + create_local_test_dir();
> +}
I'm not sure yet what happens there exactly. One problem that I can see is
that this constructor function is executed before main() is entered, it
generates a random test path as global variable, creates that test directory,
then main() is entered and qost-test.c might now call g_test_trap_subprocess()
(depending on the config) which would fork the process for the individual test
cases, probably ending up with a shared test dir path unintentionally. So this
constructor solution is probably wrong anyway.
But that does not explain what I'm seeing in above's CI error: that error
message suggests that create_local_test_dir() was called in parallel with the
same test path. A GCC constructor function being called again on fork() is not
an expected behaviour to me, but assuming it does on some system, the address
space should have deviated at this point and hence each subprocess should end
up with overwriting the global test path variable with their own test
directory path in this case.
It's too late for touching libqos for this, so I hope we can find a temporary
workaround for this problem for 5.2 release. For instance by using a TLS
(__thread) variable instead of a regular global variable for the test path,
but I would still like to understand the precise (mis)behaviour observed
there.
> +
> +static void __attribute__((destructor)) destruct_virtio_9p(void)
> +{
> + /* remove previously created test dir when test suite completed */
> + remove_local_test_dir();
> +}
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests
2020-10-31 13:20 ` Christian Schoenebeck
@ 2020-10-31 20:34 ` Peter Maydell
2020-10-31 21:15 ` Christian Schoenebeck
2020-11-01 11:37 ` Christian Schoenebeck
1 sibling, 1 reply; 21+ messages in thread
From: Peter Maydell @ 2020-10-31 20:34 UTC (permalink / raw)
To: Christian Schoenebeck; +Cc: QEMU Developers, Greg Kurz
On Sat, 31 Oct 2020 at 13:20, Christian Schoenebeck
<qemu_oss@crudebyte.com> wrote:
>
> On Freitag, 30. Oktober 2020 13:07:03 CET Christian Schoenebeck wrote:
> > Use mkdtemp() to generate a unique directory for the 9p 'local' tests.
> >
> > This fixes occasional 9p test failures when running 'make check -jN' if
> > QEMU was compiled for multiple target architectures, because the individual
> > architecture's test suites would run in parallel and interfere with each
> > other's data as the test directory was previously hard coded and hence the
> > same directory was used by all of them simultaniously.
> >
> > This also requires a change how the test directory is created and deleted:
> > As the test path is now randomized and virtio_9p_register_nodes() being
> > called in a somewhat undeterministic way, that's no longer an appropriate
> > place to create and remove the test directory. Use a constructor and
> > destructor function for creating and removing the test directory instead.
> > Unfortunately libqos currently does not support setup/teardown callbacks
> > to handle this more cleanly.
>
> Peter, please ignore this PR. This patch needs rework:
OK. As a general rule you need to make "please drop this PR"
requests as replies to the top level cover letter, though --
otherwise it's pot luck whether I happen to notice them or not.
thanks
-- PMM
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests
2020-10-31 20:34 ` Peter Maydell
@ 2020-10-31 21:15 ` Christian Schoenebeck
0 siblings, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-10-31 21:15 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Greg Kurz
On Samstag, 31. Oktober 2020 21:34:31 CET Peter Maydell wrote:
> On Sat, 31 Oct 2020 at 13:20, Christian Schoenebeck
>
> <qemu_oss@crudebyte.com> wrote:
> > On Freitag, 30. Oktober 2020 13:07:03 CET Christian Schoenebeck wrote:
> > > Use mkdtemp() to generate a unique directory for the 9p 'local' tests.
> > >
> > > This fixes occasional 9p test failures when running 'make check -jN' if
> > > QEMU was compiled for multiple target architectures, because the
> > > individual
> > > architecture's test suites would run in parallel and interfere with each
> > > other's data as the test directory was previously hard coded and hence
> > > the
> > > same directory was used by all of them simultaniously.
> > >
> > > This also requires a change how the test directory is created and
> > > deleted:
> > > As the test path is now randomized and virtio_9p_register_nodes() being
> > > called in a somewhat undeterministic way, that's no longer an
> > > appropriate
> > > place to create and remove the test directory. Use a constructor and
> > > destructor function for creating and removing the test directory
> > > instead.
> > > Unfortunately libqos currently does not support setup/teardown callbacks
> > > to handle this more cleanly.
> >
> > Peter, please ignore this PR. This patch needs rework:
> OK. As a general rule you need to make "please drop this PR"
> requests as replies to the top level cover letter, though --
> otherwise it's pot luck whether I happen to notice them or not.
>
> thanks
> -- PMM
Okay, got it.
Best regards,
Christian Schoenebeck
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests
2020-10-31 13:20 ` Christian Schoenebeck
2020-10-31 20:34 ` Peter Maydell
@ 2020-11-01 11:37 ` Christian Schoenebeck
1 sibling, 0 replies; 21+ messages in thread
From: Christian Schoenebeck @ 2020-11-01 11:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Greg Kurz
On Samstag, 31. Oktober 2020 14:20:27 CET Christian Schoenebeck wrote:
> On Freitag, 30. Oktober 2020 13:07:03 CET Christian Schoenebeck wrote:
> > Use mkdtemp() to generate a unique directory for the 9p 'local' tests.
> >
> > This fixes occasional 9p test failures when running 'make check -jN' if
> > QEMU was compiled for multiple target architectures, because the
> > individual
> > architecture's test suites would run in parallel and interfere with each
> > other's data as the test directory was previously hard coded and hence the
> > same directory was used by all of them simultaniously.
> >
> > This also requires a change how the test directory is created and deleted:
> > As the test path is now randomized and virtio_9p_register_nodes() being
> > called in a somewhat undeterministic way, that's no longer an appropriate
> > place to create and remove the test directory. Use a constructor and
> > destructor function for creating and removing the test directory instead.
> > Unfortunately libqos currently does not support setup/teardown callbacks
> > to handle this more cleanly.
>
> Peter, please ignore this PR. This patch needs rework:
>
> ERROR:../tests/qtest/test-x86-cpuid-compat.c:208:test_plus_minus: stdout of
> child process (/x86/cpuid/parsing-plus-minus/subprocess [34856]) failed to
> match:
>
> stdout was:
>
> # mkdir('/home/travis/build/cschoenebeck/qemu/build/qtest-9p-local-PwY2nQ')
> failed: File exists
>
> ERROR qtest-x86_64/test-x86-cpuid-compat - Bail out! ERROR:../tests/qtest/
> test-x86-cpuid-compat.c:208:test_plus_minus: stdout of child process (/x86/
> cpuid/parsing-plus-minus/subprocess [34856]) failed to match:
>
> make: *** [Makefile.mtest:1793: run-test-222] Error 1
>
> https://travis-ci.org/github/cschoenebeck/qemu/jobs/740199494
Ok, I found a solution: by moving constructor & destructor functions from
virtio-9p.c to virtio-9p-test.c:
https://github.com/cschoenebeck/qemu/commit/b4c72149f087d5a
The problem was that the constructor function was executed when libqos was
loaded, which included completely unrelated test suites that just link to
libqos.
In conjunction with Peter Xu's two migration patches (fixing occasional
lockups of migration tests) overall situation appears to be smooth now:
https://lore.kernel.org/qemu-devel/20201030135350.GA588069@xz-x1/
There is now only one test failure left concerning macOS Xcode builds, but
that seems to be completely unrelated to our 9pfs patches:
https://github.com/cschoenebeck/qemu/runs/1338011297
missing object type 'vhost-user-gpu'
Broken pipe
../tests/qtest/libqtest.c:176: kill_qemu() detected QEMU death from signal 6
(Abort trap: 6)
ERROR qtest-aarch64/device-introspect-test - too few tests run (expected 6,
got 5)
gmake: *** [Makefile.mtest:905: run-test-111] Error 1
I prepare updated patches for review.
Best regards,
Christian Schoenebeck
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2020-11-01 11:38 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-30 14:19 [PULL v2 00/16] 9p queue (previous 2020-10-23) Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 04/16] tests/9pfs: Factor out do_version() helper Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 07/16] tests/9pfs: Turn fs_readdir_split() into a helper Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 05/16] tests/9pfs: Set alloc in fs_create_dir() Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 06/16] tests/9pfs: Factor out do_attach() helper Christian Schoenebeck
2020-10-20 16:09 ` [PULL v2 08/16] tests/9pfs: Turn fs_mkdir() into a helper Christian Schoenebeck
2020-10-21 12:06 ` [PULL v2 09/16] tests/9pfs: simplify do_mkdir() Christian Schoenebeck
2020-10-21 12:17 ` [PULL v2 10/16] tests/9pfs: add local Tunlinkat directory test Christian Schoenebeck
2020-10-21 12:25 ` [PULL v2 11/16] tests/9pfs: add local Tlcreate test Christian Schoenebeck
2020-10-21 12:28 ` [PULL v2 12/16] tests/9pfs: add local Tunlinkat file test Christian Schoenebeck
2020-10-21 12:33 ` [PULL v2 13/16] tests/9pfs: add local Tsymlink test Christian Schoenebeck
2020-10-21 12:36 ` [PULL v2 14/16] tests/9pfs: add local Tunlinkat symlink test Christian Schoenebeck
2020-10-21 12:51 ` [PULL v2 15/16] tests/9pfs: add local Tlink test Christian Schoenebeck
2020-10-21 12:55 ` [PULL v2 16/16] tests/9pfs: add local Tunlinkat hard link test Christian Schoenebeck
2020-10-30 12:07 ` [PULL v2 01/16] tests/9pfs: fix test dir for parallel tests Christian Schoenebeck
2020-10-31 13:20 ` Christian Schoenebeck
2020-10-31 20:34 ` Peter Maydell
2020-10-31 21:15 ` Christian Schoenebeck
2020-11-01 11:37 ` Christian Schoenebeck
2020-10-30 12:07 ` [PULL v2 02/16] tests/9pfs: fix coverity error in create_local_test_dir() Christian Schoenebeck
2020-10-30 12:46 ` [PULL v2 03/16] tests/9pfs: Force removing of local 9pfs test directory Christian Schoenebeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).