From nobody Sun May 19 13:14:44 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=1601643472; cv=none; d=zohomail.com; s=zohoarc; b=UylPKF0KKRvUewzz2bnottKjQBKodEFC55QD27mSzJSgDNPy3SDy4yz7dr4uyMUYy608UgIPWb+vp9LnexqI4xsTqlu9woZ/3Jj+7hshJle+oHm7YpdoAOfXoHTaEgKzzxFLoAOduUO+lUQ74LVFCOxpdy7dKy+s9eMYcGzCOpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601643472; 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=McUpn21AQ5D6/AnBWMXLbv6rkgZ1bsU64ZZMejtbXxeKifQZaV6rgGodt4USqoFS67uELLxjGkdVRHOb+V3BdLgfVGnJDFlDv8dZQwBdzHj1fueqBw7yjZKcBTKVsZ3O+ayF84GiEEiSbWUkId6ZSn/vVsRbLf2T9c4D8VMNEKM= 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 1601643472948976.0000173046651; Fri, 2 Oct 2020 05:57:52 -0700 (PDT) Received: from localhost ([::1]:34278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKdD-0005DU-OY for importer@patchew.org; Fri, 02 Oct 2020 08:57:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <040e30f37e4bf31b14331d97f2c8c2bad430fd4c@lizzy.crudebyte.com>) id 1kOKaS-0002oT-JT for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:55:00 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:55963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <040e30f37e4bf31b14331d97f2c8c2bad430fd4c@lizzy.crudebyte.com>) id 1kOKaR-00009U-3v for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:55:00 -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=JDU+w +1Vsy/goVVqEQqJcdTROhZUKR1WJnl9hoWDqhd0S3wte8hed8T/QJaRMPX+F5vVkp/4hLgxV8phK7 wDu92ACuzyoKSyolS7ab5yWQ0TJO3FoNUwM9ADh1abZ+N+onhytV0MCn+VoH4JQvZ3RPfBMPxKFQK sJ64mK77n0HiGRyvAlj+OmbPUqbVP42TGMzQhaF4NumG3gjd/cM71I9FgIqDQP6Qo55bhonHrS6XR KgY0QIOQ5iFVio/Y/Q0m9GUThHbX6SBRhx/PYWXLGq9lHOu4HFa0fpe9WwGi3d7Cv2tkhULgTYh3I EFNlbBw5O77Df3bHP7DHj+VrDfolQ==; Message-Id: <040e30f37e4bf31b14331d97f2c8c2bad430fd4c.1601639563.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=040e30f37e4bf31b14331d97f2c8c2bad430fd4c@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 13:14:44 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=1601643360; cv=none; d=zohomail.com; s=zohoarc; b=SeJZg+0zuSf5WLx1ev7+SDYFilGDvW4d90n4NJWgAhZADKcRFFRfhiGwQEJJL/6Vp+Lj7XIBNhcatog25L7Y6nFxS8RwK8HfM8iC1+TYp1defOl8w22qpI2OQ7Jxm/ayfkHh7VGJv8S3X5c+ZqZUBM93npAOosM66y7GTJBdZ+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601643360; 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=LIrMrUgACRwZWYEBJQ58+HH+XbMjXgmECy95tp3pVmT0GziN1diXxUUl66GX7QW8oXaYeDt++5LTkgJUy2oBL+SnWyi6dyHQifJ5yo7raNxboF0riZGgxCRLZguUEovx6u06KrxV9EEewDdWPZnvqZOKDwl6pk8TGeOfuvtuNKo= 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 1601643360948451.34227360418595; Fri, 2 Oct 2020 05:56:00 -0700 (PDT) Received: from localhost ([::1]:58278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKbP-0003SU-Hu for importer@patchew.org; Fri, 02 Oct 2020 08:55:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <08d91b5509f34ca77940588e0bbe530408f9f8b8@lizzy.crudebyte.com>) id 1kOKZS-00029E-0j for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:53:58 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:37299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <08d91b5509f34ca77940588e0bbe530408f9f8b8@lizzy.crudebyte.com>) id 1kOKZQ-0008V0-4E for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:53:57 -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=EhDGb gM+cUceHATB5uVzPRygsEzE0DOlsxqz+WB+OMLPu3s2n72E6o8j+/WiQ0TEebm/9B9lhkC2avS+Hp A3H8iEGjCR9jpsqTOIyd8pI1+ODGPllHFwjrtwX2udQ23KySZI31oQW051DtEGG3+ag0F41U9fIIo Jr8y7v2cXTcqHX7Ba0Bk/ZQWgH/fPEtVZ1YOPbvbGCNd7AbrQ7zWB2CQYYQKtYSSoDQU06uJzN1W2 hEnoyzIJlNdwtXFIyEGSR6gh3Ph7m5vu+xjEDABY/TCVfuNmbhh/EzK7eb7kfaj4QheOrXsh8GHkn dPAWjWhkSlVn6WDpTV7+g9tn/92gA==; Message-Id: <08d91b5509f34ca77940588e0bbe530408f9f8b8.1601639563.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=08d91b5509f34ca77940588e0bbe530408f9f8b8@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 13:14:44 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=1601643361; cv=none; d=zohomail.com; s=zohoarc; b=CizgDqQwCgM8yJX65PD1VrwxcpWvvWC5Fig9hUHuEofPmN1i+dA7qOCkj8chPtLj+Ax+pfT2A3kt+9h//+VC75VR80r19IK6fnmZaNgI3kBvqsVk+nUksELotwvnNX1OASHa1J+HoTjXGFlEhWlplIkWt83JuwLdTivnJBno3mA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601643361; 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=efUiofG1s/e53ObZOXEFHcOmWzjcLuBHHBURfsEwvCPgons6w3qR+A3ey+x0H7BcKE8XcLOnNEiByhmp7o+2zvNc2Omdf4M0wLNae3IuR6xqIfyAyn3gv9z6RVYehAD4HE5EoOqQivYyTfkZR+F8GJaHYpRGZZ8Zg4NigG7Yyqg= 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 1601643361583192.8681486876111; Fri, 2 Oct 2020 05:56:01 -0700 (PDT) Received: from localhost ([::1]:58344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKbQ-0003Ty-9J for importer@patchew.org; Fri, 02 Oct 2020 08:56:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOKWL-0007eM-Mo for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:50:45 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:38645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOKWI-00086b-0k for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:50:45 -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=Yk9SC lGa8aRAqMSwtn2atRBqRcgktwQvkoRW13SuQFOKspJm3LOia7DSQOW1G9D/r8PjAJQ4Sf7KVl+Vxi e1osGX6Sec8YI7sUyNltCY/zLAbh+QAm4MnLiwXna6ZBKViroUc36QvV6btkNLqWT3oWOkyBsE0fZ CngCHSEsnYgJyQ1RIMv2ab9GWkVpaNfOlndhM2YF8t/WbGv8OanVutcyCZ0YBc6Gd7hMjUj2S0R4r Zrhxm/NDj/vp47o643jsYaRm/zmdIuDcBaPVIW0ZeTVYGbYrbTvr10aqz2hpr7qRE/neFPlyk/c9c DU66/+YODj9reWJ1P8qj/QobCUS/Q==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=e8cf7c5bbbfe34f5ba211c7133861f081db82285@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 13:14:44 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=1601643164; cv=none; d=zohomail.com; s=zohoarc; b=XUrIMFHPsW66AB2fW1tt1Chd0hSqZVU22NggXHBIwTlOp/GkRj3ZitH99htltRVrxH6n7Lv+BdLi3we3HBh+5tJQk53ttCBuGmSNgrlTwUc0bTb75hrgq9Ll8VxzV/606W0AN2GpLx5iMIgsvzBIcvLOgrfs3/YoKaA/6uZbL7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601643164; 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=IH4BNYL8KBfbvFWWHzfuA5V0s5X1X90X9X8tJMNOD9/iR0+jjmdVHN+RGCbqgs2aJMMAA+n5hznBuf4I29HDcXjxyZRlEQF3wh6Pfk/9FoH1CJsLonnvMaYEIYD+Le0K/D+AJyz8reLOaptNc6AZ/Iz+Eikmt8cIIfUOOpWLzO0= 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 1601643164818196.81963221123397; Fri, 2 Oct 2020 05:52:44 -0700 (PDT) Received: from localhost ([::1]:52368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKYF-0000nr-En for importer@patchew.org; Fri, 02 Oct 2020 08:52:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3cee259a12ba78f1ea2655983297add0b46254f6@lizzy.crudebyte.com>) id 1kOKUG-0005R3-Pg for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:48:36 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:57723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3cee259a12ba78f1ea2655983297add0b46254f6@lizzy.crudebyte.com>) id 1kOKUE-0007yg-6B for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:48: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=Cyyld5a/6X2z/GHtUILwJZBN75BuasEc9WQ7betFIyk=; b=Rg4i2 fiL7tBIOQjItgbPsInrdNQdDPFsp6l9CNzJBqI/8tl3mNG0pGke3AuOAK+xxjzoVSbSpu1ifPgFA0 Y/IechyEtVuk0qIt8Xx9RMs1maGqPLjbf6iJlW4vfk3fG+FtHCHzcLxaj4PWDg44Sy2WjW7QGzLi1 eBD/m0WnPdhFpitIM9vVT89x+syKc87ezbtE4njmh588uN62vVDfJJ50hPPIol+d9aMrOqF4zcuWs 8TByH/Oerle99PAeeVi2g9hGyBa1g2oGrOE5xLdjgH7S7YYdJ4NWpMSZkHcwocevZgLiIvsUQZTPL mZg9Let/kIoXD4Ah3vnolxuRj8iFA==; Message-Id: <3cee259a12ba78f1ea2655983297add0b46254f6.1601639563.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=3cee259a12ba78f1ea2655983297add0b46254f6@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 13:14:44 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=1601643625; cv=none; d=zohomail.com; s=zohoarc; b=XVphQu1jMIFpH9TH9uRAMUOTAE6WLDG3i4gd1D7DKB/e1oYdkCucOerpCJRukGhn4vMZkoX80VN8EHoM1xsfeEPPJxy1ddMF0UgI1YGhd26zjutYNfx6UGbxZajx4sXDbnU69d64R6TOj3mEx0bqKwblF/wuiZYcMW4TjHVnUzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601643625; 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=oIKs5ZsXs41KzMD3PdxUpjGrim7lD8bVJvi97ERpYwmoZpw9CyFLAXxo8p+ZcG2cPVguy9Gq/qpb7acq2XxwMg6UrJn45WNYeW9RoAeGGK3EvJt1JRJM6CWWX7SouOGhMQL7Ud6VbFvSwpQaMtVA7H826KelLQwRcu1IlqQ+xS0= 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 1601643625801393.92339574099583; Fri, 2 Oct 2020 06:00:25 -0700 (PDT) Received: from localhost ([::1]:41186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKfd-00084V-Vk for importer@patchew.org; Fri, 02 Oct 2020 09:00:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <07adc676da3e54a43dce2de8d03b3ce0a15e0d8f@lizzy.crudebyte.com>) id 1kOKbT-0003vl-7a for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:56:03 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:37777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <07adc676da3e54a43dce2de8d03b3ce0a15e0d8f@lizzy.crudebyte.com>) id 1kOKbR-0000DM-K6 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:56:02 -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=OjdH+ HiDUurSIZel5kN1R2xaHfSPNR/RoDk6pP3cnLY5j1p2qQZ6eTUO/5G9cPMpYtmx2CZWqTZgAgYmSQ ANxHxvHY3klWG9L4/nkdDr17UU92jcONxLXAT0XiL7Zc4y3TNdMuqayQPHvnKoQS/vevLFeLj9EHD kKTEp9voTSZz98D/C7cdRyacLHebd0tpuQx13glHWefHSvx9LJePlDZ4+0TYsrumcDuTiwq8Ror4c tLx50XFElQ146vBVyPt8aEeWozExirqT7gM0FnD9yBAEH3ttq3bXuCSqB7NrZq24e62ulYQ4TSS/3 Fj9Rs0iguTe6ILMn3DqwVXgy3XJIg==; Message-Id: <07adc676da3e54a43dce2de8d03b3ce0a15e0d8f.1601639563.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=07adc676da3e54a43dce2de8d03b3ce0a15e0d8f@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 13:14:44 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=1601643239; cv=none; d=zohomail.com; s=zohoarc; b=HmQBW3qTbrdYaYuqwCGmt2/BeBz3f99sxnY4D/Os2Pofmi2cnwHnRSVenLR0tnPIlXSRO6KXYf73XBFpW4rNRaIIkqnGOzXim47ZBo7eVw+ffjGrb9NWf4qJhUR9gpOy30NFGTAiewi69dnvFHwiaEjCgz3nLLEpe2JEtTOEPg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601643239; 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=ArdSafDNH8fU1eV2hZOAo5/K+AnCosiENO5jej9V74SKF6C//nO86m5obpv9kpcmJ/z7RxNw3PmwNwrP6JCga+uwBWqN6i1foYevHQTEO7UfpWWxsnwqUhfgq6pRZoSeUeG8orwljKTncoeO8KMfuCklBgBcPrg975W4KZJNDDc= 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 1601643239629917.2702186877435; Fri, 2 Oct 2020 05:53:59 -0700 (PDT) Received: from localhost ([::1]:54938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKZS-0001uv-BJ for importer@patchew.org; Fri, 02 Oct 2020 08:53:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <813e27cea046e75b0c8a249637a4ebf20d687d02@lizzy.crudebyte.com>) id 1kOKYQ-0001FS-S6 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:52:54 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:56089) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <813e27cea046e75b0c8a249637a4ebf20d687d02@lizzy.crudebyte.com>) id 1kOKYP-0008Q6-Ac for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:52:54 -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=bQRIG I8CdoDpZkhpZnGOVGeDZstJRMUzzuBJhAWzWi0J4/bP/r+oCstfOlA0Fy7FkoG78hHrWcQS3Wv5Ix 72p6+dvc1BmXx21dtwFea7WQLZKrBuPvLZZX4y7/mHNsFKXZxKBkn4QFaUdk3lwPHHjm8QRfjCF0c P2RDIIrEEzxJNSh2HJzLS9JRv3Y3m1q8EN8PYsVtm7tE0azKqRKaTouJ5gWVTLmuzL55iAYU1VbrY k3hAI0wUgAr8xK2sxgBfTxdds9iQKj9GQMoPHElCv+fZbSZCSNM84M3soJS8Va2wvazgjxYV1Xgzx INFHJw++hVU9sGa6Bm3TNP72emLDA==; Message-Id: <813e27cea046e75b0c8a249637a4ebf20d687d02.1601639563.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=813e27cea046e75b0c8a249637a4ebf20d687d02@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 13:14:44 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=1601643059; cv=none; d=zohomail.com; s=zohoarc; b=Qji56t3xvZsZMBdYrlKaMfnwobw3W+Gt4EQtu40slKGYk96FNqUS9XXptwJupaLHahRvYGKmyxfn/9iZonciN9CE6W0yVIlfX93Ak+XuokFDT3/8cwZf3oQ4NgYbWbtsWfUhYEj6UeykmRe0/+hy7JIC+TGMDvGExyqMRE7bs2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601643059; 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=EV2/Kda2rkxQ49xOj4ZAQCzKkkpZdURmQpBSMMPx9AqrLzjvPQ3RhOkj3gDpY0hU1bFvhAisbd2RuHEZdAUXcJSW3BzSx0PWcBm1cpXcs1uWVeQVT6uWLZ+e3SV5qgHp+V9X4i7ULKg2Hft+6qpBTO1UPrqCpfwBXX7exm7aFfw= 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 160164305995478.81468947455357; Fri, 2 Oct 2020 05:50:59 -0700 (PDT) Received: from localhost ([::1]:48722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKWY-0007b5-NI for importer@patchew.org; Fri, 02 Oct 2020 08:50:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3d40fd3055d064497e7f2ec92b759dac824e55bb@lizzy.crudebyte.com>) id 1kOKVJ-0006IR-1p for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:49:41 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:49785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3d40fd3055d064497e7f2ec92b759dac824e55bb@lizzy.crudebyte.com>) id 1kOKVH-00082r-EU for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:49: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=61K9IPek47Lb/jUIgvqHI9x1BIex8Psn2YIHGCS3rpk=; b=B+UZX RvxdX7SDrk+Z0B7EOukhDM5vOzLRCOQGgCN4yu6z3sWXDdkcRaoLkZTPIlw2H30kIhGjqZslxvFJw QeTiyFZT1ghA4THo4pSMwDlSuGIFv/1MEo3a/ler766bpVQCKQxZCTvXF9fXs2pUzpLtCgRD39XgZ iBXZcgfakUIs3xR9/qVPDrRoVs0au9ZkcVOTOfJF/vF4d2Ae6FXexxu6ObjtM3TUs0CszNcAEQKwT JHoK4lu3X8IaszOF+jCZR5gGBdqFBdyHiuaGSjIQieOx2IzNS72TFsUIahgo7499v+DIL/AldPdaq kD2BHOPGI8ZlbDUe+Kx16G5qRHRGg==; Message-Id: <3d40fd3055d064497e7f2ec92b759dac824e55bb.1601639563.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=3d40fd3055d064497e7f2ec92b759dac824e55bb@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 13:14:44 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=1601642998; cv=none; d=zohomail.com; s=zohoarc; b=HdAwdmzm1KYD5rStJU/hJv17sJK2kYR91xmrUpI+jv5LIvgsH9YURVDaeYmxGzRlVh9eP6SCJwPs55/5rjas4ZYDxFhwnjFwStQX2d00wJHUvIXjNNpaolF4bslV0GIIYri74HnLvsV84RqcenzGi4Nt1MAhk99MLepFdYOPHAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601642998; 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=/aSVUozxY1tMmMejsjPy+mqBzCD41WyLrj4EhDow/XE=; b=fipkrQyKugxNrNxsLr8DQSYhspgm/pdSqkFK4H6Vw9xt8YeUdOsxtACyWbX11ocghjL294QlHfKF8lBn26l98UhfqlxS8gR+evY0tsAfVN3CaReTnMMVDHmvaqjGd3sBRvtC2tY6x2O5wu+5TA5GZL9B0zIjXfUCEvR62fZMSsE= 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 1601642998401673.8023210055568; Fri, 2 Oct 2020 05:49:58 -0700 (PDT) Received: from localhost ([::1]:45630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKVZ-0006GP-6k for importer@patchew.org; Fri, 02 Oct 2020 08:49:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <8dd7d15176ca1e947054dd6891e478cdf7902f7e@lizzy.crudebyte.com>) id 1kOKTF-000454-6n for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:47:33 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:36651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <8dd7d15176ca1e947054dd6891e478cdf7902f7e@lizzy.crudebyte.com>) id 1kOKTD-0007si-6f for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:47:32 -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=/aSVUozxY1tMmMejsjPy+mqBzCD41WyLrj4EhDow/XE=; b=gByHI 1eituVnGJj+mOvnC/lr6oQrHbUtpORhBnE6nmT7OI6KMofV7t4K9WqMmx3P5qMx30MhxRZEGTp+Rm blkcNei39wItdc24UrUElEr5QYMZrm6VHD1IZGFo87JsGHVOMgUrhg1cufXVyusRj61uzFZch6Fqd h568aMvP7dzvDC9OUPzCsg6LVzhppU0QlHSR8gGXIysrmYtcS4Z8t+1Hsne4Q+JsRvUqRQ3mc1tNm K9KycljeXHKNTYQZS14iZpljwW/QMc5Nrwk6zDxf4713Ba3ZYNCmyz25JqQ6vlZWJDlrPb9gvuMnw AtiTka8Rsnf9Sz/0h0TGzX+xeLhbQ==; Message-Id: <8dd7d15176ca1e947054dd6891e478cdf7902f7e.1601639563.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 08/11] tests/9pfs: introduce local tests To: qemu-devel@nongnu.org Cc: Thomas Huth , Laurent Vivier , Paolo Bonzini , Emanuele Giuseppe Esposito , 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=8dd7d15176ca1e947054dd6891e478cdf7902f7e@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 | 100 +++++++++++++++++++++++++++++++++ tests/qtest/libqos/virtio-9p.h | 5 ++ tests/qtest/virtio-9p-test.c | 44 ++++++++++----- 3 files changed, 135 insertions(+), 14 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 2e300063e3..86e40e5d56 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -24,6 +24,63 @@ #include "qgraph.h" =20 static QGuestAllocator *alloc; +static char *local_test_path; + +static char *strpr(const char* format, ...) GCC_FMT_ATTR(1, 2); + +/* Concatenates the passed 2 pathes. Returned result must be freed. */ +static char *concat_path(const char* a, const char* b) +{ + const int len =3D strlen(a) + strlen("/") + strlen(b); + char *path =3D g_malloc0(len + 1); + snprintf(path, len + 1, "%s/%s", a, b); + g_assert(strlen(path) =3D=3D len); + return path; +} + +/* + * Lazy sprintf() implementation which auto allocates buffer. Returned res= ult + * must be freed. + */ +static char *strpr(const char* format, ...) +{ + va_list argp; + + va_start(argp, format); + const int sz =3D vsnprintf(NULL, 0, format, argp) + 1; + va_end(argp); + + g_assert(sz > 0); + char *s =3D g_malloc0(sz); + + va_start(argp, format); + const int len =3D vsnprintf(s, sz, format, argp); + va_end(argp); + + g_assert(len + 1 =3D=3D sz); + return s; +} + +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 +203,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 strpr("\\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 strpr("\\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 13:14:44 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=1601643473; cv=none; d=zohomail.com; s=zohoarc; b=g+yh/n/wmzzuIav3arp27/EyrXfIgM6lLOf94OPHn1yAKzZ3scU0B2HmBShi03rYOE2kEjz2ZLRmA7zjJN++5F7G1PT+EIUCC0yMPYtnA6Wjv4q5PHao11xt6Rpe9nLH3IdI3d74MCg5BCrxZr4EmETm71wmAwuGA0p6uZVK2Ts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601643473; 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=AnO5hDBjL13vnsmw8rZQ8n8acmgU4cSW+h2SSlexQGo=; b=NEjkngjJW1omty68+WM0CpgWNt4lI800rwIvWfizJEmTZtnCsV/237reGKbSLNAZHZSet/IphchGM3gk+R8RUmJnjjh6q/havp5f+Ieb0twLjOQYTu5WPpLbisDlrAjZQhTmf43q3H0EYsNyk8pXCctC+RWerdDkWLr0lsXK30M= 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 1601643473567161.21772860835438; Fri, 2 Oct 2020 05:57:53 -0700 (PDT) Received: from localhost ([::1]:34318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKdE-0005ER-7t for importer@patchew.org; Fri, 02 Oct 2020 08:57:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOKXP-0000Ss-U5 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:51:53 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:59039) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOKXM-0008K0-1v for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:51:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=AnO5hDBjL13vnsmw8rZQ8n8acmgU4cSW+h2SSlexQGo=; b=lbqA8 45CJu2X5ca51znopA8OYHtd1OkuLulyXFFROBUSr9aec5OrvXDgRRijoW2V+LszAjIf6ug0pbM/F6 lH5wMDKaeQqn21VPElijio63aPBlcG1+R6Xcnjf9Ms/hZx4mCmLFfdKNu4SYF9nqTtHYVnVXZbQ6U Cv6xDzJyawLtaw/O457pupTRyssrXRm5eu+gD6oo59yhyqhzRYIN36XeGZzv5SpjT5EKQT1wyZc7T X+vNKncE4voieKp4prCdraU+zjhyc95o1TrWMfmj3NHNi+5HZQCEp/xsqj1ixDV0EgibWxEXxJuUn 3aFRCxhwso3yZn5UWh10Gd5dOyOOA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=a6b048f6393d0d8dfcf760dc875557ea15addc2a@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 86e40e5d56..6cd8c8964b 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -82,6 +82,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 strpr("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); @@ -249,6 +261,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 13:14:44 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=1601644505; cv=none; d=zohomail.com; s=zohoarc; b=R/U7fplcw7pepBHRj8W3L1zb095w94xdQylIbHIuV5EKieDadC2xl9LvVhflYB4GnXpE5oCxoJBTndtkrJOdlFR/8ethvJcE7cC1i3u+Zlo8aQJfdF7b7onl4v2fm69KakIj8wL6jL1jINcvesOI3iMHLLMqF6aD5cLJnc/12Sc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601644505; 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=9m93UYLD/NDIZCFxgSGIgUg0vmHl3SG20Z+QrKQmnlQ=; b=E3ICWqa6cSFGwU3ZqlEm+2MU6Yf4MDCAj+Vh1HSW43S2nRs7jQ+95gtyKNb0pZNqp96vcjQqcyUtN5eObt8vwFVYn+EHC8MmWDZ0ULzgUrVZRZmhYlAFcDkLu4B8U76ZEXkPQoArfPvC2gI9oaCmZ+wt0/WvzNg/MIJ6wbSpPVE= 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 160164450592662.78740060504822; Fri, 2 Oct 2020 06:15:05 -0700 (PDT) Received: from localhost ([::1]:34970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKts-0001J9-AW for importer@patchew.org; Fri, 02 Oct 2020 09:15:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <7e9d9494ddabbed819301398b434510088f4eb6d@lizzy.crudebyte.com>) id 1kOKsm-0000tv-81 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 09:13:56 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:59953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <7e9d9494ddabbed819301398b434510088f4eb6d@lizzy.crudebyte.com>) id 1kOKsk-0002hD-B6 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 09:13:55 -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=9m93UYLD/NDIZCFxgSGIgUg0vmHl3SG20Z+QrKQmnlQ=; b=lewvi jjOAq58syeN858IUUcfFCMtq7VETdvR1Ba8tloS8xirpdV99P64MnxHlFf53kJ5HMP1gebx+Sgq+k ZG2NLV+LLaW93j5QLwysk1EVdmE5k21CmfrSYmHismPSDYBTGnwDSNiEEqbjE5baY+k9Sm+UgGvaX k7c0r+6m4b+39LAIi1JaM0q+9yXDJWfT1LmrRnmGzHBftrImyCkD+4+fTr1XHxJFUzXS9KbV1UYhr TTIrGq30TC8VcX4YZIffhpPZrr96Heo0Bg1BFjUwSg2JOdE0lOVvp2aV9V1UlvIkGgSZpwg1m3dKc lEsROMVaNAd2rZhTRoiHzohmJfEZQ==; Message-Id: <7e9d9494ddabbed819301398b434510088f4eb6d.1601639563.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=7e9d9494ddabbed819301398b434510088f4eb6d@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 6cd8c8964b..ccab889a2b 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -94,6 +94,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 13:14:44 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=1601642905; cv=none; d=zohomail.com; s=zohoarc; b=IUnVH7qnWmWI50+9QlTcqP7BExo5/S2v1EOoOSHQHsj+c/4oOAHP1nSHqLRNA3Y4lA5WmHB896tB5h09rKLIV6E/s3DHoTz8Yl99Jy6MDDHOpJRowY58XWRXiNqP8ysnSjCs2RV0pHEKZun3DeJ0+6sY9h1f2e3QriwKZJ0a9is= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601642905; 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=eKHKjk30AuNXqAIu1uQvHPy7y5hzJkZXr5LlBDStaTA=; b=ZdAFQuHrRiKRa16zTfQuoaWcXje3WHugKb0WDyiicJEWWuXMCLaIA/rPeJFxDalGU2tk8EG9YW+zLB8mXfSdCf2nZd0tghjTQS+x+Hbr54fieEGqKdp/9AkW8KOkd/sieBuUC+I3tkhKAise6NMy+5QXUI5sOMpboUnTZvxTjrk= 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 1601642905258349.96781828605856; Fri, 2 Oct 2020 05:48:25 -0700 (PDT) Received: from localhost ([::1]:42858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOKU3-0004rs-Qh for importer@patchew.org; Fri, 02 Oct 2020 08:48:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9488e95ff86b6ceea0254dab6a7dff67cbe0bf16@lizzy.crudebyte.com>) id 1kOKQu-0002LY-23 for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:45:08 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:52199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9488e95ff86b6ceea0254dab6a7dff67cbe0bf16@lizzy.crudebyte.com>) id 1kOKQp-0007Oe-5P for qemu-devel@nongnu.org; Fri, 02 Oct 2020 08:45: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=eKHKjk30AuNXqAIu1uQvHPy7y5hzJkZXr5LlBDStaTA=; b=NSSqc FzCpEDYfoN4k02VUtwk9oUb+9dwQoVzIVQC9u+wpCsZbweMEFD/I35VB8+rlIPl7xs+c9Y3iyOgBi sKpZ//Z36eubDoVM86P4NrwLLjxlNSkp6NVvoUizgvVOcQYyjxe4w6JXNY/qb3tNlIzvFD98L05qW jxgOClX+CN1OSjai5PaYyEudrsx9x9FfKvNXjPv8fJiCnDiHRRYP9c1qMA7DlM/qQJTeafmk2qwLC 9L+yXWRxpoKiwF/IqUywikX7xNPqfRpneLZKoW2vIgUAxj6H54WpKY8yuUA+Cr8zKu92Vu83tCMTd 2h0jKS/sH/xN2YCFjLqqnP5P2wCew==; Message-Id: <9488e95ff86b6ceea0254dab6a7dff67cbe0bf16.1601639563.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Fri, 2 Oct 2020 13:51:54 +0200 Subject: [PATCH v2 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 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=9488e95ff86b6ceea0254dab6a7dff67cbe0bf16@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. 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..93161a4b35 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_malloc0(n * sizeof(char *) + 1); /* last element NULL delim= iter */ + + 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