From nobody Wed Feb 11 08:38:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517334107868961.5659231719791; Tue, 30 Jan 2018 09:41:47 -0800 (PST) Received: from localhost ([::1]:51102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egZuk-0000vM-QA for importer@patchew.org; Tue, 30 Jan 2018 12:41:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egZt0-0008Jw-VS for qemu-devel@nongnu.org; Tue, 30 Jan 2018 12:40:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egZsv-0004IT-UO for qemu-devel@nongnu.org; Tue, 30 Jan 2018 12:39:58 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59732) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1egZsv-0004EG-JW for qemu-devel@nongnu.org; Tue, 30 Jan 2018 12:39:53 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0UHdkQx113103 for ; Tue, 30 Jan 2018 12:39:50 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ftt7wsv8q-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 30 Jan 2018 12:39:49 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 30 Jan 2018 17:39:43 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 30 Jan 2018 17:39:41 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0UHdfY244892288; Tue, 30 Jan 2018 17:39:41 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2312CAE04D; Tue, 30 Jan 2018 17:31:07 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11807AE045; Tue, 30 Jan 2018 17:31:07 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 30 Jan 2018 17:31:07 +0000 (GMT) Received: from bahia.lab.toulouse-stg.fr.ibm.com (bahia.lab.toulouse-stg.fr.ibm.com [9.101.4.41]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 9CBB02204A5; Tue, 30 Jan 2018 18:39:40 +0100 (CET) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 30 Jan 2018 18:39:30 +0100 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180130173935.5172-1-groug@kaod.org> References: <20180130173935.5172-1-groug@kaod.org> X-TM-AS-GCONF: 00 x-cbid: 18013017-0020-0000-0000-000003F07135 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18013017-0021-0000-0000-00004282D309 Message-Id: <20180130173935.5172-6-groug@kaod.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801300218 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 05/10] tests: virtio-9p: use the synth backend X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The purpose of virtio-9p-test is to test the virtio-9p device, especially the 9p server state machine. We don't really care what fsdev backend we're using. Moreover, if we want to be able to test the flush request or a device reset with in-flights I/O, it is close to impossible to achieve with a physical backend because we cannot ask it reliably to put an I/O on hold at a specific point in time. Fortunately, we can do that with the synthetic backend, which allows to register callbacks on read/write accesses to a specific file. This will be used by a later patch to test the 9P flush request. The walk request test is converted to using the synth backend. Signed-off-by: Greg Kurz Reviewed-by: Stefan Hajnoczi --- hw/9pfs/9p-synth.c | 16 ++++++++++++++++ hw/9pfs/9p-synth.h | 4 ++++ tests/virtio-9p-test.c | 22 ++++++---------------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 8f255e91c00f..dcbd320da17a 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -19,6 +19,7 @@ #include "qemu/rcu.h" #include "qemu/rcu_queue.h" #include "qemu/cutils.h" +#include "sysemu/qtest.h" =20 /* Root node for synth file system */ static V9fsSynthNode synth_root =3D { @@ -527,6 +528,21 @@ static int synth_init(FsContext *ctx, Error **errp) =20 /* Mark the subsystem is ready for use */ synth_fs =3D 1; + + if (qtest_enabled()) { + V9fsSynthNode *node =3D NULL; + int i, ret; + + /* Directory hierarchy for WALK test */ + for (i =3D 0; i < P9_MAXWELEM; i++) { + char *name =3D g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i); + + ret =3D qemu_v9fs_synth_mkdir(node, 0700, name, &node); + assert(!ret); + g_free(name); + } + } + return 0; } =20 diff --git a/hw/9pfs/9p-synth.h b/hw/9pfs/9p-synth.h index 49c2fc7b274e..876b4ef58288 100644 --- a/hw/9pfs/9p-synth.h +++ b/hw/9pfs/9p-synth.h @@ -49,4 +49,8 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int m= ode, const char *name, v9fs_synth_read read, v9fs_synth_write write, void *arg); =20 +/* qtest stuff */ + +#define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d" + #endif diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c index cb086315a36e..652198156731 100644 --- a/tests/virtio-9p-test.c +++ b/tests/virtio-9p-test.c @@ -17,6 +17,7 @@ #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_pci.h" #include "hw/9pfs/9p.h" +#include "hw/9pfs/9p-synth.h" =20 #define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000) =20 @@ -26,23 +27,19 @@ typedef struct { QVirtioDevice *dev; QOSState *qs; QVirtQueue *vq; - char *test_share; } QVirtIO9P; =20 static QVirtIO9P *qvirtio_9p_start(const char *driver) { const char *arch =3D qtest_get_arch(); - const char *cmd =3D "-fsdev local,id=3Dfsdev0,security_model=3Dnone,pa= th=3D%s " + const char *cmd =3D "-fsdev synth,id=3Dfsdev0 " "-device %s,fsdev=3Dfsdev0,mount_tag=3D%s"; QVirtIO9P *v9p =3D g_new0(QVirtIO9P, 1); =20 - v9p->test_share =3D g_strdup("/tmp/qtest.XXXXXX"); - g_assert_nonnull(mkdtemp(v9p->test_share)); - if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - v9p->qs =3D qtest_pc_boot(cmd, v9p->test_share, driver, mount_tag); + v9p->qs =3D qtest_pc_boot(cmd, driver, mount_tag); } else if (strcmp(arch, "ppc64") =3D=3D 0) { - v9p->qs =3D qtest_spapr_boot(cmd, v9p->test_share, driver, mount_t= ag); + v9p->qs =3D qtest_spapr_boot(cmd, driver, mount_tag); } else { g_printerr("virtio-9p tests are only available on x86 or ppc64\n"); exit(EXIT_FAILURE); @@ -54,8 +51,6 @@ static QVirtIO9P *qvirtio_9p_start(const char *driver) static void qvirtio_9p_stop(QVirtIO9P *v9p) { qtest_shutdown(v9p->qs); - rmdir(v9p->test_share); - g_free(v9p->test_share); g_free(v9p); } =20 @@ -422,17 +417,14 @@ static void fs_attach(QVirtIO9P *v9p) =20 static void fs_walk(QVirtIO9P *v9p) { - char *wnames[P9_MAXWELEM], *paths[P9_MAXWELEM]; - char *last_path =3D v9p->test_share; + char *wnames[P9_MAXWELEM]; uint16_t nwqid; v9fs_qid *wqid; int i; P9Req *req; =20 for (i =3D 0; i < P9_MAXWELEM; i++) { - wnames[i] =3D g_strdup_printf("%s%d", __func__, i); - last_path =3D paths[i] =3D g_strdup_printf("%s/%s", last_path, wna= mes[i]); - g_assert(!mkdir(paths[i], 0700)); + wnames[i] =3D g_strdup_printf(QTEST_V9FS_SYNTH_WALK_FILE, i); } =20 fs_attach(v9p); @@ -443,8 +435,6 @@ static void fs_walk(QVirtIO9P *v9p) g_assert_cmpint(nwqid, =3D=3D, P9_MAXWELEM); =20 for (i =3D 0; i < P9_MAXWELEM; i++) { - rmdir(paths[P9_MAXWELEM - i - 1]); - g_free(paths[P9_MAXWELEM - i - 1]); g_free(wnames[i]); } =20 --=20 2.13.6