1
1
.. _qgraph :
2
2
3
- ========================================
4
3
Qtest Driver Framework
5
- ========================================
4
+ ======================
6
5
7
6
In order to test a specific driver, plain libqos tests need to
8
7
take care of booting QEMU with the right machine and devices.
@@ -31,13 +30,15 @@ so the sdhci-test should only care of linking its qgraph node with
31
30
that interface. In this way, if the command line of a sdhci driver
32
31
is changed, only the respective qgraph driver node has to be adjusted.
33
32
33
+ QGraph concepts
34
+ ---------------
35
+
34
36
The graph is composed by nodes that represent machines, drivers, tests
35
37
and edges that define the relationships between them (``CONSUMES ``, ``PRODUCES ``, and
36
38
``CONTAINS ``).
37
39
38
-
39
40
Nodes
40
- ^^^^^^
41
+ ~~~~~
41
42
42
43
A node can be of four types:
43
44
@@ -64,7 +65,7 @@ Notes for the nodes:
64
65
drivers name, otherwise they won't be discovered
65
66
66
67
Edges
67
- ^^^^^^
68
+ ~~~~~
68
69
69
70
An edge relation between two nodes (drivers or machines) ``X `` and ``Y `` can be:
70
71
@@ -73,7 +74,7 @@ An edge relation between two nodes (drivers or machines) ``X`` and ``Y`` can be:
73
74
- ``X CONTAINS Y ``: ``Y `` is part of ``X `` component
74
75
75
76
Execution steps
76
- ^^^^^^^^^^^^^^^
77
+ ~~~~~~~~~~~~~~~
77
78
78
79
The basic framework steps are the following:
79
80
@@ -92,8 +93,64 @@ The basic framework steps are the following:
92
93
Depending on the QEMU binary used, only some drivers/machines will be
93
94
available and only test that are reached by them will be executed.
94
95
96
+ Command line
97
+ ~~~~~~~~~~~~
98
+
99
+ Command line is built by using node names and optional arguments
100
+ passed by the user when building the edges.
101
+
102
+ There are three types of command line arguments:
103
+
104
+ - ``in node `` : created from the node name. For example, machines will
105
+ have ``-M <machine> `` to its command line, while devices
106
+ ``-device <device> ``. It is automatically done by the framework.
107
+ - ``after node `` : added as additional argument to the node name.
108
+ This argument is added optionally when creating edges,
109
+ by setting the parameter ``after_cmd_line `` and
110
+ ``extra_edge_opts `` in ``QOSGraphEdgeOptions ``.
111
+ The framework automatically adds
112
+ a comma before ``extra_edge_opts ``,
113
+ because it is going to add attributes
114
+ after the destination node pointed by
115
+ the edge containing these options, and automatically
116
+ adds a space before ``after_cmd_line ``, because it
117
+ adds an additional device, not an attribute.
118
+ - ``before node `` : added as additional argument to the node name.
119
+ This argument is added optionally when creating edges,
120
+ by setting the parameter ``before_cmd_line `` in
121
+ ``QOSGraphEdgeOptions ``. This attribute
122
+ is going to add attributes before the destination node
123
+ pointed by the edge containing these options. It is
124
+ helpful to commands that are not node-representable,
125
+ such as ``-fdsev `` or ``-netdev ``.
126
+
127
+ While adding command line in edges is always used, not all nodes names are
128
+ used in every path walk: this is because the contained or produced ones
129
+ are already added by QEMU, so only nodes that "consumes" will be used to
130
+ build the command line. Also, nodes that will have ``{ "abstract" : true } ``
131
+ as QMP attribute will loose their command line, since they are not proper
132
+ devices to be added in QEMU.
133
+
134
+ Example::
135
+
136
+ QOSGraphEdgeOptions opts = {
137
+ .before_cmd_line = "-drive id=drv0,if=none,file=null-co://,"
138
+ "file.read-zeroes=on,format=raw",
139
+ .after_cmd_line = "-device scsi-hd,bus=vs0.0,drive=drv0",
140
+
141
+ opts.extra_device_opts = "id=vs0";
142
+ };
143
+
144
+ qos_node_create_driver("virtio-scsi-device",
145
+ virtio_scsi_device_create);
146
+ qos_node_consumes("virtio-scsi-device", "virtio-bus", &opts);
147
+
148
+ Will produce the following command line:
149
+ ``-drive id=drv0,if=none,file=null-co://, -device virtio-scsi-device,id=vs0 -device scsi-hd,bus=vs0.0,drive=drv0 ``
150
+
95
151
Troubleshooting unavailable tests
96
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153
+
97
154
If there is no path from an available machine to a test then that test will be
98
155
unavailable and won't execute. This can happen if a test or driver did not set
99
156
up its qgraph node correctly. It can also happen if the necessary machine type
@@ -151,7 +208,7 @@ Typically this is because the QEMU binary lacks support for the necessary
151
208
machine type or device.
152
209
153
210
Creating a new driver and its interface
154
- """""""""""""""""""""""""""""""""""""""""
211
+ ---------------------------------------
155
212
156
213
Here we continue the ``sdhci `` use case, with the following scenario:
157
214
@@ -489,7 +546,7 @@ or inverting the consumes edge in consumed_by::
489
546
arm/raspi2b --contains--> generic-sdhci
490
547
491
548
Adding a new test
492
- """""""""""""""""
549
+ -----------------
493
550
494
551
Given the above setup, adding a new test is very simple.
495
552
``sdhci-test ``, taken from ``tests/qtest/sdhci-test.c ``::
@@ -565,62 +622,7 @@ and for the binary ``QTEST_QEMU_BINARY=./qemu-system-arm``:
565
622
566
623
Additional examples are also in ``test-qgraph.c ``
567
624
568
- Command line:
569
- """"""""""""""
570
-
571
- Command line is built by using node names and optional arguments
572
- passed by the user when building the edges.
573
-
574
- There are three types of command line arguments:
575
-
576
- - ``in node `` : created from the node name. For example, machines will
577
- have ``-M <machine> `` to its command line, while devices
578
- ``-device <device> ``. It is automatically done by the framework.
579
- - ``after node `` : added as additional argument to the node name.
580
- This argument is added optionally when creating edges,
581
- by setting the parameter ``after_cmd_line `` and
582
- ``extra_edge_opts `` in ``QOSGraphEdgeOptions ``.
583
- The framework automatically adds
584
- a comma before ``extra_edge_opts ``,
585
- because it is going to add attributes
586
- after the destination node pointed by
587
- the edge containing these options, and automatically
588
- adds a space before ``after_cmd_line ``, because it
589
- adds an additional device, not an attribute.
590
- - ``before node `` : added as additional argument to the node name.
591
- This argument is added optionally when creating edges,
592
- by setting the parameter ``before_cmd_line `` in
593
- ``QOSGraphEdgeOptions ``. This attribute
594
- is going to add attributes before the destination node
595
- pointed by the edge containing these options. It is
596
- helpful to commands that are not node-representable,
597
- such as ``-fdsev `` or ``-netdev ``.
598
-
599
- While adding command line in edges is always used, not all nodes names are
600
- used in every path walk: this is because the contained or produced ones
601
- are already added by QEMU, so only nodes that "consumes" will be used to
602
- build the command line. Also, nodes that will have ``{ "abstract" : true } ``
603
- as QMP attribute will loose their command line, since they are not proper
604
- devices to be added in QEMU.
605
-
606
- Example::
607
-
608
- QOSGraphEdgeOptions opts = {
609
- .before_cmd_line = "-drive id=drv0,if=none,file=null-co://,"
610
- "file.read-zeroes=on,format=raw",
611
- .after_cmd_line = "-device scsi-hd,bus=vs0.0,drive=drv0",
612
-
613
- opts.extra_device_opts = "id=vs0";
614
- };
615
-
616
- qos_node_create_driver("virtio-scsi-device",
617
- virtio_scsi_device_create);
618
- qos_node_consumes("virtio-scsi-device", "virtio-bus", &opts);
619
-
620
- Will produce the following command line:
621
- ``-drive id=drv0,if=none,file=null-co://, -device virtio-scsi-device,id=vs0 -device scsi-hd,bus=vs0.0,drive=drv0 ``
622
-
623
625
Qgraph API reference
624
- ^^^^^^^^^^^^^^^^^^^^
626
+ --------------------
625
627
626
628
.. kernel-doc :: tests/qtest/libqos/qgraph.h
0 commit comments