From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604310926; cv=none; d=zohomail.com; s=zohoarc; b=nIR6mLFJoBcd3IiC1c7+JYlNGmRFvhhjX0as1VNpJ83112m0vcQ4N5NrB/Gj3IXC3i0d4WSUqtz7h7M7kw8NLUxOqRRwNd8NrruyUvs9MNwk1BmtuuT18ktMyBvSs7ICLRCycOZfVYCVajoLj/xZ5JsDkOVpAJvZPqxHkYSQMD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604310926; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=qnTnQy0Xa8xQsWTotjLWOzYssCe4FirszozZZ3yzRxU=; b=EpCq53/TzbwPTrkaWrnZwjcvJsmalgzSKneg4U8q/z2UwUT8K67Gpkb/tdI+w4xWblDYHtP1xRAmK0V5TkBO9OY4YfevlG2Gfo27ZtBbO+r/0P4MTIiqZjGPsCDscpuslVF+oqg/1f29VFDHvI5PpX/lN+JUU/krDA8c+RGdnBw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160431092637552.61481727471505; Mon, 2 Nov 2020 01:55:26 -0800 (PST) Received: from localhost ([::1]:41468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWYf-0007LN-9G for importer@patchew.org; Mon, 02 Nov 2020 04:55:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <8db193c4108e09996923a4d716b51fc98efb7f3a@lizzy.crudebyte.com>) id 1kZWTD-0001W4-2Q for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:49:47 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:60689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <8db193c4108e09996923a4d716b51fc98efb7f3a@lizzy.crudebyte.com>) id 1kZWTB-0006Zo-FL for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:49:46 -0500 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=qnTnQy0Xa8xQsWTotjLWOzYssCe4FirszozZZ3yzRxU=; b=U3aZv fSDPmOLIhwk7P213qMHgGj2PFnwe21hxvBPwZ8lIEZBSfSCPbTyLPQp1CRkOsIPkcrOLP89D2pGRu vh+47QYITqQhZDxPmnGms+za6odk6lUVvcaxsycbB9ghe32MMBDB3UzDyr00ngAZ+rs4heSsH0/qs g8yMifPcQqXL9cP90jZlxfM6AJGXLf1HcYESelwKirsRkPpMlH+DDN//F+lbgtsf1rrpwwtG7Ukjb 54DJW3U6DvJvptBwQ14o9GUOd5ufHxlIjBOSEKd8xc8PlB9+t6qRMHpr4w/WAbxvpJMK7oo3SDd0W eqfQEM4Er0eE0YviiY9haxqRk8Dvg==; Message-Id: <8db193c4108e09996923a4d716b51fc98efb7f3a.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 1 Nov 2020 15:25:14 +0100 Subject: [PULL v3 01/17] tests/9pfs: make create/remove test dir public To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=8db193c4108e09996923a4d716b51fc98efb7f3a@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Make functions create_local_test_dir() and remove_local_test_dir() public. They're going to be used in the next patch. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p.c | 10 ++++------ tests/qtest/libqos/virtio-9p.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index d43647b3b7..2736e9ae2a 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -39,8 +39,7 @@ static void init_local_test_path(void) g_free(pwd); } =20 -/* Creates the directory for the 9pfs 'local' filesystem driver to access.= */ -static void create_local_test_dir(void) +void virtio_9p_create_local_test_dir(void) { struct stat st; =20 @@ -53,8 +52,7 @@ static void create_local_test_dir(void) g_assert((st.st_mode & S_IFMT) =3D=3D S_IFDIR); } =20 -/* Deletes directory previously created by create_local_test_dir(). */ -static void remove_local_test_dir(void) +void virtio_9p_remove_local_test_dir(void) { g_assert(local_test_path !=3D NULL); char *cmd =3D g_strdup_printf("rm -r '%s'\n", local_test_path); @@ -248,8 +246,8 @@ static void virtio_9p_register_nodes(void) =20 /* make sure test dir for the 'local' tests exists and is clean */ init_local_test_path(); - remove_local_test_dir(); - create_local_test_dir(); + virtio_9p_remove_local_test_dir(); + virtio_9p_create_local_test_dir(); =20 QPCIAddress addr =3D { .devfn =3D QPCI_DEVFN(4, 0), diff --git a/tests/qtest/libqos/virtio-9p.h b/tests/qtest/libqos/virtio-9p.h index 19a4d97454..480727120e 100644 --- a/tests/qtest/libqos/virtio-9p.h +++ b/tests/qtest/libqos/virtio-9p.h @@ -44,6 +44,16 @@ struct QVirtio9PDevice { QVirtio9P v9p; }; =20 +/** + * Creates the directory for the 9pfs 'local' filesystem driver to access. + */ +void virtio_9p_create_local_test_dir(void); + +/** + * Deletes directory previously created by virtio_9p_create_local_test_dir= (). + */ +void virtio_9p_remove_local_test_dir(void); + /** * Prepares QEMU command line for 9pfs tests using the 'local' fs driver. */ --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311152; cv=none; d=zohomail.com; s=zohoarc; b=E5/642ziR2W/QyMf91ndL9zVHTpw68nzrgzb1CTthf3R1UojgokF/ThccUJZF220YL2znv7r6Uk+niPNo0OHg0ds4eHG4ieCMtsl4IEFLTNDVK5BcDDR35/Dhe2U81IaIb82tbajAkGvbWxk3XaygWylhP2WoHOnAU26s5dwTOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311152; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=tO675tDFEeFMR7lltQjZleg7qUOrV75TbEgjX8683Fk=; b=VcMbY06abwK19qVLnukSf2PwD16M8ffXejxeGjltNiTOdUMhnEc0m4+RW//6Ta1dr+VTeY+vpEuNLVCXOtaFLo/lwFocXo+l2TOPFQ8RcvVYYbXhMLpILNEro49az4iz1oDgWgV62Xiz79tmIxIcHwXVJc1hHh5YXuv7BQ7sIz0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311152156167.19161555975847; Mon, 2 Nov 2020 01:59:12 -0800 (PST) Received: from localhost ([::1]:55406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWcJ-0004c9-11 for importer@patchew.org; Mon, 02 Nov 2020 04:59:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <136b7af22774a6f0fb44c9c1b8c088b52e2e92ed@lizzy.crudebyte.com>) id 1kZWTL-0001sw-NS for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:49:55 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:58301) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <136b7af22774a6f0fb44c9c1b8c088b52e2e92ed@lizzy.crudebyte.com>) id 1kZWTJ-0006cm-V8 for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:49:55 -0500 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=tO675tDFEeFMR7lltQjZleg7qUOrV75TbEgjX8683Fk=; b=i+LNF 9yp3r/ZqfvduzDsaF4v1EjTAvW/n1nwIugLSmdxtjSH7UyKz+4VaePRv0Rg/BQu/n4eOxyK16lw9C WwqPf+NKFgGfjxeoLikIXn5olCPzIc4SkE0vDp0UCIvS354BTTfTwa8ODoZ+L4ZvxCuCvQtM93bLj CB6JZLmTeVS0ZoHmBrlLsCJAHVVnfvWnA+45Ef/rZ3MrTKKuNu7ycn1RxDOwPAkwfm9o7h5z2P3xp 0k4BbjGdTEHZOI9DOSfUfSd+rH/lBKNitsIJsXQZPeMHreaqKDOYD7sBMQx+orPjsUsESGwj28eU+ 5DV427lH3GXKlChJwv/FKzSdoX8fg==; Message-Id: <136b7af22774a6f0fb44c9c1b8c088b52e2e92ed.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 1 Nov 2020 15:37:12 +0100 Subject: [PULL v3 02/17] tests/9pfs: fix test dir for parallel tests To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=136b7af22774a6f0fb44c9c1b8c088b52e2e92ed@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. The constructor functions needs to be in virtio-9p-test.c, not in virtio-9p.c, because in the latter location it would cause all apps that link to libqos (i.e. entirely unrelated test suites) to create a 9pfs test directory as well, which would even break other test suites. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Tested-by: Greg Kurz Message-Id: <7746f42d8f557593898d3d9d8e57c46e872dfb4f.1604243521.git.qemu_o= ss@crudebyte.com> Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p.c | 14 ++++++++------ tests/qtest/virtio-9p-test.c | 12 ++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 2736e9ae2a..586e700b24 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 =3D g_get_current_dir(); - local_test_path =3D concat_path(pwd, "qtest-9p-local"); + char *template =3D concat_path(pwd, "qtest-9p-local-XXXXXX"); + local_test_path =3D mkdtemp(template); + if (!local_test_path) { + g_test_message("mkdtemp('%s') failed: %s", template, strerror(errn= o)); + } + g_assert(local_test_path); g_free(pwd); } =20 @@ -43,6 +48,8 @@ void virtio_9p_create_local_test_dir(void) { struct stat st; =20 + init_local_test_path(); + g_assert(local_test_path !=3D NULL); mkdir(local_test_path, 0777); =20 @@ -244,11 +251,6 @@ static void virtio_9p_register_nodes(void) const char *str_simple =3D "fsdev=3Dfsdev0,mount_tag=3D" MOUNT_TAG; const char *str_addr =3D "fsdev=3Dfsdev0,addr=3D04.0,mount_tag=3D" MOU= NT_TAG; =20 - /* make sure test dir for the 'local' tests exists and is clean */ - init_local_test_path(); - virtio_9p_remove_local_test_dir(); - virtio_9p_create_local_test_dir(); - QPCIAddress addr =3D { .devfn =3D QPCI_DEVFN(4, 0), }; diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index c15908f27b..6401d4f564 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1076,3 +1076,15 @@ static void register_virtio_9p_test(void) } =20 libqos_init(register_virtio_9p_test); + +static void __attribute__((constructor)) construct_9p_test(void) +{ + /* make sure test dir for the 'local' tests exists */ + virtio_9p_create_local_test_dir(); +} + +static void __attribute__((destructor)) destruct_9p_test(void) +{ + /* remove previously created test dir when test suite completed */ + virtio_9p_remove_local_test_dir(); +} --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604310904; cv=none; d=zohomail.com; s=zohoarc; b=CJyjuZb0RdKbhDEjMLwsnnlzN12SzYDd3vvP8tW2s5Nwcnx5PKfYQMpPg3epQueEY3zE6AGrhlhsXnaTgEY+TCV98XIET8Qn5ukylwrBX9DbQX4COYNdm5X+02OQAsHF3xlax78TT97PClNBrNy6Oc2nAzuIWj/yb4d+2GQ7GGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604310904; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=SG24nj4kAoQT9Jl8qWJ5ZyJy6bKq46bWP1SjB59f1c8=; b=F3jSuh8WR4t5ykiBEeQQ/dq7J4MUUbHHzU6ahSXkBk8Eez0O4VyBZPXsM34GMLrniEfd74Tz8ov8TpMIjNNqdbq4P7w+26HpCEDG0Ee1dKmBOBw7BzMp++k1TqkBuVIfO5m4PB/DjOG1qcs5WtpOGEr9AJg9SA2uS8BW8iIzkwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604310904537758.8082385171408; Mon, 2 Nov 2020 01:55:04 -0800 (PST) Received: from localhost ([::1]:39450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWYJ-0006Vn-EC for importer@patchew.org; Mon, 02 Nov 2020 04:55:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5409d8bea40289106e1005c41973382a7dfacf1c@lizzy.crudebyte.com>) id 1kZWTV-00027t-ER for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:05 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:34357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5409d8bea40289106e1005c41973382a7dfacf1c@lizzy.crudebyte.com>) id 1kZWTR-0006gI-Nf for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:02 -0500 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=SG24nj4kAoQT9Jl8qWJ5ZyJy6bKq46bWP1SjB59f1c8=; b=J44Jt 6ARddOn03uXTyyOaU095xOhPKmS8wtGtIv3TmNJW1+stmOO3V0WttR6kMlNOlxh0H7+db7TWoanes A2/NVnCV62FDAX+eQXeozytX8oaTMKNMqJIPsAMklqXUdn+zh+d/KPthhY0XPOPi4BcqFgNebKT6u y7N9il9nu4i7S549Tmw4+avjTfXd31BvXNs/PkR6IbDtUB0eDiccCrbv6RtAdgbempWNXNcdJlJ+D iioIvfsk9j8GcIMESEhB3ad2Fu1HiMkC4nkglUwPGNsKcf0Pgy208kgUVzRkgMoKrepDZwAGiLoty Q3lyhyXJA7UcyXw2xeX2gf8HyqVHA==; Message-Id: <5409d8bea40289106e1005c41973382a7dfacf1c.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 30 Oct 2020 13:07:03 +0100 Subject: [PULL v3 03/17] tests/9pfs: fix coverity error in create_local_test_dir() To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=5409d8bea40289106e1005c41973382a7dfacf1c@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 !=3D 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) =3D=3D 0); 52 /* ... and is actually a directory */ 53 g_assert((st.st_mode & S_IFMT) =3D=3D 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 Reviewed-by: Greg Kurz Message-Id: <03f68c7ec08064e20f43797f4eb4305ad21e1e8e.1604061839.git.qemu_o= ss@crudebyte.com> Signed-off-by: Christian Schoenebeck --- 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 586e700b24..3671043108 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -47,11 +47,16 @@ static void init_local_test_path(void) void virtio_9p_create_local_test_dir(void) { struct stat st; + int res; =20 init_local_test_path(); =20 g_assert(local_test_path !=3D NULL); - mkdir(local_test_path, 0777); + res =3D mkdir(local_test_path, 0777); + if (res < 0) { + g_test_message("mkdir('%s') failed: %s", local_test_path, + strerror(errno)); + } =20 /* ensure test directory exists now ... */ g_assert(stat(local_test_path, &st) =3D=3D 0); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311043; cv=none; d=zohomail.com; s=zohoarc; b=JPv933ZXLM6s9BMFJKggevTRy1MLX6LltikY5m761W+1igclPEg17evrC9uErPVczkMiJzVPjgYSpyV5aDglMav5F8TuDxsn1WfNLpFcb3ymftGvbDOnxtA2Q9tee3ZJG8n11e2r4zWfmfzqrnSk4ErmEW3HMrCrEx3BmD1s0F8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311043; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=9mbFW1L9cJNMO3v79t1MYLd1hVqVwJ9dF+hqdbpIaYc=; b=QYAmheSQLEe5Yb0J4ZDm0+i8RO29pKd6luV9/j2FDcmODNHxZhu+MtTgiytDdwX2QRcxPc9aM4TX2byi+XoIsqB6tVPgjkgmx5Dk9dw4MCM6X6NVnfHxdsfb4nfKbtUt3UxoIUyQ0CtYbab0+gOBW6eZCRit7WxttuYaI70ePHo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311043769276.3857266852592; Mon, 2 Nov 2020 01:57:23 -0800 (PST) Received: from localhost ([::1]:47046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWaY-0001G8-J3 for importer@patchew.org; Mon, 02 Nov 2020 04:57:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <603cc76a60691b288947c88ad63b7b0d616f98b6@lizzy.crudebyte.com>) id 1kZWTe-0002Ea-4o for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:14 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:45525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <603cc76a60691b288947c88ad63b7b0d616f98b6@lizzy.crudebyte.com>) id 1kZWTb-0006jz-Ki for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:13 -0500 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=9mbFW1L9cJNMO3v79t1MYLd1hVqVwJ9dF+hqdbpIaYc=; b=ac/z/ JsqpqZOdo4X3sf0TyqKFMjzw06ZGX5tJroMZErIEyXepEUkcQDoZDGzvIklv9GpZMaCV7q59xLabe q7j/p81LsGSjvmP16wyG+/vamw+tvDeCugzPGtRli3/q5YvNmcVLGEq3Rc8TbaPD0hLkK2Exmg23A hX21+uQjaCJS5OHw+NGxp+c7Au3X3RdyHhrHnyUrKbMFqZyFxAJ6h+E3kuPB5BdZQec2xWX1pfaU+ ugRgDsnHcpUhy2gtuyjDL6nsWg4g64stad+qj7Gy4z8nPpSecunQ0LAJZFKIUej6UJ1aj21jKfyX4 +mVfXs4nU+z6lrZzblIkXOi/rXjQQ==; Message-Id: <603cc76a60691b288947c88ad63b7b0d616f98b6.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 30 Oct 2020 13:46:34 +0100 Subject: [PULL v3 04/17] tests/9pfs: Force removing of local 9pfs test directory To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=603cc76a60691b288947c88ad63b7b0d616f98b6@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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=ham 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz No need to get a complaint from "rm" if some path disappeared for some reason. Signed-off-by: Greg Kurz Message-Id: <160406199444.312256.8319835906008559151.stgit@bahia.lan> Signed-off-by: Christian Schoenebeck --- 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 3671043108..be91662c6f 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -67,7 +67,7 @@ void virtio_9p_create_local_test_dir(void) void virtio_9p_remove_local_test_dir(void) { g_assert(local_test_path !=3D NULL); - char *cmd =3D g_strdup_printf("rm -r '%s'\n", local_test_path); + char *cmd =3D g_strdup_printf("rm -fr '%s'\n", local_test_path); int res =3D system(cmd); if (res < 0) { /* ignore error, dummy check to prevent compiler error */ --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311157; cv=none; d=zohomail.com; s=zohoarc; b=jk3lUPMBdLbANzzRi8/dAiR0L24gDVaQKqKwskSKePRyt2ju8Ob04yXg44L1oop3St3ZzJXC1it9+K5/g2t4PRBI6OaSEcvooLf2KqlkhPZv/r6nP3H39TBEVsyaZQYVULRwuPmr4IGJQx/xwiMRE1dYn4PCLkpEVOZE/zNHSo8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311157; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=v2MmCkQpxp8yswXiOv4ce1Mq1oNqKDNZTBjXbOqIiDY=; b=mEP8ib+xCHM8kHGqiJLqle/os2rKI+BTihcZ8Nq4QkF6vjF8bnDKl2NFLa9+MbLdZZioUEm9TDJwBeMECN7mwExaxFWOk9h+ujZhlOuVhtSBsgr479MrFAJijkIN/75DlOR2jf4FFjGHjbBphFj/NPrkDljhEwAQUJ5EN7tXY6g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311157493489.40783159707837; Mon, 2 Nov 2020 01:59:17 -0800 (PST) Received: from localhost ([::1]:56000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWcO-0004qX-Dl for importer@patchew.org; Mon, 02 Nov 2020 04:59:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1c450e6efe14a7c76f4e75d7316c9fdf00e757c0@lizzy.crudebyte.com>) id 1kZWTm-0002HR-1G for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:22 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:38605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1c450e6efe14a7c76f4e75d7316c9fdf00e757c0@lizzy.crudebyte.com>) id 1kZWTk-0006mg-5z for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:21 -0500 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=v2MmCkQpxp8yswXiOv4ce1Mq1oNqKDNZTBjXbOqIiDY=; b=PoYKg CTYDqr5XdhudUiwqZLwGzodPFsQR9fSsYWiyuaEgPzAbUoDejQ6uea441OtqbDJbkTSTOZ22dFzEk Z+PnMnTF8vUOs5TNcDB2+yFPZKtvouL4CXsjYnBHm5FHLQhMHFn8SsyJhpVGpiojakg5J4ZiVyKuX MY8whGHNom5ogDjWKTNFmwzaeA6wGeOaasByourPEDXIi+zgQrzSqQM+T3MOy3aDyGDInk+/0Ufuc HOEIvKRMj4t71PVD31IsKdHoSgSJMFAdZXbaosvy5jx+5tnHNiBbtkjffMwsDdrpZQg94rzRDtff/ frAb/2fM6OMYdLtg2qcl9ZT7JElGA==; Message-Id: <1c450e6efe14a7c76f4e75d7316c9fdf00e757c0.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 18:09:14 +0200 Subject: [PULL v3 05/17] tests/9pfs: Factor out do_version() helper To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=1c450e6efe14a7c76f4e75d7316c9fdf00e757c0@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz 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 6401d4f564..92d12f5e02 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); } =20 -static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc) +static void do_version(QVirtio9P *v9p) { - QVirtio9P *v9p =3D obj; - alloc =3D t_alloc; const char *version =3D "9P2000.L"; uint16_t server_len; char *server_version; @@ -585,13 +583,19 @@ static void fs_version(void *obj, void *data, QGuestA= llocator *t_alloc) g_free(server_version); } =20 +static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc) +{ + alloc =3D t_alloc; + do_version(obj); +} + static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; alloc =3D t_alloc; P9Req *req; =20 - fs_version(v9p, NULL, t_alloc); + do_version(v9p); req =3D 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, QGues= tAllocator *t_alloc) v9fs_qid root_qid, *wqid; P9Req *req; =20 - fs_version(v9p, NULL, t_alloc); + do_version(v9p); req =3D v9fs_tattach(v9p, 0, getuid(), 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rattach(req, &root_qid); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311152; cv=none; d=zohomail.com; s=zohoarc; b=Xr1Vxv7+PhztSgvaogdRraSmgq7+x9/MgCecdoFzXSOe0O3mMrJD7d3yuy0YKjNyGg/DIkjUaduAS/ifwMwnDAgtxnDaXCPi/EjV+mUQJLPptx1diRO4oDPDlNTH0EjBoetD9NNv+4B9tnZ3R0t9XQ2kvyaQ0mAPCrYTPi7Wh2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311152; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=WMCfNs2uGPY8dPeNDE/WSVYNFrsHd3Yq7E9fSS3IzcA=; b=E6nJFjK8lAYDTANxT4lrJI3vVmrfhlUTqCwuSM64luOUPfZSh6gGTPZ6payjU126EB8h77uz+GJg0QjNFRGmCjUqDn2QJXDkQ19Hdsx4iqk5drUkEBjYwn2PNLvR5E3cvbNoqGsq1+pjO39nPzMMklkEDo1FDJQFulTwdqtPFAQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311152682144.48860246314757; Mon, 2 Nov 2020 01:59:12 -0800 (PST) Received: from localhost ([::1]:55442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWcJ-0004d4-IX for importer@patchew.org; Mon, 02 Nov 2020 04:59:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <382619eff506bd229c7ba0d5671c84b6f1a0a415@lizzy.crudebyte.com>) id 1kZWTu-0002O7-VI for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:31 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:57319) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <382619eff506bd229c7ba0d5671c84b6f1a0a415@lizzy.crudebyte.com>) id 1kZWTt-0006q1-Ne for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:30 -0500 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=WMCfNs2uGPY8dPeNDE/WSVYNFrsHd3Yq7E9fSS3IzcA=; b=MZaai wJw/REuPIBQUKXSUCA/OuIv+4h/9gdbEUv/3yiiYu0V+591dP49uCpRTVUwZmzwT0DURSkSgGIfda nRUbfqGmkhWXHXQQMUpF/kBVywiIry8++z+Oo8WM/P07wBLwqzLxF/MKRczUT7/F51tJQ+ga8V1fi 8t1T6qNDj54JAYwvDUSL34nUFyuKNO/U8Je0fi/28X7VukBWhqcH1PIM6B6V8zVCB7iTp0gWBYRT8 kcjNIxhzkCoQNH1slsAiDsQJN0N2VGNpAKk2RbO/B8eQsPENr67EM+cqONKAsEbdcRE8hFNihCy3U mOWyonrnPMR4EcLzM/k51iQbHdAtw==; Message-Id: <382619eff506bd229c7ba0d5671c84b6f1a0a415.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 18:09:27 +0200 Subject: [PULL v3 06/17] tests/9pfs: Set alloc in fs_create_dir() To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=382619eff506bd229c7ba0d5671c84b6f1a0a415@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz 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 92d12f5e02..ab59431d79 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 *dat= a, static void fs_create_dir(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; struct stat st; char *root_path =3D virtio_9p_test_path(""); char *new_dir =3D virtio_9p_test_path("01"); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311099; cv=none; d=zohomail.com; s=zohoarc; b=UlQyaM7xlYtx/DCuFghu4T+nx5WuIuKuLag+1rUtQku7+Be3C+YxDS71iMVNpcx/u2CV8/xf8WFX/DcXOVo5uZ6DGsG7UUX7DyTN6o8KWiYd1mhEQEKYUSeu1GER/70jhjxci9UBngbTN+RSof9rgNG6/5p174xNns9GkFjR0Oc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311099; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=XvvlpV7JJMEP8WWu+wvPOxEv/u5A60bGNocLFFYxiHY=; b=Pq5BIgfnQklhAQApUBTIYVoQ36KJc5pRNLWs6bofqfzvRJZEBzj85YHnrZZu3u8pWsLHA/r2wnDNce5Dz/RFl1AgNJ6a6FyPToLtWWnxpy55X6YKEru8grn1pfmIDKFFEPRmQeuYU7PMIBKRmMHa3O3RCmUs2+eS7Mxb9IxmphY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311099410452.4096100008568; Mon, 2 Nov 2020 01:58:19 -0800 (PST) Received: from localhost ([::1]:49870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWbS-0002Pe-8x for importer@patchew.org; Mon, 02 Nov 2020 04:58:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3fe4baf47be2633022ed4af71466aca6ddfc3f19@lizzy.crudebyte.com>) id 1kZWU7-0002QY-E1 for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:45 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:41507) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3fe4baf47be2633022ed4af71466aca6ddfc3f19@lizzy.crudebyte.com>) id 1kZWU0-0006se-Om for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:38 -0500 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=XvvlpV7JJMEP8WWu+wvPOxEv/u5A60bGNocLFFYxiHY=; b=JDKxg fBGY4dMTuci2dj8wxMdrJfGLQUl0rlqzlTJZXkO/P5D4qdmpVnIaYuF0wT9gSS6LARoQG1xtuQUr8 WLc828CIBGy7qlJ6lGPdRvAS3sx1dEARlhVCkoa6p2bOlcOSL3MfHk5z7Qi+ve25rBL1e7XmNOTk7 cMiy2RSqjfnhc2ZE9+IE3lrbr0gitzKnNFl1X/JY+EYvoHyhBRGfKXT41zuYJXSg/3C8Hds4jrB4I c+5PWOSS+Q07QyvZverk7TNtRUY4jJsN0rs2yrMl82jQLvKhngwXDktReo1+FkbHO0pYYNfwhZMxf BSavH4/VpBH9EhUEJCIGzDIAp1E9A==; Message-Id: <3fe4baf47be2633022ed4af71466aca6ddfc3f19.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 18:09:34 +0200 Subject: [PULL v3 07/17] tests/9pfs: Factor out do_attach() helper To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=3fe4baf47be2633022ed4af71466aca6ddfc3f19@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz 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 ab59431d79..9c2738885e 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, QGuestAl= locator *t_alloc) do_version(obj); } =20 -static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc) +static void do_attach(QVirtio9P *v9p) { - QVirtio9P *v9p =3D obj; - alloc =3D t_alloc; P9Req *req; =20 do_version(v9p); @@ -601,6 +599,12 @@ static void fs_attach(void *obj, void *data, QGuestAll= ocator *t_alloc) v9fs_rattach(req, NULL); } =20 +static void fs_attach(void *obj, void *data, QGuestAllocator *t_alloc) +{ + alloc =3D t_alloc; + do_attach(obj); +} + static void fs_walk(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; @@ -615,7 +619,7 @@ static void fs_walk(void *obj, void *data, QGuestAlloca= tor *t_alloc) wnames[i] =3D g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i); } =20 - fs_attach(v9p, NULL, t_alloc); + do_attach(v9p); req =3D 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, QGuestAll= ocator *t_alloc) struct V9fsDirent *entries =3D NULL; P9Req *req; =20 - fs_attach(v9p, NULL, t_alloc); + do_attach(v9p); req =3D 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, QGu= estAllocator *t_alloc, int fid; uint64_t offset; =20 - fs_attach(v9p, NULL, t_alloc); + do_attach(v9p); =20 fid =3D 1; offset =3D 0; @@ -817,7 +821,7 @@ static void fs_walk_no_slash(void *obj, void *data, QGu= estAllocator *t_alloc) P9Req *req; uint32_t err; =20 - fs_attach(v9p, NULL, t_alloc); + do_attach(v9p); req =3D 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, QGuestAlloc= ator *t_alloc) char *const wnames[] =3D { g_strdup(QTEST_V9FS_SYNTH_LOPEN_FILE) }; P9Req *req; =20 - fs_attach(v9p, NULL, t_alloc); + do_attach(v9p); req =3D 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, QGuestAlloc= ator *t_alloc) uint32_t count; P9Req *req; =20 - fs_attach(v9p, NULL, t_alloc); + do_attach(v9p); req =3D 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, QGu= estAllocator *t_alloc) uint32_t reply_len; uint8_t should_block; =20 - fs_attach(v9p, NULL, t_alloc); + do_attach(v9p); req =3D 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, QGu= estAllocator *t_alloc) uint32_t count; uint8_t should_block; =20 - fs_attach(v9p, NULL, t_alloc); + do_attach(v9p); req =3D 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, QGue= stAllocator *t_alloc) =20 g_assert(root_path !=3D NULL); =20 - fs_attach(v9p, NULL, t_alloc); + do_attach(v9p); fs_mkdir(v9p, data, t_alloc, "/", "01"); =20 /* check if created directory really exists now ... */ --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311280; cv=none; d=zohomail.com; s=zohoarc; b=YQAHDM/x/eRd+BKhQVQcRbqC11cDl4meu/cHHegNqQfESzSNlT5VEphY4kVXRGCm6SViSHBT5OVC9Rd7mHVPDKyVcoi0qvDROqqrF76TTVzLm7en8deD/lEh1WWKLTzXaEf+e5c5o+IvehdWcgNDYhJgO/NFTOtiYW7oIprpWtk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311280; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=65TkmXkZ0RhsQI38MI0QUdjZ3VQJ9H7GcpKnYh/cT1Q=; b=GRCs7Q+FiHCgVZxyg7wCgnnm3H6GK0oaAJeXrz30BC+eTzq/y582tP9OeMHBT66wan/wGruAGUkNxKjJVbTlJ9G2BE6nIUHNwNcEKxBhJnlmlxk8zaTZjGC2c5PgVg+k5bGZECSjzzsOKs6ealG506XRPm7TevV8CvIwkrMt06A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311280643281.22945379893827; Mon, 2 Nov 2020 02:01:20 -0800 (PST) Received: from localhost ([::1]:35650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWeL-00085e-Tn for importer@patchew.org; Mon, 02 Nov 2020 05:01:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1d98613d7cd488528bc08260185c03ee078c1347@lizzy.crudebyte.com>) id 1kZWUB-0002T7-AE for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:52 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:47435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1d98613d7cd488528bc08260185c03ee078c1347@lizzy.crudebyte.com>) id 1kZWU7-0006vY-TK for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:46 -0500 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=65TkmXkZ0RhsQI38MI0QUdjZ3VQJ9H7GcpKnYh/cT1Q=; b=RFEON ZRVtMMPiigRsuW1OBIA8rHLRjuZsuqmI0neusojE7effhLmk43zs8azjrxdEOK/j1xC+FKCKVAt6u AtHfrDiTxEep41WpcIWr3aRg1mitkLHvO1iPoH3VpW+sk1Q7tOFGncd+IxHl9K3slpqxkVLZ/AhKI qMJ7/mQL5/AzEzPOKXRenjCyx6JQX5zBrHaJJmRlNG20CpVOoDLql8oCrb2UCSzMh4vklzZ8SMwwD RpsGO9qly+V1PUhg5rZCtfIKsatGYN2LOkR9v/CutnJcX2pB1RPZk1KnoGXntjbttFmIOwBEcw0sD XaicHYyweI+Kv1yBobpC47MX6/RsA==; Message-Id: <1d98613d7cd488528bc08260185c03ee078c1347.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 18:09:20 +0200 Subject: [PULL v3 08/17] tests/9pfs: Turn fs_readdir_split() into a helper To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=1d98613d7cd488528bc08260185c03ee078c1347@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz 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 9c2738885e..734b4bcb7a 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, QGuestAl= locator *t_alloc) } =20 /* readdir test where overall request is split over several messages */ -static void fs_readdir_split(void *obj, void *data, QGuestAllocator *t_all= oc, - uint32_t count) +static void do_readdir_split(QVirtio9P *v9p, uint32_t count) { - QVirtio9P *v9p =3D obj; - alloc =3D t_alloc; char *const wnames[] =3D { 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, QGuestAl= locator *t_alloc, static void fs_readdir_split_128(void *obj, void *data, QGuestAllocator *t_alloc) { - fs_readdir_split(obj, data, t_alloc, 128); + alloc =3D t_alloc; + do_readdir_split(obj, 128); } =20 static void fs_readdir_split_256(void *obj, void *data, QGuestAllocator *t_alloc) { - fs_readdir_split(obj, data, t_alloc, 256); + alloc =3D t_alloc; + do_readdir_split(obj, 256); } =20 static void fs_readdir_split_512(void *obj, void *data, QGuestAllocator *t_alloc) { - fs_readdir_split(obj, data, t_alloc, 512); + alloc =3D t_alloc; + do_readdir_split(obj, 512); } =20 =20 --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311299; cv=none; d=zohomail.com; s=zohoarc; b=Hl1nHxZPb++iCW/SyGu+b+JJcZP3hugD5eUtMme9djHgY6t1ofILK6BCamDbjET4iwpl1iZFlhl7f6kKgccByjfVQ7RcwqKxtaqA5z9e6UP4hT0R3KzXsw1pFtZhhh0lOFsK1uEcJtUrsj1kZzYFObhvwUYDW1fx2oxpWxzFCxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311299; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=aD1UXjgSwBFRvYSpDfMbtCtrntAFlYlhy4F3gNLqgXU=; b=EpBOU2XUhuy/CICamUnj1gMEq7xoITJVplvXtNi+XRKG78CCXc8OCVXHSGSiEcRnn9zHildgw1Xl21/o4c7873PkVG6mh5siFaOuYGWpZY0AQB9vUcVknMvF1U0xF2awlYeQZdV8EaoLBzHBu+z/KbhfX56j94cIuJji6I4PYLg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311299514299.93911356268234; Mon, 2 Nov 2020 02:01:39 -0800 (PST) Received: from localhost ([::1]:36084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWef-0008GD-Ej for importer@patchew.org; Mon, 02 Nov 2020 05:01:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZWUI-0002Vo-3Y for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:54 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:38597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZWUG-0006yf-9C for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:50:53 -0500 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=aD1UXjgSwBFRvYSpDfMbtCtrntAFlYlhy4F3gNLqgXU=; b=F7Zh1 pNTkkfwGbUNB/q1ViEVRkeIANP9hdZBbZ3PQB3p3vOrv4RgMV4g8BhOct7106lytftOzHDgksbwV+ LDfvbtk1P12sGWvDFcuMxCHY3Atipa25AN9C3cdJKWYQjRa0Pg475ewHh4gEoD2e/0t5roVswbJot W/yBjRs1HfFLxf74eVUosjQ3SoI0SeOExttZ+ij8mPeEZZ2hM1jxmoM3KG37hmmaYEBulVzzDfJ4D EF7m8tlfnt+sfCSDYUEIVKpSiHBC3RvXKuxZrxRyKFpEYRjAzvJRke9gPl8lBQECZWpql7pQkKiVL Jzn/wa820/poHUBWZtP407tYQ+Osg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 18:09:41 +0200 Subject: [PULL v3 09/17] tests/9pfs: Turn fs_mkdir() into a helper To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=c1934f630c131ec487d21949c9b53e1e3f2b8bcb@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz 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 734b4bcb7a..6f8c46a645 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, QG= uestAllocator *t_alloc) g_free(wnames[0]); } =20 -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 =3D obj; - alloc =3D t_alloc; char **wnames; char *const name =3D g_strdup(cname); P9Req *req; @@ -1031,7 +1028,7 @@ static void fs_create_dir(void *obj, void *data, QGue= stAllocator *t_alloc) g_assert(root_path !=3D NULL); =20 do_attach(v9p); - fs_mkdir(v9p, data, t_alloc, "/", "01"); + do_mkdir(v9p, "/", "01"); =20 /* check if created directory really exists now ... */ g_assert(stat(new_dir, &st) =3D=3D 0); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311618; cv=none; d=zohomail.com; s=zohoarc; b=M0MXvRlPyNFoHJG6XD+V7FOKQtY4cBe+xNjnnt7BRgAaEqSV8a/C+Nn1OZiriV1edza5O7I6nrJUmGnvo9p8URYNBrFb7UoOD1axeCyCInyEEBuY5bY+NNqwwgilLV69wJECTzku1YKjInucHIdF7jLJvQdT9gljpSfYn2OsmvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311618; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=o2+jeSzz7qQD6sWpHqHX3A+P88gUlYGMB32yoKShenw=; b=QDw2ddp1CDVoQPgad9qO38Od1N9s5HfVnXX55HbsymHCLhh6gB6OQfecMmkV7hl/dMz3A4suLOY4RAXRo30QpbsMlcNeomD4ymAOlk+scmNMVy6DcqNxbDLLlapPjeBbh9CoxuJlp0wNv3KDmb6WGQLu4qSr9bbNc2pZdOThDhc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311618298862.0351976901527; Mon, 2 Nov 2020 02:06:58 -0800 (PST) Received: from localhost ([::1]:53902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWjp-00076x-4K for importer@patchew.org; Mon, 02 Nov 2020 05:06:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <20018805224c69c78ac25d6b361eded8c8095c75@lizzy.crudebyte.com>) id 1kZWUP-0002lp-6X for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:01 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:38551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <20018805224c69c78ac25d6b361eded8c8095c75@lizzy.crudebyte.com>) id 1kZWUN-00071h-KW for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:00 -0500 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=o2+jeSzz7qQD6sWpHqHX3A+P88gUlYGMB32yoKShenw=; b=ISpLr 5V+AdE7twrx79js5KBvcxJ/QOay9vEl68KL694ujS2wBYvecjRNJJFOdRzrwx1lMNdXFNXXWcAWLi /dXB42dV/WHDVtKNyxAWYavDD/JDzJi5lLWHKSEiIaISY+lEKOxSQAkFDW8Y+aAq1qT67aDzgy5G9 GuOl8H/dlLrUIpljc0SN7YfeGrf54BtWsD07YtjKyAG276W9Co9vQj8zgm1pgwHqEnJ6JYnoHeNB8 rqAjq+O+4IEI5Ps7iZVMRi+4p7y7niLSCM/MYbuRpgAopilNg9jUw4VJgUXtSermJl74FXI6djplR PX53WMTk2QIXh8CNoaLcHC3Yod/rQ==; Message-Id: <20018805224c69c78ac25d6b361eded8c8095c75.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:06:53 +0200 Subject: [PULL v3 10/17] tests/9pfs: simplify do_mkdir() To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=20018805224c69c78ac25d6b361eded8c8095c75@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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_o= ss@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 6f8c46a645..db37e31b32 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); } =20 +/* 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 =3D genfid(); + + int nwnames =3D split(path, "/", &wnames); + + req =3D 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 =3D t_alloc; @@ -974,23 +991,17 @@ static void fs_flush_ignored(void *obj, void *data, Q= GuestAllocator *t_alloc) =20 static void do_mkdir(QVirtio9P *v9p, const char *path, const char *cname) { - char **wnames; char *const name =3D g_strdup(cname); + uint32_t fid; P9Req *req; - const uint32_t fid =3D genfid(); =20 - int nwnames =3D split(path, "/", &wnames); - - req =3D v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0); - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, NULL, NULL); + fid =3D do_walk(v9p, path); =20 req =3D v9fs_tmkdir(v9p, fid, name, 0750, 0, 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rmkdir(req, NULL); =20 g_free(name); - split_free(&wnames); } =20 static void fs_readdir_split_128(void *obj, void *data, --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311280; cv=none; d=zohomail.com; s=zohoarc; b=MYsHf5sadu1XubYeN+h3tq+xinhiIxqmH4deiX8QV3oJwDvbh2o2J6ZawxevTbl41Z8YpFiawkbEX1GQnKsFPdboAVW6sPGwPqMlsc8hJ8tBbloElnbxlDE5MP3OG3w14K/lp7UfcaV7et1q2acUbBxUMLP/kYm8Tj+FFEDl2lk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311280; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Bc3/R2yv/N+NzR29DMwVvKgof09nkVZ73zOW1DTxNxg=; b=PJ4Y2SHkp8bGxco/HIrhyqy/3Eewb9NFqCm8erVnocG17Y1/1rXqoLRzj6syT9m9ra/f/aZ30HFULhUfpHKaUzmTtPN3CEwp/bWXlc9ZWX8boBKHjUCXyiK95luxZDLaQDnSCC8TLx7JH1SxKM2UX/S/s3iCPROASEX+uhDEA0k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311280863201.1225501275976; Mon, 2 Nov 2020 02:01:20 -0800 (PST) Received: from localhost ([::1]:35644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWeL-00085X-Tc for importer@patchew.org; Mon, 02 Nov 2020 05:01:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZWUW-0002xX-UL for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:08 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:36813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZWUV-00074b-C7 for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:08 -0500 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=Bc3/R2yv/N+NzR29DMwVvKgof09nkVZ73zOW1DTxNxg=; b=IP6vN 6kpIqZteuxjps65wtcGCCEo1WLP8TLmbxdFA8Yyym93PkAy4yStha56D8C2g0Opo6nC7ZwQ5dfZOc bo9EFyiv+VcH7zjZXXgrMIm5PWaktSwq+GGxI8aK6rwUbfQJCEaokYesQJqiBioMRZAixqi56BvXM R2bnXSZCKK1UPpHt4hj3NKQpd/LDX0DrVBuMDLJlWBl6RmP3z7TZrESpNU2gQrNjHtvx41YdXESm+ 0leTw2mpofCEOPcAM7B6Cl2hlnrUQ4y0zJ8QY6I5v7cK9SeIsdujbS2ltFDCxJcN3dM0dAvrWoakg hlzxolxxtqvH6dqBuT+syOi9ymYVw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:17:01 +0200 Subject: [PULL v3 11/17] tests/9pfs: add local Tunlinkat directory test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=b37d62d6de08bea1f57e51a4b99938f7994a84d6@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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_o= ss@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 db37e31b32..6c8842351f 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 =3D=3D P9_RLOPEN ? "RLOPEN" : id =3D=3D P9_RWRITE ? "RWRITE" : id =3D=3D P9_RMKDIR ? "RMKDIR" : + id =3D=3D P9_RUNLINKAT ? "RUNLINKAT" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "READDIR" : ""; @@ -693,6 +694,33 @@ static void v9fs_rmkdir(P9Req *req, v9fs_qid *qid) v9fs_req_free(req); } =20 +/* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */ +static P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *n= ame, + uint32_t flags, uint16_t tag) +{ + P9Req *req; + + uint32_t body_size =3D 4 + 4; + uint16_t string_size =3D v9fs_string_size(name); + + g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); + body_size +=3D string_size; + + req =3D 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 *pat= h, const char *cname) g_free(name); } =20 +static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rp= ath, + uint32_t flags) +{ + char *const name =3D g_strdup(rpath); + uint32_t fid; + P9Req *req; + + fid =3D do_walk(v9p, atpath); + + req =3D 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, QGu= estAllocator *t_alloc) g_free(root_path); } =20 +static void fs_unlinkat_dir(void *obj, void *data, QGuestAllocator *t_allo= c) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *root_path =3D virtio_9p_test_path(""); + char *new_dir =3D virtio_9p_test_path("02"); + + g_assert(root_path !=3D NULL); + + do_attach(v9p); + do_mkdir(v9p, "/", "02"); + + /* check if created directory really exists now ... */ + g_assert(stat(new_dir, &st) =3D=3D 0); + /* ... and is actually a directory */ + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFDIR); + + do_unlinkat(v9p, "/", "02", AT_REMOVEDIR); + /* directory should be gone now */ + g_assert(stat(new_dir, &st) !=3D 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=3Dmapped-xattr= "); @@ -1090,6 +1160,7 @@ static void register_virtio_9p_test(void) opts.before =3D 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= ); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311754; cv=none; d=zohomail.com; s=zohoarc; b=B+5JOFKRZsj8PF1psAH2czutJ0EdZalpk9nC+kivUn36OuYKExktU/KlpmbX3DIEufaIa4cYXk0/THaNODolTGXaK8BWUvu36rIsBrcS/rY+rTf8likJPGFsJ/p2dYqNMC/p8h3Qp4KHV4Z8ueL1h32Dl7A8s1roePKOABGxS+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311754; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=J86RKAQ7eygBXyIn/1sq2uDHzo1tpshAphst7k5xMSQ=; b=aKKS7KgzjLT0DC0nxDmhSedkYcMCzaoUZQ4CnUjRGBZcL2YYiiYQ4zjuTqXNd+Aaa1/NzbXOi0P2iK7iCqEhf6s5hwDJOQmLCJA1SHJENaksGWJUezpqnwF0hO7z8Dtp8zLf4uBAyhS1sl6bPSWwqRpWRHf/6mFm9p0hZls9aRg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311754819497.04113511976084; Mon, 2 Nov 2020 02:09:14 -0800 (PST) Received: from localhost ([::1]:34220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWm1-00028W-JA for importer@patchew.org; Mon, 02 Nov 2020 05:09:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZWUi-0003Tg-VY for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:20 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:41707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZWUh-00077c-CX for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:20 -0500 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=J86RKAQ7eygBXyIn/1sq2uDHzo1tpshAphst7k5xMSQ=; b=ZgSv/ SbjgqQ93uQ0YB1Pf5kXhHI1nAILYHEut9J767EXCfQaLheDY+OLyXB3kABu8C1G8N4livn+PMh5m8 4tsnswxvyu8BA2+DGFd5hJiFXPflmouwyzkdLIQui+EBE9OrKtRWc9YhJbwrrrCAhrp67MTGIp1uQ oa5fYhg8ZCfZm2Jr4TPlM+Fc/y52sjQX3ZAhGOJKh3jAaesmdniX8HwDq99jZS47bv2IEVfNmjUPH HIlnBHgRyDC1D3Ds9Ykhec3c/5jW0agYdWlTbpCPH2W7qTKZ/KNvfaOOe0uK8zX5B7YHV1SbwIbTD uWez/uMRLszo5rQL5OxnxfGkdX/pg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:25:33 +0200 Subject: [PULL v3 12/17] tests/9pfs: add local Tlcreate test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=b09dbfdd5177ccd49117b6e6ce6712db99714ee0@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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_o= ss@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 6c8842351f..c685db27d9 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 =3D=3D P9_RLOPEN ? "RLOPEN" : id =3D=3D P9_RWRITE ? "RWRITE" : id =3D=3D P9_RMKDIR ? "RMKDIR" : + id =3D=3D P9_RLCREATE ? "RLCREATE" : id =3D=3D P9_RUNLINKAT ? "RUNLINKAT" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "READDIR" : @@ -694,6 +695,44 @@ static void v9fs_rmkdir(P9Req *req, v9fs_qid *qid) v9fs_req_free(req); } =20 +/* 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 =3D 4 + 4 + 4 + 4; + uint16_t string_size =3D v9fs_string_size(name); + + g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); + body_size +=3D string_size; + + req =3D 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 *n= ame, uint32_t flags, uint16_t tag) @@ -1032,6 +1071,24 @@ static void do_mkdir(QVirtio9P *v9p, const char *pat= h, const char *cname) g_free(name); } =20 +/* 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 =3D g_strdup(cname); + uint32_t fid; + P9Req *req; + + fid =3D do_walk(v9p, path); + + req =3D 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 *rp= ath, uint32_t flags) { @@ -1120,6 +1177,25 @@ static void fs_unlinkat_dir(void *obj, void *data, Q= GuestAllocator *t_alloc) g_free(root_path); } =20 +static void fs_create_file(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *new_file =3D 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) =3D=3D 0); + /* ... and is a regular file */ + g_assert((st.st_mode & S_IFMT) =3D=3D 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=3Dmapped-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); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311443; cv=none; d=zohomail.com; s=zohoarc; b=bqESdO3pca49R5zqkg/ttd3PZkeAkuktZrfGKmJUkbRrXV97REr4ypIKJHzXwR1GA5Vegv4N7u4RIeMMtDhUjbugFePB3gOlTKuM75GEUJ/hX9XLY30ny+aRlkfORlAeYNsV0wbo5blNoSOebbbyfiD+6agHiWVZxJfkAATdVu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311443; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=7g6F1Ukgu57xGK4R3WuXTx4Ntw5GtnOnSXJXaKwMoTw=; b=mMeJQhoiv5ndXjukj1LIocTMm+oSAsqnow3lbcoUCLMGAfy4/oCTz4/Q3SbLeLsCsjgcZSNKoG+oiGP4dW0fMmH1ev43Cc37k+BMCopNxCXiG6FC63/CZq48ZONKRsgwSOa12JoTrqfmrgJuJKZFH4Ixqf4cHENHaJFqm7rKvtE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311443235784.1835696428402; Mon, 2 Nov 2020 02:04:03 -0800 (PST) Received: from localhost ([::1]:44476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWh0-0003E3-2t for importer@patchew.org; Mon, 02 Nov 2020 05:04:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <472c18b8bf20f111b02abc403407efd88b6281d7@lizzy.crudebyte.com>) id 1kZWUp-0003ZY-5i for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:27 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:35155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <472c18b8bf20f111b02abc403407efd88b6281d7@lizzy.crudebyte.com>) id 1kZWUl-0007DM-1z for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:26 -0500 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=7g6F1Ukgu57xGK4R3WuXTx4Ntw5GtnOnSXJXaKwMoTw=; b=FNH8u 0l3W/maBlBi/GkNampWLkTOhUArzo46dwlrPJhUbZqfPfyxDpKh7R8BrPmufW25/7cPFjCUhSDARy T0F7RB1MOLmxJx4+tieKWNHDXH0rhIg0kFEP1iW5AsOzj041/Xm7+6BDshlyv6mNJ0LQ1wOsJNYOv hQl5qsBJumMVnslctuc/0XifpAVszCcWf6UD0yiqdlg3/KdPKJecqZREhBK1aKssnZDh/sEyMSMt3 WzxJLgHCrM27ygQZFvJHr04AR+HwhjyyXx9G+26E1VlFuFlXyGHbNlIBrY8vi01rTaSh8Eb4FvDNQ rkIRkEPoji+eeJHQGMJoxRpL6z24A==; Message-Id: <472c18b8bf20f111b02abc403407efd88b6281d7.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:28:37 +0200 Subject: [PULL v3 13/17] tests/9pfs: add local Tunlinkat file test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=472c18b8bf20f111b02abc403407efd88b6281d7@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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_o= ss@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 c685db27d9..52ecdfab7a 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, QG= uestAllocator *t_alloc) g_free(new_file); } =20 +static void fs_unlinkat_file(void *obj, void *data, QGuestAllocator *t_all= oc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *new_file =3D 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) =3D=3D 0); + /* ... and is a regular file */ + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_unlinkat(v9p, "04", "doa_file", 0); + /* file should be gone now */ + g_assert(stat(new_file, &st) !=3D 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=3Dmapped-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, &op= ts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311610; cv=none; d=zohomail.com; s=zohoarc; b=bA0JH1jdl19wl1NW0WZLmSLnBk+u4a1HUWVTk+/02aBl5JRe0asS2QTasqZfzAaXS+FE78rKEZB9BKYwkVcIqB+LyXtg6mUbHDqr0xZGRfLEt3ZLRcdY4EMGsnHQVE3ha6+7U+qJaZmFQbsDDrULZx0G8FNZpoLtGs6NDF7wFCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311610; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=UOIDmTkc6DwTYHlMlMlbXZMmXxWD39EpkVgVSQNZvDk=; b=UNoDklKOhTT+bcFzWM1g6BwygKzV7PXaPTa0/23PCTl4WGb/rL719sf5/A7Vn4xk+o+w5IKaQ/KNYIG6nrtiiyR6sruhjhH34dTBS27g2ES4xdBB7N/ZjPq5DyZpQ1Mogfkj4mY3jUp8CytBsf6T+CHMFXb6suOuUViSuIwAU9k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311610162666.6392262047503; Mon, 2 Nov 2020 02:06:50 -0800 (PST) Received: from localhost ([::1]:52968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWjg-0006jS-Uf for importer@patchew.org; Mon, 02 Nov 2020 05:06:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <59ff563db1cfb9f3a20075b452d1564585bbc66a@lizzy.crudebyte.com>) id 1kZWUv-0003pz-6g for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:33 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:56767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <59ff563db1cfb9f3a20075b452d1564585bbc66a@lizzy.crudebyte.com>) id 1kZWUt-0007H5-LB for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:32 -0500 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=UOIDmTkc6DwTYHlMlMlbXZMmXxWD39EpkVgVSQNZvDk=; b=UKVkC Uus4RAo4NiCL2N0iHGxSzogsxjfTHS3+CuVZ25Lv0AcrgTCauJG+qYiDZApeHEJ728W1c5OoPcTly 03Wc85fmmd2QI0QctgxIMhzwqrv4uFsn1gK7WPxt+GYF6QvOklAtAyLnVE5ONXo03Xp7CNpfAQb/N iBs+7J1Y1/u/mXqePUadCJDSd6/EWRaCrIS1aZYsTf/Yu9eWc199Xk0JdGc1Y7fCOM02vwjOcLaiz ziyyZ4vL4iDoJyC4T5tgqQPSK6pyTfFYqDGeEjNJXk5oI+mo7iZrZFZZ3XNJPrqMsyuDLz46K3fgD h9kqR6fA33B8MhF4TkcQn1zSc/38w==; Message-Id: <59ff563db1cfb9f3a20075b452d1564585bbc66a.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:33:34 +0200 Subject: [PULL v3 14/17] tests/9pfs: add local Tsymlink test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=59ff563db1cfb9f3a20075b452d1564585bbc66a@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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_o= ss@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 52ecdfab7a..d61e7d244d 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 =3D=3D P9_RWRITE ? "RWRITE" : id =3D=3D P9_RMKDIR ? "RMKDIR" : id =3D=3D P9_RLCREATE ? "RLCREATE" : + id =3D=3D P9_RSYMLINK ? "RSYMLINK" : id =3D=3D P9_RUNLINKAT ? "RUNLINKAT" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "READDIR" : @@ -733,6 +734,39 @@ static void v9fs_rlcreate(P9Req *req, v9fs_qid *qid, u= int32_t *iounit) v9fs_req_free(req); } =20 +/* 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 =3D 4 + 4; + uint16_t string_size =3D v9fs_string_size(name) + v9fs_string_size(sym= tgt); + + g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); + body_size +=3D string_size; + + req =3D 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 *n= ame, uint32_t flags, uint16_t tag) @@ -1089,6 +1123,25 @@ static uint32_t do_lcreate(QVirtio9P *v9p, const cha= r *path, return fid; } =20 +/* 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 =3D g_strdup(clink); + char *const dst =3D g_strdup(to); + uint32_t fid; + P9Req *req; + + fid =3D do_walk(v9p, path); + + req =3D 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 *rp= ath, uint32_t flags) { @@ -1219,6 +1272,29 @@ static void fs_unlinkat_file(void *obj, void *data, = QGuestAllocator *t_alloc) g_free(new_file); } =20 +static void fs_symlink_file(void *obj, void *data, QGuestAllocator *t_allo= c) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *real_file =3D virtio_9p_test_path("05/real_file"); + char *symlink_file =3D 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) =3D=3D 0); + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_symlink(v9p, "05", "symlink_file", "real_file"); + + /* check if created link exists now */ + g_assert(stat(symlink_file, &st) =3D=3D 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=3Dmapped-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, &op= ts); + qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts= ); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311439; cv=none; d=zohomail.com; s=zohoarc; b=l1wSXpbm1pWxqFiuPxun24411uFdRI1g7lxVnbHZBRamzNan1cA1iboekLWicL4D5GWFHph+Tos5ajMfhoMayXp4rqUCaAIz4jpWBYjIpSaOX2wWiUyWCIokpJYl7iXDhp7Pe0oA/VDfVhxfVy0gITHFvQXlSIylQLEN3dnOiNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311439; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=1eWTmw6rgsM4fWFXaDo3RDUQrv3Oj1xC7+iJ3Crw4bQ=; b=PBi8I3E/f+1oj8ZF5NvrCFGvRj9xKIBAhKBTCgROtXV+77N84oENk/EAJAtMuiLMMU5SMDUL5VzwC+lCpQQf8UhMO9RRut4te0EJwjDpuYQmeJkZYBBZ0WJvrSVf9hD+WbpWzUQL4fcMVukrKhJtZLebutTYetxMd0xFV2L/PFg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311439389183.83340542772157; Mon, 2 Nov 2020 02:03:59 -0800 (PST) Received: from localhost ([::1]:44058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWgw-00033p-0h for importer@patchew.org; Mon, 02 Nov 2020 05:03:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5b28ab8bda41768acb6be05c8949a0bc8e6b9cd8@lizzy.crudebyte.com>) id 1kZWV6-0004BN-VC for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:44 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:48135) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5b28ab8bda41768acb6be05c8949a0bc8e6b9cd8@lizzy.crudebyte.com>) id 1kZWV5-0007JH-FY for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:44 -0500 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=1eWTmw6rgsM4fWFXaDo3RDUQrv3Oj1xC7+iJ3Crw4bQ=; b=WuJ6R 2MBqhJQBDUH87ygFygGw/aB2YaQZimH+J1mH7G+c/tzcQKvIINpvU2Q8SEsbCkKFIj+GoLaT7biKA /KphnKoJxfZ0AzO02duAz7uLMkukzG7AxsUQiCpSKuy0K80doLvuwxBv1yx0t334vZCl/PJ9rLarT vBQuYsWUH5pM3kiOFtm1H2NHs/YnxI51s1koO3sPoRvPzP8fq3JA5BtPbpnAfjuTPwZnH1yjrKCCH ycxRBDMibxfThDbDN0dH0ROKWAreUBjXEeAim6oLmvE2xXReU7eWkbuYNjx3tw1MHXHyNTJCeG6OL eojrIHhobNZ9v6iLCgaYC8kH5p9iA==; Message-Id: <5b28ab8bda41768acb6be05c8949a0bc8e6b9cd8.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:36:23 +0200 Subject: [PULL v3 15/17] tests/9pfs: add local Tunlinkat symlink test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=5b28ab8bda41768acb6be05c8949a0bc8e6b9cd8@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 d61e7d244d..fb08db1dde 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, Q= GuestAllocator *t_alloc) g_free(real_file); } =20 +static void fs_unlinkat_symlink(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *real_file =3D virtio_9p_test_path("06/real_file"); + char *symlink_file =3D 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) =3D=3D 0); + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_symlink(v9p, "06", "symlink_file", "real_file"); + g_assert(stat(symlink_file, &st) =3D=3D 0); + + do_unlinkat(v9p, "06", "symlink_file", 0); + /* symlink should be gone now */ + g_assert(stat(symlink_file, &st) !=3D 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=3Dmapped-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, &op= ts); qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts= ); + qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlin= k, + &opts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311733; cv=none; d=zohomail.com; s=zohoarc; b=dfvsFzVGqvNGIODOj3ME3wRfxoiMGEvWyU87eNVTaNL0Pg8YB+o7+1sTJEgxjpN02egnGI0cZKiyezJRppHJsS75Okjrqikszi3qgiIYiRb3zAYBG1YXV/OhDw0qi/4ylPyQWS8h33lLksxx35RnpDQ7dLrOvDyi6xuQq+Laz4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311733; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=lo2KI2AWYKdrOD6mLHG400wpN8Ne2yZgB1HB/23XBwc=; b=eSRriW7yHg3xW8xgy/7iRnAW95+RaKq7AwoicDm3SN+tjuiIhwz3geQI1EmFmfK7oFkGsWpl8jvrU7iQ2ScWHI1neKx2fL4GcpD1YO1oHSVBG+YpkNqUL/BMZOTtiU5e+Dull8hlqGeVrtWxLzuK+L180YJe9m5vWJQZlj7XgCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311733973754.9353790441013; Mon, 2 Nov 2020 02:08:53 -0800 (PST) Received: from localhost ([::1]:33356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWlg-0001mL-TB for importer@patchew.org; Mon, 02 Nov 2020 05:08:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <64e3d4032296aae1adf80e6638b2c4b1987a70d0@lizzy.crudebyte.com>) id 1kZWVA-0004Lf-Mg for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:48 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:50627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <64e3d4032296aae1adf80e6638b2c4b1987a70d0@lizzy.crudebyte.com>) id 1kZWV9-0007Kh-1H for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:48 -0500 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=lo2KI2AWYKdrOD6mLHG400wpN8Ne2yZgB1HB/23XBwc=; b=OJ3iu z5MqMH4E7XL3aSUO9UWNj0Uzglu+mvkmuQ/zCxTU4RzmndTJ1ZcEBq/iulIjENRWVua1HcUSdirrp lZ8e8sDk/YBf5cL9l1PzXHynKt/t6iT8GyIdZbmGw+SIFtMLYw5bOIw6piNm0bqyy8wQhkTrK9d7R oK9+jN1BP1609dC427N7HOGlWr7dF5yJG7c/YUvGPHEurM9vBkncin56cFQZVhthcgTwbG7mXTCgk iucdZC4+kirlVSkEDjBEFb3fxZK/maPCgKwmh4/os6OXhXGBHTwHePw9bgwfZtO5y1WwYpiTTho4F l21zz6xPJVJ6BuPwIaXti2FcIyx0w==; Message-Id: <64e3d4032296aae1adf80e6638b2c4b1987a70d0.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:51:09 +0200 Subject: [PULL v3 16/17] tests/9pfs: add local Tlink test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=64e3d4032296aae1adf80e6638b2c4b1987a70d0@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 fb08db1dde..35499e74ed 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 =3D=3D P9_RMKDIR ? "RMKDIR" : id =3D=3D P9_RLCREATE ? "RLCREATE" : id =3D=3D P9_RSYMLINK ? "RSYMLINK" : + id =3D=3D P9_RLINK ? "RLINK" : id =3D=3D P9_RUNLINKAT ? "RUNLINKAT" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "READDIR" : @@ -767,6 +768,33 @@ static void v9fs_rsymlink(P9Req *req, v9fs_qid *qid) v9fs_req_free(req); } =20 +/* 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 =3D 4 + 4; + uint16_t string_size =3D v9fs_string_size(name); + + g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); + body_size +=3D string_size; + + req =3D 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 *n= ame, uint32_t flags, uint16_t tag) @@ -1142,6 +1170,21 @@ static void do_symlink(QVirtio9P *v9p, const char *p= ath, const char *clink, g_free(name); } =20 +/* create a hard link named @a clink in directory @a path pointing to @a t= o */ +static void do_hardlink(QVirtio9P *v9p, const char *path, const char *clin= k, + const char *to) +{ + uint32_t dfid, fid; + P9Req *req; + + dfid =3D do_walk(v9p, path); + fid =3D do_walk(v9p, to); + + req =3D 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 *rp= ath, uint32_t flags) { @@ -1321,6 +1364,33 @@ static void fs_unlinkat_symlink(void *obj, void *dat= a, g_free(real_file); } =20 +static void fs_hardlink_file(void *obj, void *data, QGuestAllocator *t_all= oc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st_real, st_link; + char *real_file =3D virtio_9p_test_path("07/real_file"); + char *hardlink_file =3D 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) =3D=3D 0); + g_assert((st_real.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_hardlink(v9p, "07", "hardlink_file", "07/real_file"); + + /* check if link exists now ... */ + g_assert(stat(hardlink_file, &st_link) =3D=3D 0); + /* ... and it's a hard link, right? */ + g_assert((st_link.st_mode & S_IFMT) =3D=3D S_IFREG); + g_assert(st_link.st_dev =3D=3D st_real.st_dev); + g_assert(st_link.st_ino =3D=3D 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=3Dmapped-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_symlin= k, &opts); + qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &op= ts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Fri May 17 07:07:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1604311854; cv=none; d=zohomail.com; s=zohoarc; b=EwHAIF8p85QFZuoWhHBB18qJ4SpENWdlDJ03V4QEC/ci2RPVOr7sSL6qr0WZ2eksc1nVjw++XRHPtjqE0DNghs1ByiQOjmQgB9Ndsa7i2zdjRJetvEOGq6lv9BXWxOQxqcjS1eE2sCZTRBQBv7pl0ZujYCydLbQYp4vOhfwvw/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604311854; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=YWmXVtZVZRtkS+BYg5kf2HB49/4Oet8HpRKUq5fnvUg=; b=SsVGN7jR21GoF2EhPGBlaGex7hUtJkf5SODJYdjKO+v/noJzl3uyBiGgTty3jo22ZS5DI5LJK7RBEX2R4qAtmD4G6/925i5E7L+Knl2URublvrAAKvSSF04ldfQuQqUEAyNYsmo1rIC1aMUhZJNIPZzrOCq2sq/IfxqzxIpFnKs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604311854213863.3694665074847; Mon, 2 Nov 2020 02:10:54 -0800 (PST) Received: from localhost ([::1]:40698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWnd-0004lw-0L for importer@patchew.org; Mon, 02 Nov 2020 05:10:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4d0746e2135f56c59c6e61ef42d700b7139065b4@lizzy.crudebyte.com>) id 1kZWVI-0004TQ-T3 for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:58 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:41791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4d0746e2135f56c59c6e61ef42d700b7139065b4@lizzy.crudebyte.com>) id 1kZWVF-0007Lm-AG for qemu-devel@nongnu.org; Mon, 02 Nov 2020 04:51:56 -0500 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=YWmXVtZVZRtkS+BYg5kf2HB49/4Oet8HpRKUq5fnvUg=; b=Q0mBt HTSm7smeZAp+uIDUFjwM695GTXUfmAOOQ3qk5PMTmxriUfL5yDQWeVqWBZeIMZDPhal7MtJoqQEXM 6V7H1pu0hAlhStP6qJNGu80AzbxCPnSyrBbVcMS7CZBhx9um2jCnSlXyCISNKCV5U83hFDBefFBSM 2Ipg86IazFWIoKukrd3B4/WAdxIDlno5hjuLmxFNb2Wp4NBLgQpJvZEimH0mcmB9Gt4N3KeBqs0+X 7BtGAM/REvDOOv97VaGbGjnIdL+nM0YZpdQq9ZwxIUByJe4riATZ0m7qPMWBEz09JCSCp5DD7u/5M rUJH9goPuAzasew11HVQqIk4F8Z8Q==; Message-Id: <4d0746e2135f56c59c6e61ef42d700b7139065b4.1604309512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:55:46 +0200 Subject: [PULL v3 17/17] tests/9pfs: add local Tunlinkat hard link test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=4d0746e2135f56c59c6e61ef42d700b7139065b4@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 04:48:35 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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_o= ss@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 35499e74ed..21e340fa5f 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); } =20 +static void fs_unlinkat_hardlink(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st_real, st_link; + char *real_file =3D virtio_9p_test_path("08/real_file"); + char *hardlink_file =3D 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) =3D=3D 0); + g_assert((st_real.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_hardlink(v9p, "08", "hardlink_file", "08/real_file"); + g_assert(stat(hardlink_file, &st_link) =3D=3D 0); + + do_unlinkat(v9p, "08", "hardlink_file", 0); + /* symlink should be gone now */ + g_assert(stat(hardlink_file, &st_link) !=3D 0); + /* and old file should still exist */ + g_assert(stat(real_file, &st_real) =3D=3D 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=3Dmapped-xattr= "); @@ -1438,6 +1466,8 @@ static void register_virtio_9p_test(void) qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlin= k, &opts); qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &op= ts); + qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardl= ink, + &opts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1