aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-02-17 13:04:48 +0000
committerPeter Maydell <peter.maydell@linaro.org>2021-02-17 13:04:48 +0000
commitf0f75dc174b6c79eb78a161d1c0921f82d7f1bf0 (patch)
treee7c899d57931490b7bc760f8e800a4fe42416b55 /tests
parent65d6ae4927d2974bcfe9326c3fdfa0fac5c6295b (diff)
parent366a85e4bb748794b1ae0ca0ccc2d95f316679a0 (diff)
Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging
* HVF fixes * Extra qos-test debugging output (Christian) * SEV secret address autodetection (James) * SEV-ES support (Thomas) * Relocatable paths bugfix (Stefan) * RR fix (Pavel) * EventNotifier fix (Greg) # gpg: Signature made Tue 16 Feb 2021 16:15:59 GMT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini-gitlab/tags/for-upstream: (21 commits) replay: fix icount request when replaying clock access event_notifier: Set ->initialized earlier in event_notifier_init() hvf: Fetch cr4 before evaluating CPUID(1) target/i386/hvf: add rdmsr 35H MSR_CORE_THREAD_COUNT hvf: x86: Remove unused definitions target/i386/hvf: add vmware-cpuid-freq cpu feature hvf: Guard xgetbv call util/cutils: Skip "." when looking for next directory component tests/qtest/qos-test: dump QEMU command if verbose tests/qtest/qos-test: dump environment variables if verbose tests/qtest/qos-test: dump qos graph if verbose libqos/qgraph_internal: add qos_printf() and qos_printf_literal() libqos/qgraph: add qos_node_create_driver_named() sev/i386: Enable an SEV-ES guest based on SEV policy kvm/i386: Use a per-VM check for SMM capability sev/i386: Don't allow a system reset under an SEV-ES guest sev/i386: Allow AP booting under SEV-ES sev/i386: Require in-kernel irqchip support for SEV-ES guests sev/i386: Add initial support for SEV-ES sev: update sev-inject-launch-secret to make gpa optional ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/libqos/qgraph.c99
-rw-r--r--tests/qtest/libqos/qgraph.h36
-rw-r--r--tests/qtest/libqos/qgraph_internal.h12
-rw-r--r--tests/qtest/qos-test.c15
4 files changed, 158 insertions, 4 deletions
diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c
index fc49cfa879..b3b1a31f81 100644
--- a/tests/qtest/libqos/qgraph.c
+++ b/tests/qtest/libqos/qgraph.c
@@ -153,6 +153,7 @@ static QOSGraphNode *create_node(const char *name, QOSNodeType type)
static void destroy_node(void *val)
{
QOSGraphNode *node = val;
+ g_free(node->qemu_name);
g_free(node->command_line);
g_free(node);
}
@@ -286,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 = g_strconcat(" -device ", node->name, NULL);
+ const char *name = node->qemu_name ?: node->name;
+ node->command_line = g_strconcat(" -device ", name, NULL);
}
/* qos_print_cb(): callback prints all path found by the DFS algorithm. */
@@ -631,6 +633,15 @@ void qos_node_create_driver(const char *name, QOSCreateDriverFunc function)
node->u.driver.constructor = function;
}
+void qos_node_create_driver_named(const char *name, const char *qemu_name,
+ QOSCreateDriverFunc function)
+{
+ QOSGraphNode *node = create_node(name, QNODE_DRIVER);
+ node->qemu_name = g_strdup(qemu_name);
+ build_driver_cmd_line(node);
+ node->u.driver.constructor = function;
+}
+
void qos_node_contains(const char *container, const char *contained,
QOSGraphEdgeOptions *opts, ...)
{
@@ -663,7 +674,7 @@ void qos_node_consumes(const char *consumer, const char *interface,
add_edge(interface, consumer, QEDGE_CONSUMED_BY, opts);
}
-void qos_graph_node_set_availability(const char *node, bool av)
+static void qos_graph_node_set_availability_explicit(const char *node, bool av)
{
QOSGraphEdgeList *elist;
QOSGraphNode *n = search_node(node);
@@ -678,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 == QEDGE_CONTAINS || e->type == 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 = g_hash_table_get_keys(node_table);
+
+ for (l = keys; l != NULL; l = l->next) {
+ const gchar *key = l->data;
+ n = 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 = n->qemu_name ?: n->name;
+ if (g_strcmp0(node_name, node) == 0) {
+ n->available = av;
+ elist = get_edgelist(n->name);
+ if (elist) {
+ QSLIST_FOREACH_SAFE(e, elist, edge_list, next) {
+ if (e->type == QEDGE_CONTAINS || e->type == QEDGE_PRODUCES)
+ {
+ qos_graph_node_set_availability_explicit(e->dest, av);
+ }
+ }
+ }
}
}
+ g_list_free(keys);
}
void qos_graph_foreach_test_path(QOSTestCallback fn)
@@ -757,3 +805,48 @@ void qos_delete_cmd_line(const char *name)
node->command_line = NULL;
}
}
+
+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(" <------- 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 ? "available" : "UNAVAILBLE"
+ );
+ }
+ g_list_free(keys);
+ qos_printf("}\n");
+}
diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h
index 5f63d352ca..07a32535f1 100644
--- a/tests/qtest/libqos/qgraph.h
+++ b/tests/qtest/libqos/qgraph.h
@@ -453,6 +453,22 @@ void qos_node_create_machine_args(const char *name,
void qos_node_create_driver(const char *name, QOSCreateDriverFunc function);
/**
+ * 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 create
+ * several instances of the same QEMU device. You are free to choose a custom
+ * 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
* edge hash table.
@@ -570,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
diff --git a/tests/qtest/libqos/qgraph_internal.h b/tests/qtest/libqos/qgraph_internal.h
index 968fa69450..c0025f5ab9 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 {
@@ -254,4 +255,15 @@ void qos_delete_cmd_line(const char *name);
*/
void qos_graph_node_set_availability(const char *node, bool av);
+/*
+ * Prepends a '#' character in front for not breaking TAP output format.
+ */
+#define qos_printf(...) printf("# " __VA_ARGS__)
+
+/*
+ * Intended for printing something literally, i.e. for appending text as is
+ * to a line already been started by qos_printf() before.
+ */
+#define qos_printf_literal printf
+
#endif
diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c
index 8fdf87b183..f97d0a08fd 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)
static void restart_qemu_or_continue(char *path)
{
+ if (g_test_verbose()) {
+ qos_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
@@ -313,15 +316,25 @@ 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()) {
+ qos_printf("ENVIRONMENT VARIABLES: {\n");
+ for (char **env = envp; *env != 0; env++) {
+ qos_printf("\t%s\n", *env);
+ }
+ qos_printf("}\n");
+ }
qos_graph_init();
module_call_init(MODULE_INIT_QOM);
module_call_init(MODULE_INIT_LIBQOS);
qos_set_machines_devices_available();
qos_graph_foreach_test_path(walk_path);
+ if (g_test_verbose()) {
+ qos_dump_graph();
+ }
g_test_run();
qtest_end();
qos_graph_destroy();