From patchwork Tue Oct 20 16:09:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1386692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjDg3gMTz9sRR for ; Fri, 23 Oct 2020 22:48:51 +1100 (AEDT) Received: from localhost ([::1]:41476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvYv-0003uY-4z for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:48:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvY0-0003sg-Gq for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:47:52 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:40751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvXo-0004HB-9H for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:47:52 -0400 Message-Id: In-Reply-To: References: From: Greg Kurz Date: Tue, 20 Oct 2020 18:09:14 +0200 Subject: [PULL 01/13] tests/9pfs: Factor out do_version() helper To: qemu-devel@nongnu.org, Peter Maydell Received-SPF: none client-ip=91.194.90.13; envelope-from=ccc858509ddfa3f6244cc4caf92c4149b7269b43@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Message-Id: <160321015403.266767.4533967728943968456.stgit@bahia.lan> Signed-off-by: Christian Schoenebeck --- 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); From patchwork Tue Oct 20 16:09:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1386693 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjDh0Py4z9sSs for ; Fri, 23 Oct 2020 22:48:52 +1100 (AEDT) Received: from localhost ([::1]:41506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvYv-0003vh-VQ for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:48:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvY0-0003tH-Nu for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:47:52 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:43117) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvXs-0004Hh-6o for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:47:52 -0400 Message-Id: In-Reply-To: References: From: Greg Kurz Date: Tue, 20 Oct 2020 18:09:27 +0200 Subject: [PULL 02/13] tests/9pfs: Set alloc in fs_create_dir() To: qemu-devel@nongnu.org, Peter Maydell Received-SPF: none client-ip=91.194.90.13; envelope-from=d620e738b4d392e2c7ac99b3fd3082e4c5053d5a@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" fs_create_dir() is a top level test function. It should set alloc. Signed-off-by: Greg Kurz Message-Id: <160321016764.266767.3763279057643874020.stgit@bahia.lan> Signed-off-by: Christian Schoenebeck --- 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"); From patchwork Tue Oct 20 16:09:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1386696 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjGY2lF7z9sRR for ; Fri, 23 Oct 2020 22:50:29 +1100 (AEDT) Received: from localhost ([::1]:49724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvaV-0007H0-14 for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:50:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvY3-0003uF-4z for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:47:56 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:41855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvY1-0004IE-KD for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:47:54 -0400 Message-Id: In-Reply-To: References: From: Greg Kurz Date: Tue, 20 Oct 2020 18:09:34 +0200 Subject: [PULL 03/13] tests/9pfs: Factor out do_attach() helper To: qemu-devel@nongnu.org, Peter Maydell Received-SPF: none client-ip=91.194.90.13; envelope-from=c06e9118de9642966a2dc368077087ce1571f63e@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Message-Id: <160321017450.266767.17377192504263871186.stgit@bahia.lan> Signed-off-by: Christian Schoenebeck --- 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 ... */ From patchwork Tue Oct 20 16:09:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1386698 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjJJ4n9Nz9sRR for ; Fri, 23 Oct 2020 22:52:00 +1100 (AEDT) Received: from localhost ([::1]:54980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvby-00015S-J1 for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:51:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvY6-0003xW-KT for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:47:58 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:53121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvY5-0004Ir-93 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:47:58 -0400 Message-Id: In-Reply-To: References: From: Greg Kurz Date: Tue, 20 Oct 2020 18:09:20 +0200 Subject: [PULL 04/13] tests/9pfs: Turn fs_readdir_split() into a helper To: qemu-devel@nongnu.org, Peter Maydell Received-SPF: none client-ip=91.194.90.13; envelope-from=c2f93e5bb1ee5cc05875ac40b1f9ad0738241c37@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Message-Id: <160321016084.266767.9501523425012383531.stgit@bahia.lan> Signed-off-by: Christian Schoenebeck --- 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); } From patchwork Tue Oct 20 16:09:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1386694 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjFK5tFVz9sRR for ; Fri, 23 Oct 2020 22:49:25 +1100 (AEDT) Received: from localhost ([::1]:44170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvZT-000541-5V for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:49:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <780f9da880e45280ce4e0a1b7c72fce618623a05@lizzy.crudebyte.com>) id 1kVvYD-00049r-9x for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:06 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:44387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <780f9da880e45280ce4e0a1b7c72fce618623a05@lizzy.crudebyte.com>) id 1kVvYC-0004Jf-15 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:05 -0400 Message-Id: <780f9da880e45280ce4e0a1b7c72fce618623a05.1603452058.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Greg Kurz Date: Tue, 20 Oct 2020 18:09:41 +0200 Subject: [PULL 05/13] tests/9pfs: Turn fs_mkdir() into a helper To: qemu-devel@nongnu.org, Peter Maydell Received-SPF: none client-ip=91.194.90.13; envelope-from=780f9da880e45280ce4e0a1b7c72fce618623a05@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Message-Id: <160321018148.266767.15959608711038504029.stgit@bahia.lan> Signed-off-by: Christian Schoenebeck --- 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); From patchwork Wed Oct 21 12:06:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1386701 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.a=rsa-sha256 header.s=lizzy header.b=NfyXETMS; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjLZ0VH8z9sSs for ; Fri, 23 Oct 2020 22:53:58 +1100 (AEDT) Received: from localhost ([::1]:34092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvds-00042F-2Z for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:53:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvYL-0004BX-2i for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:13 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:39161) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvYI-0004Jy-5Z for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=9ifmdLPDMaqG5Wb2AjtogbTpfUi00Bi4jhLYWV8cvng=; b=NfyXE TMSde0OrmuOc97vEjmJyLn6Ps8Rkj3d8ZmIGzRq1UBsUx0FO4Bw+1UcWP/kkoGTg1xiaUaZR3K0uj Jx/UbPqh94C3WEYiLY0AMMDoKSSOwULKACDtr+h7eYeWi2LYrYupkjfPzpOjq1eAVM/cx7mzS7eRB sSNhuEILhojPTqKv0oJh+Ir863Yrh06R7aVUSaoFA8fbWti155tYnt1HNFHmmGp8pBd6ZY+FWwSnV HhOH9DDXGMiAg5Z9HwNo2A2Ei9c2GR4PlSC8HjJrsGEgliR3DQbxUmqbKNeX7pgxeqcWH3y+NAC8E 2W1a27mfSbQhDY9Ufvz9kjT+wLatA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:06:53 +0200 Subject: [PULL 06/13] tests/9pfs: simplify do_mkdir() To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=cb2bc157997817ea2e0787aae3349b94fb0a402b@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Greg Kurz Message-Id: <4d7275b2363f122438a443ce079cbb355285e9d6.1603285620.git.qemu_oss@crudebyte.com> Signed-off-by: Christian Schoenebeck --- 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, From patchwork Wed Oct 21 12:17:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1386704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.a=rsa-sha256 header.s=lizzy header.b=VnQT6Sok; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjPJ6XJYz9sSC for ; Fri, 23 Oct 2020 22:56:19 +1100 (AEDT) Received: from localhost ([::1]:42124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvg9-0007Kl-64 for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:56:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <266004888ff6f4192e629ac09dd5950cbd41fd0e@lizzy.crudebyte.com>) id 1kVvYP-0004I9-V7 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:17 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:40089) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <266004888ff6f4192e629ac09dd5950cbd41fd0e@lizzy.crudebyte.com>) id 1kVvYO-0004MG-5q for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=phItk4QZiksuHmENHHPRlyMGsHv4X7a/4BRC5vPMnvE=; b=VnQT6 SokZeJsZ2DbspQZ+B2DrdjD4tJeJtyzWyYo0tefOb+ftFCfMEhocKYUjZECTwa12o5ew8ud+N3yhk 58DO2d5EBS8yemeYxLb41rxIhaEgeyrZm4WAK5gohUqDd0UcggirVOJ7n9JV8g+3QKqpskuRNcxZE qOv9kPq1ldbJeyqcaXZbmlgQKtyRAPKx7MR7SxA7pZfI0Io52pklnHHiShDOOIZIKt5LIxDZtMk/O /MmixPbC2jRyoaoRdGoN/yPhgb6Ncav5cQbTBwWwXQSaIPui1EcYF2zDOTG+LQPaw/mp8e2DBY54o LIEBdSvNqWaO9CneqJ11fHs3XsCEQ==; Message-Id: <266004888ff6f4192e629ac09dd5950cbd41fd0e.1603452058.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:17:01 +0200 Subject: [PULL 07/13] tests/9pfs: add local Tunlinkat directory test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=266004888ff6f4192e629ac09dd5950cbd41fd0e@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Greg Kurz Message-Id: <3c7c65b476ba44bea6afd0b378b5287e1c671a32.1603285620.git.qemu_oss@crudebyte.com> Signed-off-by: Christian Schoenebeck --- 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" : ""; @@ -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); From patchwork Wed Oct 21 12:25:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1386699 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.a=rsa-sha256 header.s=lizzy header.b=cXLYyiiD; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjK16Glzz9sV0 for ; Fri, 23 Oct 2020 22:52:37 +1100 (AEDT) Received: from localhost ([::1]:57142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvcZ-0001wc-Q2 for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:52:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvYX-0004NZ-KB for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:25 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:49693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvYV-0004N3-0a for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=7F7Z+yXYLuM3MjkIbqlf4UwiBRT7dXMX22Ht94r12PE=; b=cXLYy iiDe358cfpL+/MSPgvV5yaHMvb3LtEmSU0SNunj2w0UME4rqOR0WGXvFxYqgw4gt+IIbmiA4JmC79 O3HTvu0GcSWH0XhYzwFGd6lVPpCfk+rapm8j6bM5FpOgURcbbREUTnQV5tZgmalhi/riWxNzKFN7g JzS7hvofXB/mEUTiFsiZ0m9ckJBkV5WpzgMy8Sx1Pit9smzo+WEq+ACy1+kpyXpdNqj08ubFAt9C/ 1ws+Ve2XwmwE9I8ASOtYpddJvF+zc/UkXgRozBqC3ckJCIiD+MB/MPUcCqt5AQ5r+s7W2FdB6xsfG U6IZ9d26pwwyBH1UHTL9o/t1c9nEw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:25:33 +0200 Subject: [PULL 08/13] tests/9pfs: add local Tlcreate test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=ac1bff459a214f1f4fb7e7951d467e168433b6d3@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This test case uses a Tlcreate 9p request to create a regular file inside host's test directory. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: <269cae0c00af941a3a4ae78f1e319f93462a7eb4.1603285620.git.qemu_oss@crudebyte.com> Signed-off-by: Christian Schoenebeck --- 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); From patchwork Wed Oct 21 12:28:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1386697 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.a=rsa-sha256 header.s=lizzy header.b=aTSqSu0J; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjGc3vk9z9sRR for ; Fri, 23 Oct 2020 22:50:31 +1100 (AEDT) Received: from localhost ([::1]:49838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvaX-0007Jo-8W for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:50:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <30eb3a9d70336b9ff551ce618ab96756a0852d5d@lizzy.crudebyte.com>) id 1kVvYg-0004Pk-Gj for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:34 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:50313) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <30eb3a9d70336b9ff551ce618ab96756a0852d5d@lizzy.crudebyte.com>) id 1kVvYb-0004OY-7d for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=7iFIBZ5NpaoP5l93o3hNP52+z8dbWVQ86vHcSLemKEc=; b=aTSqS u0JK7LkBSdBb2C8C4k79Rv3T12BjsFE6G3G4AkPlwT0nVt5DgiDW8xOm92d5B0aNc2IP7i38sFITS aRQqMPwqVYAJfvZu/0mfu8QvnngTmjw01Cr3m/wymqIaurusumO6wD4kCJpVcRaFKsWZViHVO1mXH 92ZHlMfoFPJJzVB+Ps4Rd1LfSqvp1dCYEcJIj/55DTtE8f0u4hSdXxlNr+kauBczKxteJ3P7sEX79 vBrbxw2rOwZImJpLCa1sX1gZbkrOUmvgOkXXoeYZz0wnnMPPLcWQwhORFksZhMeQEcmldX4sVD0AX Zul8qeSqINM4SYhi+TfUlrHY/n3Vw==; Message-Id: <30eb3a9d70336b9ff551ce618ab96756a0852d5d.1603452058.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:28:37 +0200 Subject: [PULL 09/13] tests/9pfs: add local Tunlinkat file test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=30eb3a9d70336b9ff551ce618ab96756a0852d5d@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This test case uses a Tunlinkat request to remove a regular file using the 9pfs 'local' fs driver. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: <4eabeed7f662721dd5664cb77fe36ea0aa08b1ec.1603285620.git.qemu_oss@crudebyte.com> Signed-off-by: Christian Schoenebeck --- 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); From patchwork Wed Oct 21 12:33:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1386700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.a=rsa-sha256 header.s=lizzy header.b=FWiqDAiI; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjK6389yz9sRR for ; Fri, 23 Oct 2020 22:52:42 +1100 (AEDT) Received: from localhost ([::1]:57498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvce-00025C-Di for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:52:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvYk-0004aR-ES for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:38 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:42387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvYh-0004PN-Lx for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=OD7Yyr93C0A87zYt/bsdPE2n3KV3zRdFYYMe3b+B+jo=; b=FWiqD AiIF8G/XkV2LlxHB23YhxKVrR38U9x7sl65e8LZGvCLiDVZZQf2B3Dj3CPv+cFwXEfOWMkL+ZuZFD MeLKRRjftlH+Xjo7VPuwmo17nioNWjstfAFBoHMcI/Xbm2nZqTDxZQ2Ib9tOWU590xPFezAxLr8XI yx7iWLAYv1iRx11YSzDi71D9vLjigWxsOslAnUIiJcvHV5c0bD8whPzBD3pLouLa/E+MVnMXtu15E OFD9ejADuTFF4olvk0mTaen2EfDGaanW5MbS27Nf/7sFAsWR6vcMiN3dE5GCu3aPJqpKmDRtoUB9A fnI4Kjw2IrguAbCoYQTHBjjCpCl2w==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:33:34 +0200 Subject: [PULL 10/13] tests/9pfs: add local Tsymlink test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=ed2d6df69f6b9c0783bea7f25f5d9f5f2210b9b8@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This test case uses a Tsymlink 9p request to create a symbolic link using the 9pfs 'local' fs driver. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: <84ac76937855bf441242372cc3e62df42f0a3dc4.1603285620.git.qemu_oss@crudebyte.com> Signed-off-by: Christian Schoenebeck --- 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); From patchwork Wed Oct 21 12:36:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1386702 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.a=rsa-sha256 header.s=lizzy header.b=VYTfi8nc; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjMR6JKYz9sSC for ; Fri, 23 Oct 2020 22:54:43 +1100 (AEDT) Received: from localhost ([::1]:36972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVveb-0005AF-OJ for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:54:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <127710a7492e53b241083831e11ba25b50fcaa8d@lizzy.crudebyte.com>) id 1kVvYv-0004w8-WE for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:50 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:40993) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <127710a7492e53b241083831e11ba25b50fcaa8d@lizzy.crudebyte.com>) id 1kVvYs-0004QQ-48 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=RRYV2V8efYiYdm3SDBKXqfdnY+J0tgfzztDfqmMM+x4=; b=VYTfi 8nc6rel42IHfm6AO1PIxU9rUXzuz7ws8oVJdvVxlQzwiV9D/py/1FTeh8nKs1tUfGsXbLCWFNZcJn bxQcWELQNZ6x+EKDVJPxvDObUngvihscGAulHWE0+pXsME/Tz+ibFjsMQR4TXvn0kbyy96uMFgibP GWexIYMfcQzmAGHt8qcnYJBa+n7X7HbxgOwU+ICjeG1Br39cXb4V2D8P0EruFWwrZlghBI3vnOsYk AKWlO6aLRmckTk/zXSagKuxCbsQjHS3ovJGaIrBaSl7WrpTAOHDq/R5vZPI6LoqZ/K3Kqv0eVGbfV qbH67fyEuq6076/y0UwHQY9kD1b7w==; Message-Id: <127710a7492e53b241083831e11ba25b50fcaa8d.1603452058.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:36:23 +0200 Subject: [PULL 11/13] tests/9pfs: add local Tunlinkat symlink test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=127710a7492e53b241083831e11ba25b50fcaa8d@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This test case uses a Tunlinkat request to remove a symlink using the 9pfs 'local' fs driver. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: Signed-off-by: Christian Schoenebeck --- 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); From patchwork Wed Oct 21 12:51:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1386705 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.a=rsa-sha256 header.s=lizzy header.b=WyPNVo+4; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjPv1bNtz9sSC for ; Fri, 23 Oct 2020 22:56:51 +1100 (AEDT) Received: from localhost ([::1]:44990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvgf-0008V6-7L for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:56:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvYy-00051t-4Y for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:52 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:57673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvYw-0004RF-Ey for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=wE/8N1R/Y5ft9aFlOJdMEJqi1XpAlJXf89HVnVRNyyQ=; b=WyPNV o+4pLnD3im3sjRztFsL3KU003FyYyQVdB0b9NY7DrocCJy9z/Pr4PzQczIGSTp9Xwt3n6ALhW5YQH Q5A7lwcQrFf5BwFIx3v+iSnMAazwXHRaVH2CAZG8FxqLfNZT8FuinCQiHrsedwJZ/KeJ0zePKlemP 9PVJMtkMfmiZeitQWN2iBltkc/l9NM5fbodt2y/eMNVzSdWPIeyPKS2WDWoIJCteqRMJEWtbzROTA KmxmaJ2Kfo6/JsVzfycg+nc1V5xtLUJVBzLb66zV5rgYI/pBYHEes7iQwue0fYZl5SgpH51eYNAVo Vo9Uyqm47EiFjQxIszYdcdVURMzuA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:51:09 +0200 Subject: [PULL 12/13] tests/9pfs: add local Tlink test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=dded36819376806576518874f63a974af611f561@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Greg Kurz Message-Id: Signed-off-by: Christian Schoenebeck --- 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); From patchwork Wed Oct 21 12:55:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 1386703 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=crudebyte.com header.i=@crudebyte.com header.a=rsa-sha256 header.s=lizzy header.b=f2nXm9BN; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHjMW5vkMz9sSs for ; Fri, 23 Oct 2020 22:54:47 +1100 (AEDT) Received: from localhost ([::1]:37394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvef-0005Li-Fh for incoming@patchwork.ozlabs.org; Fri, 23 Oct 2020 07:54:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvZ6-0005Ei-7m for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:49:01 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:34933) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVvZ4-0004TJ-Se for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:48:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=xsjARTJMRsIzsvTagiZQBElZfq3230JVVbcEUvQWxjk=; b=f2nXm 9BNnnHJZza8fCfbtzrDNrp0kgw8U0XFv/GjZkLIW7Yb47gM2ZTZ/2WlB6ULR/qNfKyrKYEiDtQnv0 Kpky4L6NBe23gKeH7AReVL0tXrGJEQvxEh+BOdAIhSO0B6LnDBs1zNxYqbmX+1OqV1w+QNGV1EyGC kOGyiFFfv2pITCDBSqQcWlzIFLv/yaMciSujnPGs7enYDV9B/Uc4R4cm1ALKCXLqYq/R4HxmLawL/ YrCATvyjyfNsKnLtRCGBs2BJLVqhi9x4SRowGdMNMpB+nJGOhsJR47KsBU35AR3Uefz2azKC4hfrM fqF/lmSq7+dsGnGPFTE0jD7w+vWVg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:55:46 +0200 Subject: [PULL 13/13] tests/9pfs: add local Tunlinkat hard link test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=ee01926a11b1f9bffcd6cdec0961dd9d1882da71@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 07:46:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_24_48=1.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Greg Kurz Message-Id: <9bec33a7d8f006ef8f80517985d0d6ac48650d53.1603285620.git.qemu_oss@crudebyte.com> Signed-off-by: Christian Schoenebeck --- 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);