From nobody Sun May 19 16:31:29 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=1601659653; cv=none; d=zohomail.com; s=zohoarc; b=OiAv0I4NK5H7ezFGr5CPD8Y7Qt4lDvQGna9PYx6lcrOmyiSUVV0lchLiQ8kMaKM1HPwp043HV89GouPLXQVeYCGOF8ASRbS7gxUxSJHH89ULnyZGhto971p39IZSm9x09B6TROXVBP70Hf9au/S5pfVNGdAWy2Hzw+oeMAZWz1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659653; 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=GZyTCxmYrj69i/SVm0Mbovz8XYMGA8mLuCNmRo809OE=; b=PtQG3o2tTYiTVLqOShFEfq/Vw0dLpmyXxf3XpDp2aWO40fQfIE3Ml57vfxYrk8Iz0jYgdjC4eln3pXedJzclBMTZ1xv1YM1IU8Nft0H4fBmJek+FSMMPJKdtED6lb7fOg0yVL8/1l8MRBdI5sgVPSXZbKX1D6ZxNDQ1YMbXQwI0= 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 1601659653248764.8681465055467; Fri, 2 Oct 2020 10:27:33 -0700 (PDT) Received: from localhost ([::1]:43894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOqC-0002Pf-13 for importer@patchew.org; Fri, 02 Oct 2020 13:27:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOOoe-00019e-RG for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:25:56 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:40183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOOoa-0001rN-SK for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:25:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=GZyTCxmYrj69i/SVm0Mbovz8XYMGA8mLuCNmRo809OE=; b=mNWVS REuodvON1cmo9L03oC+zdia9miGu066IyLQbYS+oIWkmJTmdHOHxDhPX+B4AQ7bM5ja8SIHO1orO1 suOGeuodB6tiNRyiERlPXKe3X8MIUTzdxo34duraKriyZ92CMCoimlQ9wOXQAuyxLn5cEwAyF0qTp xid3PsB6WHcGywpy3mNWxtsifDxn7qsOeYy0LR+6b7iz6hJ8bzcD0ig8QUEBY4yJ8G8UQiNPSBn+i LlheEdxfqKnri3qv6ci9XEZewmhJ9dL7IqKaTB/WVyQHWYswlY0E+s+lpz3s4xLLcH4BjRaFLx+kN AuA+Ea6GE3TIf4EA0z/1Tzzh4WuVA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 01/11] libqos/qgraph: add qemu_name to QOSGraphNode To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=a5bcdb10d5494f6f8a693150291d074d867ff308@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" Add new member variable 'qemu_name' to struct QOSGraphNode. This new member may be optionally set in case a different name for the node (which must always be a unique name) vs. its actually associated QEMU (QMP) device name is required. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/qgraph.c | 1 + tests/qtest/libqos/qgraph_internal.h | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c index fc49cfa879..e42f3eaafa 100644 --- a/tests/qtest/libqos/qgraph.c +++ b/tests/qtest/libqos/qgraph.c @@ -153,6 +153,7 @@ static QOSGraphNode *create_node(const char *name, QOSN= odeType type) static void destroy_node(void *val) { QOSGraphNode *node =3D val; + g_free(node->qemu_name); g_free(node->command_line); g_free(node); } diff --git a/tests/qtest/libqos/qgraph_internal.h b/tests/qtest/libqos/qgra= ph_internal.h index 968fa69450..974985dce9 100644 --- a/tests/qtest/libqos/qgraph_internal.h +++ b/tests/qtest/libqos/qgraph_internal.h @@ -56,6 +56,7 @@ struct QOSGraphNode { bool available; /* set by QEMU via QMP, used during graph walk */ bool visited; /* used during graph walk */ char *name; /* used to identify the node */ + char *qemu_name; /* optional: see qos_node_create_driver_named() */ char *command_line; /* used to start QEMU at test execution */ union { struct { --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601659488; cv=none; d=zohomail.com; s=zohoarc; b=Mzh1Xav5IUaO3YLqAl/e/PWfhwEeGvK+r0lXB4tIiydGqFSI0e4Ac7B5WnLuZhEG1H6zVOTiVRksQTPdYkTiwWVOSKVGYfuqLAwUAZ//0hffTPRCLWlqYszwXETJp6be6PQhtHswC3albSz4159cfqMIukGAHUMmTTtroxTC8WE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659488; 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=baW8d6Af0E+xPV7T/Dn1dnU1Plbu8QKi0pyhr5ugh2A=; b=aRvYDD0KTQ7JuNX7FhAfr8O3Lb9+q+v65QCrWguoPQcdkXCIFS4jyEdu62Qqy29cjID0gc0fXUUsoGEg2XCwZmDDAf9T8t06q7YmduPC7exSr6HmjLN/5HQsmHJZEcpXNinNJDl1EoHUhfNX/CrggmBofWbUYNHEOsHF6mxVn9I= 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 1601659488586810.0394995150782; Fri, 2 Oct 2020 10:24:48 -0700 (PDT) Received: from localhost ([::1]:35928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOnX-0007PM-AP for importer@patchew.org; Fri, 02 Oct 2020 13:24:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4c3ab37f109719bda36c1165dcd1aae6be2de68b@lizzy.crudebyte.com>) id 1kOOjU-0003DJ-G8 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:20:37 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:35459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4c3ab37f109719bda36c1165dcd1aae6be2de68b@lizzy.crudebyte.com>) id 1kOOjR-0001J1-Q2 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:20:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=baW8d6Af0E+xPV7T/Dn1dnU1Plbu8QKi0pyhr5ugh2A=; b=QXEb6 Ghv1c3A9hFqREkjlrUVqRe1+i8ZWO0raMNBLmQOTGkslch7n2f1d0CpzSmF1bOzNi5MJOWLqUE36n 7zU1AzM8zUvpNBXMfhSyAErUgmP4oXbWZuriMa08ScelNQ/MhnQi6JOBHR2ZeEtlIordqRGDplTkb 6k1Tosmbj0EeIZwL24MKywaxpAK/qK/Ue7IZZNp/mj90iIAYrl3M05Qd6zXSkXDCvneYBdjbC+qSx xInPa1Dq5Zec6FAQsuaMv9UbRAQzEJL1wOYZMzYr7SfTrH10eauFptTwrSTHiBjO9jivjiQTzPx9F ilHHGa2iZL8IMO2+6rjNT4ws9g0+g==; Message-Id: <4c3ab37f109719bda36c1165dcd1aae6be2de68b.1601655308.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 02/11] libqos/qgraph: add qos_node_create_driver_named() To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=4c3ab37f109719bda36c1165dcd1aae6be2de68b@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" So far the qos subsystem of the qtest framework had the limitation that only one instance of the same official QEMU (QMP) driver name could be created for qtests. That's because a) the created qos node names must always be unique, b) the node name must match the official QEMU driver name being instantiated and c) all nodes are in a global space shared by all tests. This patch removes this limitation by introducing a new function qos_node_create_driver_named() which allows test case authors to specify a node name being different from the actual associated QEMU driver name. It fills the new 'qemu_name' field of QOSGraphNode for that purpose. Adjust build_driver_cmd_line() and qos_graph_node_set_availability() to correctly deal with either accessing node name vs. node's qemu_name correctly. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/qgraph.c | 53 ++++++++++++++++++++++++++++++++++--- tests/qtest/libqos/qgraph.h | 16 +++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c index e42f3eaafa..61faf6b27d 100644 --- a/tests/qtest/libqos/qgraph.c +++ b/tests/qtest/libqos/qgraph.c @@ -287,7 +287,8 @@ static void build_machine_cmd_line(QOSGraphNode *node, = const char *args) */ static void build_driver_cmd_line(QOSGraphNode *node) { - node->command_line =3D g_strconcat(" -device ", node->name, NULL); + const char *name =3D node->qemu_name ?: node->name; + node->command_line =3D g_strconcat(" -device ", name, NULL); } =20 /* qos_print_cb(): callback prints all path found by the DFS algorithm. */ @@ -632,6 +633,15 @@ void qos_node_create_driver(const char *name, QOSCreat= eDriverFunc function) node->u.driver.constructor =3D function; } =20 +void qos_node_create_driver_named(const char *name, const char *qemu_name, + QOSCreateDriverFunc function) +{ + QOSGraphNode *node =3D create_node(name, QNODE_DRIVER); + node->qemu_name =3D g_strdup(qemu_name); + build_driver_cmd_line(node); + node->u.driver.constructor =3D function; +} + void qos_node_contains(const char *container, const char *contained, QOSGraphEdgeOptions *opts, ...) { @@ -664,7 +674,7 @@ void qos_node_consumes(const char *consumer, const char= *interface, add_edge(interface, consumer, QEDGE_CONSUMED_BY, opts); } =20 -void qos_graph_node_set_availability(const char *node, bool av) +static void qos_graph_node_set_availability_explicit(const char *node, boo= l av) { QOSGraphEdgeList *elist; QOSGraphNode *n =3D search_node(node); @@ -679,9 +689,46 @@ void qos_graph_node_set_availability(const char *node,= bool av) } QSLIST_FOREACH_SAFE(e, elist, edge_list, next) { if (e->type =3D=3D QEDGE_CONTAINS || e->type =3D=3D QEDGE_PRODUCES= ) { - qos_graph_node_set_availability(e->dest, av); + qos_graph_node_set_availability_explicit(e->dest, av); + } + } +} + +/* + * Behaves as qos_graph_node_set_availability_explicit(), except that the + * former always matches by node name only, whereas this function matches = both + * by node name and node's optional 'qemu_name' field. + */ +void qos_graph_node_set_availability(const char *node, bool av) +{ + GList *l; + QOSGraphEdgeList *elist; + QOSGraphEdge *e, *next; + QOSGraphNode *n; + GList *keys =3D g_hash_table_get_keys(node_table); + + for (l =3D keys; l !=3D NULL; l =3D l->next) { + const gchar *key =3D l->data; + n =3D g_hash_table_lookup(node_table, key); + /* + * node's 'qemu_name' is set if there is more than one device with + * the same QEMU (QMP) device name + */ + const char *node_name =3D n->qemu_name ?: n->name; + if (g_strcmp0(node_name, node) =3D=3D 0) { + n->available =3D av; + elist =3D get_edgelist(n->name); + if (elist) { + QSLIST_FOREACH_SAFE(e, elist, edge_list, next) { + if (e->type =3D=3D QEDGE_CONTAINS || e->type =3D=3D QE= DGE_PRODUCES) + { + qos_graph_node_set_availability_explicit(e->dest, = av); + } + } + } } } + g_list_free(keys); } =20 void qos_graph_foreach_test_path(QOSTestCallback fn) diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h index 5f63d352ca..f472949f68 100644 --- a/tests/qtest/libqos/qgraph.h +++ b/tests/qtest/libqos/qgraph.h @@ -452,6 +452,22 @@ void qos_node_create_machine_args(const char *name, */ void qos_node_create_driver(const char *name, QOSCreateDriverFunc function= ); =20 +/** + * Behaves as qos_node_create_driver() with the extension of allowing to + * specify a different node name vs. associated QEMU device name. + * + * Use this function instead of qos_node_create_driver() if you need to cr= eate + * several instances of the same QEMU device. You are free to choose a cus= tom + * node name, however the chosen node name must always be unique. + * + * @param name: custom, unique name of the node to be created + * @param qemu_name: actual (official) QEMU driver name the node shall be + * associated with + * @param function: driver constructor + */ +void qos_node_create_driver_named(const char *name, const char *qemu_name, + QOSCreateDriverFunc function); + /** * qos_node_contains(): creates one or more edges of type QEDGE_CONTAINS * and adds them to the edge list mapped to @container in the --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601659607; cv=none; d=zohomail.com; s=zohoarc; b=RsF0q3sScSuT4zZp7++3FEtkMzSGK/A7OXXzpS5qIVqUC3Tm7KNWQF/CiBeQs8m8TKYkomFbsbZRq5UTh9kH3G2FdRVrj/+in4fUVim0jp5nIGD87cc/WegI6OlMy8oBplTQat6Is+eOLYViW1mwPhKEICMd6wsEyXILGXJJ+6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659607; 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=MOuYzYgoUjX0F+dL6MaCElse45kBDIj3nDYLLbxQJyQ=; b=Ru9iY3kUv2OI8eTM16LjDkGskw1+hWxTsD8pPIBfFkdv3QWIfO3zF6/LnKqv0eXTJ4d5OBoZ7RAtxGC/467UFXbFnPJjfH1N2cohTvqGFZvkI8jHsa5Wfhy5S/ZpuJ/x5gMWj5KjhP9dtE37P4gV/xREU70/lqIMABfqBEgD2p8= 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 1601659607121592.1539461004893; Fri, 2 Oct 2020 10:26:47 -0700 (PDT) Received: from localhost ([::1]:41372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOpR-0001LT-RE for importer@patchew.org; Fri, 02 Oct 2020 13:26:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOOkW-0004Wh-Ev for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:21:43 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:55943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOOkU-0001UN-4l for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:21:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=MOuYzYgoUjX0F+dL6MaCElse45kBDIj3nDYLLbxQJyQ=; b=I8igD XgOsJvooQEGOL2m1nGZfMDRIzLUjw3ZAFkBylrlY4hVYe/4YEbWzowymbXe4pTyHXDF8iqn0taPaV NhGWtCAMmkTxRVd0cYrX4knVdYghwfFo+d40cDt+JIb4Z4rnqTWbjOnLrolP/s09SUCm0QNuaW80v k5NyXM1ni+FW5W7deplBrnTMuLsg3TkNuHwoFGRZGlxqg4mhJhO6fIV7ai/KJNn9HbKRVGmfNkOZ6 5ZSB4fwNuEFHQALEWQVR6wGanrMDuyPe50ot6CJT5Gj9jWmi4D6YvkQcStpaf+CP+edHhupqngqon wQfBceErrEMP3irWWGJ+u62no33Ag==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 03/11] libqos/qgraph: add qos_dump_graph() To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=d63b603a48ebbc92bab3eddc161a4c7fcc2fa3f3@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" This new function is purely for debugging purposes. It prints the current qos graph to stdout and allows to identify problems in the created qos graph e.g. when writing new qos tests. Coloured output is used to mark available nodes in green colour, whereas unavailable nodes are marked in red colour. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/qgraph.c | 54 +++++++++++++++++++++++++++++++++++++ tests/qtest/libqos/qgraph.h | 20 ++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c index 61faf6b27d..e70635750e 100644 --- a/tests/qtest/libqos/qgraph.c +++ b/tests/qtest/libqos/qgraph.c @@ -805,3 +805,57 @@ void qos_delete_cmd_line(const char *name) node->command_line =3D NULL; } } + +#define RED(txt) ( \ + "\033[0;91m" txt \ + "\033[0m" \ +) + +#define GREEN(txt) ( \ + "\033[0;92m" txt \ + "\033[0m" \ +) + +void qos_dump_graph(void) +{ + GList *keys; + GList *l; + QOSGraphEdgeList *list; + QOSGraphEdge *e, *next; + QOSGraphNode *dest_node, *node; + + printf("ALL QGRAPH EDGES: {\n"); + keys =3D g_hash_table_get_keys(edge_table); + for (l =3D keys; l !=3D NULL; l =3D l->next) { + const gchar *key =3D l->data; + printf("\t src=3D'%s'\n", key); + list =3D get_edgelist(key); + QSLIST_FOREACH_SAFE(e, list, edge_list, next) { + dest_node =3D g_hash_table_lookup(node_table, e->dest); + printf("\t\t|-> dest=3D'%s' type=3D%d (node=3D%p)", + e->dest, e->type, dest_node); + if (!dest_node) { + printf(RED(" <------- ERROR !")); + } + printf("\n"); + } + } + g_list_free(keys); + printf("}\n"); + + printf("ALL QGRAPH NODES: {\n"); + keys =3D g_hash_table_get_keys(node_table); + for (l =3D keys; l !=3D NULL; l =3D l->next) { + const gchar *key =3D l->data; + node =3D g_hash_table_lookup(node_table, key); + printf("\t name=3D'%s' ", key); + if (node->qemu_name) { + printf("qemu_name=3D'%s' ", node->qemu_name); + } + printf("type=3D%d cmd_line=3D'%s' [%s]\n", + node->type, node->command_line, + node->available ? GREEN("available") : RED("UNAVAILBLE")); + } + g_list_free(keys); + printf("}\n"); +} diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h index f472949f68..07a32535f1 100644 --- a/tests/qtest/libqos/qgraph.h +++ b/tests/qtest/libqos/qgraph.h @@ -586,5 +586,25 @@ QOSGraphObject *qos_machine_new(QOSGraphNode *node, QT= estState *qts); QOSGraphObject *qos_driver_new(QOSGraphNode *node, QOSGraphObject *parent, QGuestAllocator *alloc, void *arg); =20 +/** + * Just for debugging purpose: prints all currently existing nodes and + * edges to stdout. + * + * All qtests add themselves to the overall qos graph by calling qgraph + * functions that add device nodes and edges between the individual graph + * nodes for tests. As the actual graph is assmbled at runtime by the qos + * subsystem, it is sometimes not obvious how the overall graph looks like. + * E.g. when writing new tests it may happen that those new tests are simp= ly + * ignored by the qtest framework. + * + * This function allows to identify problems in the created qgraph. Keep in + * mind: only tests with a path down from the actual test case node (leaf)= up + * to the graph's root node are actually executed by the qtest framework. = And + * the qtest framework uses QMP to automatically check which QEMU drivers = are + * actually currently available, and accordingly qos marks certain pathes = as + * 'unavailable' in such cases (e.g. when QEMU was compiled without suppor= t for + * a certain feature). + */ +void qos_dump_graph(void); =20 #endif --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601659463; cv=none; d=zohomail.com; s=zohoarc; b=ZuIIqqAZQdQpfNSfBfEqdHGAz+xqKsr3HgJ9ugKLrY318VX+GNLrtrDTaLVgKcD+938KM/nGcyMIDfBrL//kx0Agc/TnTdJIxSobw7AEV0l8ZwT7kDKvXaST65Pa8Y17JScSTEb9tbhWncSVUAkOlPQ7Esm+vpgwIqxp1/4Ug6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659463; 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=Cyyld5a/6X2z/GHtUILwJZBN75BuasEc9WQ7betFIyk=; b=Cy1rTmBAwxls/vHpuzgQ2XuIDqqPcxaJYdT0E+ogoGbDZPXrv19/cVQ41NAH4RxVxdIDwakcfoo6ps9DLV+2MdtlwVNYPgEkLW9tQOwqQk2D0mA6UkLxIgvdLA/2IgLKQ8sqTSQYhLWTi/uzkzZHBhaUfV9/FdOWKPMJanFVVIk= 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 1601659463115191.28279528477935; Fri, 2 Oct 2020 10:24:23 -0700 (PDT) Received: from localhost ([::1]:34788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOn7-0006wn-OK for importer@patchew.org; Fri, 02 Oct 2020 13:24:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5e3a48aa672d7fcfdc48dead3d031cdf457e413c@lizzy.crudebyte.com>) id 1kOOhR-0000n7-Ax for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:18:29 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:44445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5e3a48aa672d7fcfdc48dead3d031cdf457e413c@lizzy.crudebyte.com>) id 1kOOhP-0001A4-NP for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:18:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=Cyyld5a/6X2z/GHtUILwJZBN75BuasEc9WQ7betFIyk=; b=fVGRu F8mLg6wk66MEjg1YtbyuklNbwWyB1DjxeRBpOVxLidrnKFqari8u8sklAW+AGmWXLebA2b9R6Jsqy RjZ58goeQAtgGl3gijGwa8YPUcWkhB7w8IZ10gPht3Gqsk609nuqQErFVpuXufCj/R1iZW04DiPGG hRzwTljNs7qRRLa60zCAGHXwa+yZL5hPtWbhq0gAzqv+qfyyiypLRzw4GPxu7ldPB5XkL/kKQKbBB KBNoUPBNFHlkAGmTVKHSfVvjE6Vp8fDBdEcItCf/a3SDFkp1Dh070dI0luJoCXiuJl9NehxV+vmJh RkpJ43iivk7tHE3CVe1rpNPQcLoyQ==; Message-Id: <5e3a48aa672d7fcfdc48dead3d031cdf457e413c.1601655308.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 04/11] tests/qtest/qos-test: dump qos graph if verbose To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=5e3a48aa672d7fcfdc48dead3d031cdf457e413c@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" If qtests were run in verbose mode (i.e. if --verbose CL argument was provided) then dump the generated qos graph (all nodes and edges, along with their current individual availability status) to stdout. See API doc comment on function qos_dump_graph() for details. Signed-off-by: Christian Schoenebeck --- tests/qtest/qos-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index 8fdf87b183..d98ef78613 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -322,6 +322,9 @@ int main(int argc, char **argv) qos_set_machines_devices_available(); =20 qos_graph_foreach_test_path(walk_path); + if (g_test_verbose()) { + qos_dump_graph(); + } g_test_run(); qtest_end(); qos_graph_destroy(); --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601659701; cv=none; d=zohomail.com; s=zohoarc; b=RsBPWym6/HubY0M0HDFZGSQKjiBJpmJ2o4ULEqvEkHoiwSK4z165PbhlDF35MICrOB2Ch0GwvkrgPb7oJUa7lZIvsDxmAUoQy35+zO4Dl0f3+zfc9JO/TDeUsXHsTLlaWIfvOnS/uxmcllJHGWkTg31OblFNf18llpc7ezvacig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659701; 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=44zIO6oSJBtCMtx0lPpF1Gk4m8vRKjg9xvEFAgJFrqw=; b=B4cBSouSjW1bVk6lPtUFTxK5w6HUe/ALUv3V5wrP5dNmH4Osy9GZgNGGOT36mfNXo2/NvOtN+VYVficg4ktWXHst8Be8U+o1teUB+miRGywnwf64himlKe1ntE34qIanvpSkagCXxQRG8wnpnG1mHUsYMqWTynDJKtJ6sjZsQ1I= 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 1601659701566297.80297474156737; Fri, 2 Oct 2020 10:28:21 -0700 (PDT) Received: from localhost ([::1]:46404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOqy-0003UU-85 for importer@patchew.org; Fri, 02 Oct 2020 13:28:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <8d8b242f38caccd81c27125167862f4457e8a22f@lizzy.crudebyte.com>) id 1kOOmY-0006oh-Hp for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:23:46 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:42627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <8d8b242f38caccd81c27125167862f4457e8a22f@lizzy.crudebyte.com>) id 1kOOmW-0001jq-Qh for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:23:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=44zIO6oSJBtCMtx0lPpF1Gk4m8vRKjg9xvEFAgJFrqw=; b=hFgB7 gMjVjv/iw/9uVSUHDXBzaILgWeLdBh73nihuh8KweK0z9eKQQOEPYpTM3CUkkpfuldUpndy/5/qDL BaqStNZXbcPZJFzod6TojpA4TxW5M3/vnQc7tKPhaiai6ifHfqr/UiIrqGqls/3xbBUfylUXL0uy9 TEBtuRfQcpPBekmCw6sGGavvZFOddH4DEmnkLNSVh14NXhmPGaAQukzpiqfe7KAgECSO5kLPuUc5V DY1AjHhUICHVKKRc27s2tKvF6DwT7jMDlRgK03YbyIJIkuwTc5rkhGJhzU77yVub93fxvbIIyvxO5 s7Ea04bHExDNoWAdvfDX6gYWjULUg==; Message-Id: <8d8b242f38caccd81c27125167862f4457e8a22f.1601655308.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 05/11] tests/qtest/qos-test: dump environment variables if verbose To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=8d8b242f38caccd81c27125167862f4457e8a22f@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" If qtests are run in verbose mode (i.e. if --verbose CL argument was provided) then print all environment variables to stdout before running the individual tests. Instead of using g_test_message() rather use printf() in combination with g_test_verbose(), to avoid g_test_message() cluttering the output. Signed-off-by: Christian Schoenebeck --- tests/qtest/qos-test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index d98ef78613..fe240b32a7 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -313,9 +313,16 @@ static void walk_path(QOSGraphNode *orig_path, int len) * machine/drivers/test objects * - Cleans up everything */ -int main(int argc, char **argv) +int main(int argc, char **argv, char** envp) { g_test_init(&argc, &argv, NULL); + if (g_test_verbose()) { + printf("ENVIRONMENT VARIABLES: {\n"); + for (char **env =3D envp; *env !=3D 0; env++) { + printf("\t%s\n", *env); + } + printf("}\n"); + } qos_graph_init(); module_call_init(MODULE_INIT_QOM); module_call_init(MODULE_INIT_LIBQOS); --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601658903; cv=none; d=zohomail.com; s=zohoarc; b=jOf6nMlDRwA5UFBdxbAnDdW+YgVTu8QO/2W6yd8OsArBOwntvFGlbxcw6zHFyRYORXNygrZN5ZnHE/CUjY3RN8VLlJUYrk2XkR2pH/aK5mvsRhl04I8fDruiALG76xuenBKTuNu9t8JhR3qnCnFhOpMHQpEyKb51s4qvvi8lL3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601658903; 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=iovGPj5Q92eV7i24vjrQeAdFBH4d8kiFupqK9XpeZzs=; b=FwjxKJPDtP9wzU1bCNuLXfg1zOLWRbX9M6HqGjg/sUnZfpn4Vauwnv+Z9YYc0ctjNFuvRgHkNxm1N9/nVCC4ZCm/AQayB0uhdesYnvCjYuIAYua+z/Slde+PBJ0KAvKDHf+XcMlwV5HIRMIjLU4PV16O7T2v7wHSU8SvFA5i3bg= 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 1601658903614814.5417924643453; Fri, 2 Oct 2020 10:15:03 -0700 (PDT) Received: from localhost ([::1]:39720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOe6-0004ug-5W for importer@patchew.org; Fri, 02 Oct 2020 13:15:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <54781ff3e3231fa1b7e1bea8d16e825c5084a74f@lizzy.crudebyte.com>) id 1kOOd2-0003zr-I6 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:13:56 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:58511) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <54781ff3e3231fa1b7e1bea8d16e825c5084a74f@lizzy.crudebyte.com>) id 1kOOd0-0000W0-IP for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:13:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=iovGPj5Q92eV7i24vjrQeAdFBH4d8kiFupqK9XpeZzs=; b=Su25C 8gaw3BTY6ngHHdkJOLPBrdJUgNYVuAS+THvX35c2OMe5cbkHF09VDDjy6WoNMR4j3wqkM68DQQmyx 4S53+xwqVTJr2/CLVehm7yr7ElooOB3aY5k6VLfVG5j36JGo3o9ebTgpzDWN0NQizNI7fD2Ro3cTF AiGMpEzCqu0tcq5rfvdU0VMwwmWgf0c62e1Jk4zQjt32BByar0M7gBSlwK9xiGpVasvhfAk8lif2N 7FZPVPHu9/mx4cfPZuuVAGvoMG8wBF2tJZHESHZYIy6fTdpH4NllX/vn+VWhv61QPUSei/CZDNBsz 4EVCL9c8xKGs7jGbEzHrRocJUuWYw==; Message-Id: <54781ff3e3231fa1b7e1bea8d16e825c5084a74f.1601655308.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 06/11] tests/qtest/qos-test: dump QEMU command if verbose To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=54781ff3e3231fa1b7e1bea8d16e825c5084a74f@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" If qtests are run in verbose mode (i.e. if --verbose CL argument was provided) then print the assembled qemu command line for each test. Instead of using g_test_message() rather use printf() in combination with g_test_verbose(), to avoid g_test_message() cluttering the output. Signed-off-by: Christian Schoenebeck --- tests/qtest/qos-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index fe240b32a7..b9f0942386 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -89,6 +89,9 @@ static void qos_set_machines_devices_available(void) =20 static void restart_qemu_or_continue(char *path) { + if (g_test_verbose()) { + printf("Run QEMU with: '%s'\n", path); + } /* compares the current command line with the * one previously executed: if they are the same, * don't restart QEMU, if they differ, stop previous --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601659280; cv=none; d=zohomail.com; s=zohoarc; b=V4pgcgP/j4lUHC87thgc/9hpiHSO3SIyfoNLZMRYQIglWZzORxJh102MdjdoezutFIYdhucnsmzZixgqvvrpbo9kVUxI+blWHNpBoYBepxUEenUZgjGEbd1IpJ+LYlSFxWMRhuuPYce4ZY37gJ0inmiEXtKWE85WIs2H/ocW3GA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659280; 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=61K9IPek47Lb/jUIgvqHI9x1BIex8Psn2YIHGCS3rpk=; b=KUxScisYU38fUQNvUoqujGrvH9qjyhZWMAtozWNluq319DN87NKrHRmRLmgIUtjKVr6x7GFtquXCyIAQwcTiveBUzvaEXkxF6gQwnfU/4nbhnIGvPet+HR8w+m3UXawPQxvneA9ad/RCoBeDWOfKDPRDiVYSS+7XF+yuoFxJlGU= 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 1601659280259616.3505250508103; Fri, 2 Oct 2020 10:21:20 -0700 (PDT) Received: from localhost ([::1]:55672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOkB-0003aX-31 for importer@patchew.org; Fri, 02 Oct 2020 13:21:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1bb273a60bd944539a3db28c0da4ccac8c0126ad@lizzy.crudebyte.com>) id 1kOOiR-0002RB-TY for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:19:31 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:54705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1bb273a60bd944539a3db28c0da4ccac8c0126ad@lizzy.crudebyte.com>) id 1kOOiQ-0001Do-9N for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:19:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=61K9IPek47Lb/jUIgvqHI9x1BIex8Psn2YIHGCS3rpk=; b=ESWEi 5e+I5WnAEbzmB/i0N9ohLq5NqZkucfv0Zsx4mENYdMf5UhdpXv6hJmFFopXE5hxiJN1qR0eMuCDpC 8oqlCMSPAXH6DgFF9fW8tk//bVzhKAhxYUxalCM8LsbrIbBw37u5fbcKzOz8gZx2jx2j3bDP+cZ9s rA1YxM9Ge28AEaMU39k/5gNjo3B5n4nCHVw/5NycLopPXRW2tx2JRE78nXrFUfaq6ukPWoloV7rE/ LPuryvnoyiSKPrWOg9BIpwwfhD4MvPDrmHz3uYvQSwKlJmxJJsRB+omCyPtc1veVS8i8mLUJLn64/ zxiU5xO2MtFHGAYQ/odwQmLXAr3bQ==; Message-Id: <1bb273a60bd944539a3db28c0da4ccac8c0126ad.1601655308.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 07/11] tests/9pfs: change qtest name prefix to synth To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=1bb273a60bd944539a3db28c0da4ccac8c0126ad@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" All existing 9pfs test cases are using the 'synth' fs driver so far, which means they are not accessing real files, but a purely simulated (in RAM only) file system. Let's make this clear by changing the prefix of the individual qtest case names from 'fs/' to 'synth/'. That way they'll be easily distinguishable from upcoming new 9pfs test cases supposed to be using a different fs driver. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index de30b717b6..3281153b9c 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -897,26 +897,26 @@ static void fs_readdir_split_512(void *obj, void *dat= a, =20 static void register_virtio_9p_test(void) { - qos_add_test("config", "virtio-9p", pci_config, NULL); - qos_add_test("fs/version/basic", "virtio-9p", fs_version, NULL); - qos_add_test("fs/attach/basic", "virtio-9p", fs_attach, NULL); - qos_add_test("fs/walk/basic", "virtio-9p", fs_walk, NULL); - qos_add_test("fs/walk/no_slash", "virtio-9p", fs_walk_no_slash, + qos_add_test("synth/config", "virtio-9p", pci_config, NULL); + qos_add_test("synth/version/basic", "virtio-9p", fs_version, NULL); + qos_add_test("synth/attach/basic", "virtio-9p", fs_attach, NULL); + qos_add_test("synth/walk/basic", "virtio-9p", fs_walk, NULL); + qos_add_test("synth/walk/no_slash", "virtio-9p", fs_walk_no_slash, NULL); - qos_add_test("fs/walk/dotdot_from_root", "virtio-9p", + qos_add_test("synth/walk/dotdot_from_root", "virtio-9p", fs_walk_dotdot, NULL); - qos_add_test("fs/lopen/basic", "virtio-9p", fs_lopen, NULL); - qos_add_test("fs/write/basic", "virtio-9p", fs_write, NULL); - qos_add_test("fs/flush/success", "virtio-9p", fs_flush_success, + qos_add_test("synth/lopen/basic", "virtio-9p", fs_lopen, NULL); + qos_add_test("synth/write/basic", "virtio-9p", fs_write, NULL); + qos_add_test("synth/flush/success", "virtio-9p", fs_flush_success, NULL); - qos_add_test("fs/flush/ignored", "virtio-9p", fs_flush_ignored, + qos_add_test("synth/flush/ignored", "virtio-9p", fs_flush_ignored, NULL); - qos_add_test("fs/readdir/basic", "virtio-9p", fs_readdir, NULL); - qos_add_test("fs/readdir/split_512", "virtio-9p", + qos_add_test("synth/readdir/basic", "virtio-9p", fs_readdir, NULL); + qos_add_test("synth/readdir/split_512", "virtio-9p", fs_readdir_split_512, NULL); - qos_add_test("fs/readdir/split_256", "virtio-9p", + qos_add_test("synth/readdir/split_256", "virtio-9p", fs_readdir_split_256, NULL); - qos_add_test("fs/readdir/split_128", "virtio-9p", + qos_add_test("synth/readdir/split_128", "virtio-9p", fs_readdir_split_128, NULL); } =20 --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601659805; cv=none; d=zohomail.com; s=zohoarc; b=BwHmy1ZNaNk9S4NhQwm5UvVLn7PwQerU4IG+sXSzBB0wgqUWfllpTanxgwS/r3IjrzbWuoOG+pmgzc6EVfSLvICOYiGe+HKJoWbNK8So1meVY77CPA06u6ColIx+vWEg53iAib1v/7xUJnwctKgZeuaQKd8gTF+cr09xXePvbew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659805; 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=Am7AnThgQlSLFdOJL4e448KatPmi955rqcXqeOaLFHs=; b=dCXrThCFpndOuQGVDsLV5+ZKi2TFSqpi31Iu4PbH+Rc4hmLqYfuDk7F6Ug5/bbLJV43c9AdhwTT8lPHLNwypu9qHpssf9hQxh9Lbd3/ChlFquq6isSUfCYUb4bUe5dYDBocIwMUYuzWY69wWgI79Nnc1ufED1lo2cAEjRyBFBN8= 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 1601659805900949.4014291783498; Fri, 2 Oct 2020 10:30:05 -0700 (PDT) Received: from localhost ([::1]:50698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOse-0005JU-0L for importer@patchew.org; Fri, 02 Oct 2020 13:30:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <61429f365a83c9e941b0d5ded9d55fdeaaedda5e@lizzy.crudebyte.com>) id 1kOOna-00080D-TH for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:24:50 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:35415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <61429f365a83c9e941b0d5ded9d55fdeaaedda5e@lizzy.crudebyte.com>) id 1kOOnX-0001nV-Ga for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:24:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=Am7AnThgQlSLFdOJL4e448KatPmi955rqcXqeOaLFHs=; b=NogoX NzZtj86qD+YUhZv6txDocgQL2gvOG5rK7VuBZQi3Kd7dj3acBxrs4vqM7r0yny6y4rknNdVOLGYRk 1k1nb3EZHKzGwPH6v9ihgaehufxmKjH/uM14a5e9l3kt3PFjs3dSNfXLOcp/AppqpzPD8ccI5b6Ij xmSC3dyFfAnIv1IUiXnPlWU0wY4jyblhRvJTKZqIOktgCXILlfUwJHKeTiU1TOnwRkZ4kDWV/BrjW MPaouYQzRc3F1ALL0g0D+OyCHbHjMPZFj1klVTHjamFC1SAfNpq9X1cF9kNoYnprnJRZb60w981bJ QnzjnkLw4Hn8CEQbtVi+SKcvRnQmA==; Message-Id: <61429f365a83c9e941b0d5ded9d55fdeaaedda5e.1601655308.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 08/11] tests/9pfs: introduce local tests To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=61429f365a83c9e941b0d5ded9d55fdeaaedda5e@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" This patch introduces 9pfs test cases using the 9pfs 'local' filesystem driver which reads/writes/creates/deletes real files and directories. In this initial version, there is only one local test which actually only checks if the 9pfs 'local' device was created successfully. Before the 9pfs 'local' tests are run, a test directory 'qtest-9p-local' is created (with world rwx permissions) under the current working directory. At this point that test directory is not auto deleted yet. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p.c | 71 ++++++++++++++++++++++++++++++++++ tests/qtest/libqos/virtio-9p.h | 5 +++ tests/qtest/virtio-9p-test.c | 44 ++++++++++++++------- 3 files changed, 106 insertions(+), 14 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 2e300063e3..1bada47af1 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -24,6 +24,34 @@ #include "qgraph.h" =20 static QGuestAllocator *alloc; +static char *local_test_path; + +/* Concatenates the passed 2 pathes. Returned result must be freed. */ +static char *concat_path(const char* a, const char* b) +{ + return g_build_filename(a, b, NULL); +} + +static void init_local_test_path(void) +{ + char *pwd =3D get_current_dir_name(); + local_test_path =3D concat_path(pwd, "qtest-9p-local"); + free(pwd); +} + +/* Creates the directory for the 9pfs 'local' filesystem driver to access.= */ +static void create_local_test_dir(void) +{ + struct stat st; + + g_assert(local_test_path !=3D NULL); + mkdir(local_test_path, 0777); + + /* ensure test directory exists now ... */ + g_assert(stat(local_test_path, &st) =3D=3D 0); + /* ... and is actually a directory */ + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFDIR); +} =20 static void virtio_9p_cleanup(QVirtio9P *interface) { @@ -146,11 +174,54 @@ static void *virtio_9p_pci_create(void *pci_bus, QGue= stAllocator *t_alloc, return obj; } =20 +void virtio_9p_assign_local_driver(GString *cmd_line, const char *args) +{ + GRegex *regex; + char *s, *arg_repl; + + g_assert_nonnull(local_test_path); + + /* replace 'synth' driver by 'local' driver */ + regex =3D g_regex_new("-fsdev synth,", 0, 0, NULL); + s =3D g_regex_replace_literal( + regex, cmd_line->str, -1, 0, "-fsdev local,", 0, NULL + ); + g_string_assign(cmd_line, s); + g_free(s); + g_regex_unref(regex); + + /* add 'path=3D...' to '-fsdev ...' group */ + regex =3D g_regex_new("(-fsdev \\w+)(\\s*)", 0, 0, NULL); + arg_repl =3D g_strdup_printf("\\1\\2,path=3D'%s'", local_test_path); + s =3D g_regex_replace( + regex, cmd_line->str, -1, 0, arg_repl, 0, NULL + ); + g_string_assign(cmd_line, s); + g_free(arg_repl); + g_free(s); + g_regex_unref(regex); + + /* add passed args to '-fsdev ...' group */ + regex =3D g_regex_new("(-fsdev \\w+)(\\s*)", 0, 0, NULL); + arg_repl =3D g_strdup_printf("\\1\\2,%s", args); + s =3D g_regex_replace( + regex, cmd_line->str, -1, 0, arg_repl, 0, NULL + ); + g_string_assign(cmd_line, s); + g_free(arg_repl); + g_free(s); + g_regex_unref(regex); +} + 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(); + create_local_test_dir(); + 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 b1e6badc4a..326a603f72 100644 --- a/tests/qtest/libqos/virtio-9p.h +++ b/tests/qtest/libqos/virtio-9p.h @@ -44,4 +44,9 @@ struct QVirtio9PDevice { QVirtio9P v9p; }; =20 +/** + * Prepares QEMU command line for 9pfs tests using the 'local' fs driver. + */ +void virtio_9p_assign_local_driver(GString *cmd_line, const char *args); + #endif diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 3281153b9c..af7e169d3a 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -895,29 +895,45 @@ static void fs_readdir_split_512(void *obj, void *dat= a, fs_readdir_split(obj, data, t_alloc, 512); } =20 +static void *assign_9p_local_driver(GString *cmd_line, void *arg) +{ + virtio_9p_assign_local_driver(cmd_line, "security_model=3Dmapped-xattr= "); + return arg; +} + static void register_virtio_9p_test(void) { - qos_add_test("synth/config", "virtio-9p", pci_config, NULL); - qos_add_test("synth/version/basic", "virtio-9p", fs_version, NULL); - qos_add_test("synth/attach/basic", "virtio-9p", fs_attach, NULL); - qos_add_test("synth/walk/basic", "virtio-9p", fs_walk, NULL); + + QOSGraphTestOptions opts =3D { + }; + + /* 9pfs test cases using the 'synth' filesystem driver */ + qos_add_test("synth/config", "virtio-9p", pci_config, &opts); + qos_add_test("synth/version/basic", "virtio-9p", fs_version, &opts); + qos_add_test("synth/attach/basic", "virtio-9p", fs_attach, &opts); + qos_add_test("synth/walk/basic", "virtio-9p", fs_walk, &opts); qos_add_test("synth/walk/no_slash", "virtio-9p", fs_walk_no_slash, - NULL); + &opts); qos_add_test("synth/walk/dotdot_from_root", "virtio-9p", - fs_walk_dotdot, NULL); - qos_add_test("synth/lopen/basic", "virtio-9p", fs_lopen, NULL); - qos_add_test("synth/write/basic", "virtio-9p", fs_write, NULL); + fs_walk_dotdot, &opts); + qos_add_test("synth/lopen/basic", "virtio-9p", fs_lopen, &opts); + qos_add_test("synth/write/basic", "virtio-9p", fs_write, &opts); qos_add_test("synth/flush/success", "virtio-9p", fs_flush_success, - NULL); + &opts); qos_add_test("synth/flush/ignored", "virtio-9p", fs_flush_ignored, - NULL); - qos_add_test("synth/readdir/basic", "virtio-9p", fs_readdir, NULL); + &opts); + qos_add_test("synth/readdir/basic", "virtio-9p", fs_readdir, &opts); qos_add_test("synth/readdir/split_512", "virtio-9p", - fs_readdir_split_512, NULL); + fs_readdir_split_512, &opts); qos_add_test("synth/readdir/split_256", "virtio-9p", - fs_readdir_split_256, NULL); + fs_readdir_split_256, &opts); qos_add_test("synth/readdir/split_128", "virtio-9p", - fs_readdir_split_128, NULL); + fs_readdir_split_128, &opts); + + + /* 9pfs test cases using the 'local' filesystem driver */ + opts.before =3D assign_9p_local_driver; + qos_add_test("local/config", "virtio-9p", pci_config, &opts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601659136; cv=none; d=zohomail.com; s=zohoarc; b=BDr/ZBXsLu1LIBy5/veFnOIHdazQD+PVgulVyNbCXjm+9Da7pkHGuQPZ/CHXeE5iYxJLygKPW+1cSVDnmQJ4Ps8DPhks3wcyk1r4NxOm2i8pIaqXIvQoXtnK4BdUnwz2R1HRp6xEgM7DCoijAJ5G4HDuMkSIR/s7KSF6tMw5kbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659136; 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=BSbk4EIVeU/i+4oKZ2B4/+wgq8/qcKvmZMjx+zQuxpE=; b=LFiGVylVg9/4bYf02TivV5Kvsqn68rrMEfKRK0XNBKigUO2L9XJ5F0FY41AplgovCqmxP76+w1WajlH9dh9nQgENQxMsu4vauKdwF/FCidg1V/GIRb2xYLwyIVHF5ESDWztwkR1G4GHzwX92eR7Y7mgNKah9XqHRbywoiUvVDok= 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 1601659136786576.5290204809291; Fri, 2 Oct 2020 10:18:56 -0700 (PDT) Received: from localhost ([::1]:50266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOhq-00017R-Dy for importer@patchew.org; Fri, 02 Oct 2020 13:18:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <0c54a2ca2049e9824df9805324cac8dac029c113@lizzy.crudebyte.com>) id 1kOOgQ-0008Gw-P9 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:17:26 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:35595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <0c54a2ca2049e9824df9805324cac8dac029c113@lizzy.crudebyte.com>) id 1kOOgP-00014c-65 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:17:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=BSbk4EIVeU/i+4oKZ2B4/+wgq8/qcKvmZMjx+zQuxpE=; b=Zc7Q1 LkI/Hcfy7u+Li+R8Oc3rOBTRt0//fgf1CNlCZ/lg0DmvwS31TEihK7OfP9u8mXqb/13kY+7Ng6Wes lgRmhlR9Uh90VnCupWE0J/amfV0hgLkyQbSWyIYVbQTyzZxdro+8oWMXai21tbaq08sRM4DFAersy TxBaIPmOAIgOaHNy3Spx2DX0ALLDQfHqpGmDPpwoSZZ4HSmY0ngkoO1QVyHTiC/Nhmm9S5VLp4fdO 8HLGzWf3WlMVZF8QI48Zr9ia7tw/6kXBA9sPdoVgXAPkyeBwdbaXnYyYg5g5P7e6eFGBSwQYHg+Ug DOJ/rnX68AMlSwlqVicWr8WEciFbw==; Message-Id: <0c54a2ca2049e9824df9805324cac8dac029c113.1601655308.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 09/11] tests/9pfs: wipe local 9pfs test directory To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=0c54a2ca2049e9824df9805324cac8dac029c113@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" Before running the first 9pfs test case, make sure the test directory for running the 9pfs 'local' tests on is entirely empty. For that reason simply delete the test directory (if any) before (re)creating it on test suite startup. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 1bada47af1..41a7c2baaa 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -53,6 +53,18 @@ 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) +{ + g_assert(local_test_path !=3D NULL); + char *cmd =3D g_strdup_printf("rm -r '%s'\n", local_test_path); + int res =3D system(cmd); + if (res < 0) { + /* ignore error, dummy check to prevent compiler error */ + } + g_free(cmd); +} + static void virtio_9p_cleanup(QVirtio9P *interface) { qvirtqueue_cleanup(interface->vdev->bus, interface->vq, alloc); @@ -220,6 +232,7 @@ 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(); =20 QPCIAddress addr =3D { --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601659023; cv=none; d=zohomail.com; s=zohoarc; b=OYnRg8otW+SV+/FXZ782b9NsaABVLa19B6uPvron+GbHqw1QgwyGRhy5i6i37US4n5EaO05VHS15gDdmRah1d9XeR7t4+bprefG3R+5M+CSRqCyAsasV3FKSnpk7yl4CUkpJQ89iR44Ak/w120uahRdX/Mgio2esynvYOB6rfCs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659023; 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=KUID9zcYFNagetFBTikouPXhrAw+dJp4Vkto9BQA5BA=; b=kl/q66sspVUCl8WsepqYwz0d9i2xJICeYUy+jgYx9SEdf2eyoJJ/nqLZtWjwHo6CPuvpCSTnU24mQcbUx1XUYHXT7HYeZZkdQctLNWAL8YLze/BNGYZbJK5S8UE3g3g4m/NUClYWhP7/qcU08ZMJ+FRZpcwB/PrU7ZCnYTtwCjA= 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 1601659023864222.55447083734884; Fri, 2 Oct 2020 10:17:03 -0700 (PDT) Received: from localhost ([::1]:44260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOg2-0006zl-L7 for importer@patchew.org; Fri, 02 Oct 2020 13:17:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOOf9-00062t-UD for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:16:08 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:58511) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOOf6-0000W0-9p for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:16:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=KUID9zcYFNagetFBTikouPXhrAw+dJp4Vkto9BQA5BA=; b=Akkb9 MHQEICxB7P0SP3FKoTxRWDv3FllfdhFhTTLQyqbRLgYANBz8g6wYwK0p51THytAWH47XX0NyWjSA5 fMr+homwxcwUHKro/9GQUdBI2hQXq3O1S4WC4YNs2OvCdo9FNfd5I9dHNXvj5WYIZYX1wouzusS4n BlZPHhUAmD+wEtgwc0Nr9Z1Z/nzd79EoDFJLNII2CLvzhd/wP+UbrYoCBKh+I6BpoGTyyI0YAsVow Tsr4lbhVWTOsSEdVlv4C/zHP5YcS7txODybAfB1W4LMXncT++lLjNlruh3ITmzByhVul6ZbwTHNDi X+WlRsiQZO41A1CgcsmOJQC9XNx2w==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 10/11] tests/9pfs: add virtio_9p_test_path() To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=ba79fe0a0b095c4936ac785cf51232aa9eec52aa@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" This new public function virtio_9p_test_path() allows 9pfs 'local' tests to translate a path from guest scope to host scope. For instance by passing an empty string it would return the root path on host of the exported 9pfs tree. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p.c | 6 ++++++ tests/qtest/libqos/virtio-9p.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 41a7c2baaa..10a5760cf4 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -65,6 +65,12 @@ static void remove_local_test_dir(void) g_free(cmd); } =20 +char *virtio_9p_test_path(const char *path) +{ + g_assert(local_test_path); + return concat_path(local_test_path, path); +} + static void virtio_9p_cleanup(QVirtio9P *interface) { qvirtqueue_cleanup(interface->vdev->bus, interface->vq, alloc); diff --git a/tests/qtest/libqos/virtio-9p.h b/tests/qtest/libqos/virtio-9p.h index 326a603f72..19a4d97454 100644 --- a/tests/qtest/libqos/virtio-9p.h +++ b/tests/qtest/libqos/virtio-9p.h @@ -49,4 +49,9 @@ struct QVirtio9PDevice { */ void virtio_9p_assign_local_driver(GString *cmd_line, const char *args); =20 +/** + * Returns path on host to the passed guest path. Result must be freed. + */ +char *virtio_9p_test_path(const char *path); + #endif --=20 2.20.1 From nobody Sun May 19 16:31:29 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=1601659019; cv=none; d=zohomail.com; s=zohoarc; b=Xck/r/FPUrg0BzY7bF34L0N0YLhZujsSld9B3a5WqnakN8TIGfkIV4SwyN58BbWE4p9X4p44+XoNiv+sjODwAG3JFEwZO9RYBtVuiWxa6o6hAdyDaHMwL9CBVwdKdjkGu47qV6h8rcdurZ8WWV1YhY70IvNCMCIPAfJwpceTrFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601659019; 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=ePtsKC4aFi7jGHFiSRI09MokuHMPuECH1mLHa2h/FG4=; b=MQUZ6qm4HTEnaAtIXLhbZlMqMn4eT5f3pA/Tr9UYJtZUDeUyS6GgkP9gfJH7QnNgn179gW4VkvW3qK+0ciHygajmtin7HYHGwkdT0GHppBiXtezpcND4E6sdQYEe/ARazWEK3NaX7a8kGwMttzkXccgckqnCU4B4C+icpISb0IU= 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 1601659019799191.4898904324043; Fri, 2 Oct 2020 10:16:59 -0700 (PDT) Received: from localhost ([::1]:44010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOOfy-0006rK-GY for importer@patchew.org; Fri, 02 Oct 2020 13:16:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4c1954a3515f63081ebb2e6870837b8edd0b4eab@lizzy.crudebyte.com>) id 1kOOe5-0005FX-DZ for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:15:01 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:58511) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4c1954a3515f63081ebb2e6870837b8edd0b4eab@lizzy.crudebyte.com>) id 1kOOe3-0000W0-Ct for qemu-devel@nongnu.org; Fri, 02 Oct 2020 13:15:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=ePtsKC4aFi7jGHFiSRI09MokuHMPuECH1mLHa2h/FG4=; b=j7cGb MtdHiJgf7Lnq9nyhA/0QknQXL7vUbaD6bDgiRuJQkF9/ivu3OrCtktU3XJ+OSobM/Qfbg0AUrYOtO aUcsXOHtXFt47JmjJfwWOmZ4a/EMyCgK8ot3H+lWg2apjFn/knhuZJBt6f2h7TX9BEOuPPMzKdMg1 67qydvUMEMFf9bds8BeT59vO0vQWFAR1q0FUVswMmLuHzkvVW3KoBzTyHC0JqHllbR0FTCA/tFIaT jXCs03bgz1vPEx4vhbUvUHPgN2dTblLATsuOeBYh+5Ez3cI9n7AojZ/AlgYjupk5eMaglmWk2kCIm 4zlwaqA0kX1fLH3BuPEwk4rAUgc7w==; Message-Id: <4c1954a3515f63081ebb2e6870837b8edd0b4eab.1601655308.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 18:15:05 +0200 Subject: [PATCH v3 11/11] tests/9pfs: add local Tmkdir test To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , Greg Kurz , berrange@redhat.com 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=4c1954a3515f63081ebb2e6870837b8edd0b4eab@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/02 08:18:24 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" This test case uses the 9pfs 'local' driver to create a directory and then checks if the expected directory was actually created (as real directory) on host side. This patch introduces a custom split() implementation, because the test code requires non empty array elements as result. For that reason g_strsplit() would not be a good alternative, as it would require additional filter code for reshuffling the array, and the resulting code would be even more complex than this split() function. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 139 +++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index af7e169d3a..c15908f27b 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -18,6 +18,62 @@ #define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000) static QGuestAllocator *alloc; =20 +/* + * Used to auto generate new fids. Start with arbitrary high value to avoid + * collision with hard coded fids in basic test code. + */ +static uint32_t fid_generator =3D 1000; + +static uint32_t genfid(void) +{ + return fid_generator++; +} + +/** + * Splits the @a in string by @a delim into individual (non empty) strings + * and outputs them to @a out. The output array @a out is NULL terminated. + * + * Output array @a out must be freed by calling split_free(). + * + * @returns number of individual elements in output array @a out (without = the + * final NULL terminating element) + */ +static int split(const char *in, const char *delim, char ***out) +{ + int n =3D 0, i =3D 0; + char *tmp, *p; + + tmp =3D g_strdup(in); + for (p =3D strtok(tmp, delim); p !=3D NULL; p =3D strtok(NULL, delim))= { + if (strlen(p) > 0) { + ++n; + } + } + g_free(tmp); + + *out =3D g_new0(char *, n + 1); /* last element NULL delimiter */ + + tmp =3D g_strdup(in); + for (p =3D strtok(tmp, delim); p !=3D NULL; p =3D strtok(NULL, delim))= { + if (strlen(p) > 0) { + (*out)[i++] =3D g_strdup(p); + } + } + g_free(tmp); + + return n; +} + +static void split_free(char ***out) +{ + int i; + for (i =3D 0; (*out)[i]; ++i) { + g_free((*out)[i]); + } + g_free(*out); + *out =3D NULL; +} + static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; @@ -201,6 +257,7 @@ static const char *rmessage_name(uint8_t id) id =3D=3D P9_RWALK ? "RWALK" : id =3D=3D P9_RLOPEN ? "RLOPEN" : id =3D=3D P9_RWRITE ? "RWRITE" : + id =3D=3D P9_RMKDIR ? "RMKDIR" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "READDIR" : ""; @@ -578,6 +635,39 @@ static bool fs_dirents_contain_name(struct V9fsDirent = *e, const char* name) return false; } =20 +/* size[4] Tmkdir tag[2] dfid[4] name[s] mode[4] gid[4] */ +static P9Req *v9fs_tmkdir(QVirtio9P *v9p, uint32_t dfid, const char *name, + uint32_t mode, uint32_t gid, uint16_t tag) +{ + P9Req *req; + + uint32_t body_size =3D 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_TMKDIR, tag); + v9fs_uint32_write(req, dfid); + v9fs_string_write(req, name); + v9fs_uint32_write(req, mode); + v9fs_uint32_write(req, gid); + v9fs_req_send(req); + return req; +} + +/* size[4] Rmkdir tag[2] qid[13] */ +static void v9fs_rmkdir(P9Req *req, v9fs_qid *qid) +{ + v9fs_req_recv(req, P9_RMKDIR); + if (qid) { + v9fs_memread(req, qid, 13); + } else { + v9fs_memskip(req, 13); + } + 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) { @@ -877,6 +967,30 @@ 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) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + char **wnames; + char *const name =3D g_strdup(cname); + 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); + + req =3D v9fs_tmkdir(v9p, fid, name, 0750, 0, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rmkdir(req, NULL); + + g_free(name); + split_free(&wnames); +} + static void fs_readdir_split_128(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -895,6 +1009,30 @@ static void fs_readdir_split_512(void *obj, void *dat= a, fs_readdir_split(obj, data, t_alloc, 512); } =20 + +/* tests using the 9pfs 'local' fs driver */ + +static void fs_create_dir(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p =3D obj; + struct stat st; + char *root_path =3D virtio_9p_test_path(""); + char *new_dir =3D virtio_9p_test_path("01"); + + g_assert(root_path !=3D NULL); + + fs_attach(v9p, NULL, t_alloc); + fs_mkdir(v9p, data, t_alloc, "/", "01"); + + /* 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); + + 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= "); @@ -934,6 +1072,7 @@ static void register_virtio_9p_test(void) /* 9pfs test cases using the 'local' filesystem driver */ 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); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1