qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>,
	Greg Kurz <groug@kaod.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v4 04/12] libqos/qgraph: add qos_dump_graph()
Date: Thu, 8 Oct 2020 20:34:56 +0200	[thread overview]
Message-ID: <5f493b816595f0f6fe50a3f83e46432ab48d881b.1602182956.git.qemu_oss@crudebyte.com> (raw)
In-Reply-To: <cover.1602182956.git.qemu_oss@crudebyte.com>

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 <qemu_oss@crudebyte.com>
---
 tests/qtest/libqos/qgraph.c | 56 +++++++++++++++++++++++++++++++++++++
 tests/qtest/libqos/qgraph.h | 20 +++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c
index 61faf6b27d..af93e38dcb 100644
--- a/tests/qtest/libqos/qgraph.c
+++ b/tests/qtest/libqos/qgraph.c
@@ -805,3 +805,59 @@ void qos_delete_cmd_line(const char *name)
         node->command_line = 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;
+
+    qos_printf("ALL QGRAPH EDGES: {\n");
+    keys = g_hash_table_get_keys(edge_table);
+    for (l = keys; l != NULL; l = l->next) {
+        const gchar *key = l->data;
+        qos_printf("\t src='%s'\n", key);
+        list = get_edgelist(key);
+        QSLIST_FOREACH_SAFE(e, list, edge_list, next) {
+            dest_node = g_hash_table_lookup(node_table, e->dest);
+            qos_printf("\t\t|-> dest='%s' type=%d (node=%p)",
+                       e->dest, e->type, dest_node);
+            if (!dest_node) {
+                qos_printf_literal(RED(" <------- ERROR !"));
+            }
+            qos_printf_literal("\n");
+        }
+    }
+    g_list_free(keys);
+    qos_printf("}\n");
+
+    qos_printf("ALL QGRAPH NODES: {\n");
+    keys = g_hash_table_get_keys(node_table);
+    for (l = keys; l != NULL; l = l->next) {
+        const gchar *key = l->data;
+        node = g_hash_table_lookup(node_table, key);
+        qos_printf("\t name='%s' ", key);
+        if (node->qemu_name) {
+            qos_printf_literal("qemu_name='%s' ", node->qemu_name);
+        }
+        qos_printf_literal("type=%d cmd_line='%s' [%s]\n",
+                           node->type, node->command_line,
+                           node->available ? GREEN("available") :
+                                             RED("UNAVAILBLE")
+        );
+    }
+    g_list_free(keys);
+    qos_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, QTestState *qts);
 QOSGraphObject *qos_driver_new(QOSGraphNode *node, QOSGraphObject *parent,
                                QGuestAllocator *alloc, void *arg);
 
+/**
+ * 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 simply
+ * 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 support for
+ * a certain feature).
+ */
+void qos_dump_graph(void);
 
 #endif
-- 
2.20.1



  parent reply	other threads:[~2020-10-08 19:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08 18:49 [PATCH v4 00/12] 9pfs: add tests using local fs driver Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 11/12] tests/9pfs: add virtio_9p_test_path() Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 08/12] tests/9pfs: change qtest name prefix to synth Christian Schoenebeck
2020-10-14 15:25   ` Christian Schoenebeck
2020-10-14 19:38     ` Greg Kurz
2020-10-15  9:16       ` Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 02/12] libqos/qgraph: add qos_node_create_driver_named() Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 07/12] tests/qtest/qos-test: dump QEMU command if verbose Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 09/12] tests/9pfs: introduce local tests Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 10/12] tests/9pfs: wipe local 9pfs test directory Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 05/12] tests/qtest/qos-test: dump qos graph if verbose Christian Schoenebeck
2020-10-24  6:01   ` Thomas Huth
2020-10-24 11:34     ` Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 06/12] tests/qtest/qos-test: dump environment variables " Christian Schoenebeck
2020-10-24  5:56   ` Thomas Huth
2020-10-24 10:57     ` Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 03/12] libqos/qgraph_internal: add qos_printf() and qos_printf_literal() Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 12/12] tests/9pfs: add local Tmkdir test Christian Schoenebeck
2020-10-08 18:34 ` Christian Schoenebeck [this message]
2020-10-24  6:04   ` [PATCH v4 04/12] libqos/qgraph: add qos_dump_graph() Thomas Huth
2020-10-24 11:24     ` Christian Schoenebeck
2020-10-28  5:51       ` Thomas Huth
2020-10-28 13:00         ` Eric Blake
2020-10-28 13:28           ` Christian Schoenebeck
2020-10-08 18:34 ` [PATCH v4 01/12] libqos/qgraph: add qemu_name to QOSGraphNode Christian Schoenebeck
2020-10-19 10:35   ` Christian Schoenebeck
2020-10-24  6:08     ` Thomas Huth
2020-10-24 10:39       ` Christian Schoenebeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5f493b816595f0f6fe50a3f83e46432ab48d881b.1602182956.git.qemu_oss@crudebyte.com \
    --to=qemu_oss@crudebyte.com \
    --cc=berrange@redhat.com \
    --cc=e.emanuelegiuseppe@gmail.com \
    --cc=groug@kaod.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).