diff mbox series

[2/3] docs/devel/qtest: Include protocol spec in document

Message ID 20201005205228.697463-3-ehabkost@redhat.com
State New
Headers show
Series docs: Include QTest protocol and libqtest API on documentation | expand

Commit Message

Eduardo Habkost Oct. 5, 2020, 8:52 p.m. UTC
Include the QTest Protocol doc string in docs/devel/qtest.rst,
after converting it to use Sphinx syntax.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 docs/devel/qtest.rst | 12 ++++++--
 softmmu/qtest.c      | 73 +++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 75 insertions(+), 10 deletions(-)

Comments

Paolo Bonzini Oct. 7, 2020, 11:03 a.m. UTC | #1
On 05/10/20 22:52, Eduardo Habkost wrote:
> + * DOC: QTest Protocol

> + *

> + * .. highlight:: none

>   *

>   * Line based protocol, request/response based.  Server can send async messages

>   * so clients should always handle many async messages before the response

>   * comes in.

>   *

>   * Valid requests

> + * ^^^^^^^^^^^^^^

>   *

>   * Clock management:

> + * """""""""""""""""

>   *

>   * The qtest client is completely in charge of the QEMU_CLOCK_VIRTUAL.  qtest commands

>   * let you adjust the value of the clock (monotonically).  All the commands

>   * return the current value of the clock in nanoseconds.

>   *

> + * .. code-block::


What version of Sphinx do you have?  I need to have ".. code-block::
none" here, so presumably the "highlight" directive is newer than my
version (1.7.6, pretty old I admit)?

Paolo
Eduardo Habkost Oct. 7, 2020, 11:39 a.m. UTC | #2
On Wed, Oct 07, 2020 at 01:03:21PM +0200, Paolo Bonzini wrote:
> On 05/10/20 22:52, Eduardo Habkost wrote:
> > + * DOC: QTest Protocol
> > + *
> > + * .. highlight:: none
> >   *
> >   * Line based protocol, request/response based.  Server can send async messages
> >   * so clients should always handle many async messages before the response
> >   * comes in.
> >   *
> >   * Valid requests
> > + * ^^^^^^^^^^^^^^
> >   *
> >   * Clock management:
> > + * """""""""""""""""
> >   *
> >   * The qtest client is completely in charge of the QEMU_CLOCK_VIRTUAL.  qtest commands
> >   * let you adjust the value of the clock (monotonically).  All the commands
> >   * return the current value of the clock in nanoseconds.
> >   *
> > + * .. code-block::
> 
> What version of Sphinx do you have?  I need to have ".. code-block::
> none" here, so presumably the "highlight" directive is newer than my
> version (1.7.6, pretty old I admit)?

I have 2.2.2.

It looks like we should really add code to print a warning if not
running Sphinx 2.x.
Paolo Bonzini Oct. 7, 2020, 12:01 p.m. UTC | #3
On 07/10/20 13:39, Eduardo Habkost wrote:
>> What version of Sphinx do you have?  I need to have ".. code-block::
>> none" here, so presumably the "highlight" directive is newer than my
>> version (1.7.6, pretty old I admit)?
> I have 2.2.2.
> 
> It looks like we should really add code to print a warning if not
> running Sphinx 2.x.

1.x seems to work just fine though, and it's what is included in RHEL8
"CodeReady Linux Builder" repository
(https://developers.redhat.com/blog/2018/11/15/introducing-codeready-linux-builder/).

Paolo
diff mbox series

Patch

diff --git a/docs/devel/qtest.rst b/docs/devel/qtest.rst
index 86dec84a0ba..3bf9ebee7f0 100644
--- a/docs/devel/qtest.rst
+++ b/docs/devel/qtest.rst
@@ -4,8 +4,8 @@  QTest Device Emulation Testing Framework
 
 QTest is a device emulation testing framework.  It can be very useful to test
 device models; it could also control certain aspects of QEMU (such as virtual
-clock stepping), with a special purpose "qtest" protocol.  Refer to the
-documentation in ``qtest.c`` for more details of the protocol.
+clock stepping), with a special purpose "qtest" protocol.  Refer to
+:ref:`qtest-protocol` for more details of the protocol.
 
 QTest cases can be executed with
 
@@ -56,3 +56,11 @@  from the output of
 
 which you can run manually.
 
+
+.. _qtest-protocol:
+
+QTest Protocol
+--------------
+
+.. kernel-doc:: softmmu/qtest.c
+   :doc: QTest Protocol
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 4e439caec7e..9382fd25439 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -49,92 +49,141 @@  static void *qtest_server_send_opaque;
 #define FMT_timeval "%ld.%06ld"
 
 /**
- * QTest Protocol
+ * DOC: QTest Protocol
+ *
+ * .. highlight:: none
  *
  * Line based protocol, request/response based.  Server can send async messages
  * so clients should always handle many async messages before the response
  * comes in.
  *
  * Valid requests
+ * ^^^^^^^^^^^^^^
  *
  * Clock management:
+ * """""""""""""""""
  *
  * The qtest client is completely in charge of the QEMU_CLOCK_VIRTUAL.  qtest commands
  * let you adjust the value of the clock (monotonically).  All the commands
  * return the current value of the clock in nanoseconds.
  *
+ * .. code-block::
+ *
  *  > clock_step
  *  < OK VALUE
  *
- *     Advance the clock to the next deadline.  Useful when waiting for
- *     asynchronous events.
+ * Advance the clock to the next deadline.  Useful when waiting for
+ * asynchronous events.
+ *
+ * .. code-block::
  *
  *  > clock_step NS
  *  < OK VALUE
  *
- *     Advance the clock by NS nanoseconds.
+ * Advance the clock by NS nanoseconds.
+ *
+ * .. code-block::
  *
  *  > clock_set NS
  *  < OK VALUE
  *
- *     Advance the clock to NS nanoseconds (do nothing if it's already past).
+ * Advance the clock to NS nanoseconds (do nothing if it's already past).
  *
  * PIO and memory access:
+ * """"""""""""""""""""""
+ *
+ * .. code-block::
  *
  *  > outb ADDR VALUE
  *  < OK
  *
+ * .. code-block::
+ *
  *  > outw ADDR VALUE
  *  < OK
  *
+ * .. code-block::
+ *
  *  > outl ADDR VALUE
  *  < OK
  *
+ * .. code-block::
+ *
  *  > inb ADDR
  *  < OK VALUE
  *
+ * .. code-block::
+ *
  *  > inw ADDR
  *  < OK VALUE
  *
+ * .. code-block::
+ *
  *  > inl ADDR
  *  < OK VALUE
  *
+ * .. code-block::
+ *
  *  > writeb ADDR VALUE
  *  < OK
  *
+ * .. code-block::
+ *
  *  > writew ADDR VALUE
  *  < OK
  *
+ * .. code-block::
+ *
  *  > writel ADDR VALUE
  *  < OK
  *
+ * .. code-block::
+ *
  *  > writeq ADDR VALUE
  *  < OK
  *
+ * .. code-block::
+ *
  *  > readb ADDR
  *  < OK VALUE
  *
+ * .. code-block::
+ *
  *  > readw ADDR
  *  < OK VALUE
  *
+ * .. code-block::
+ *
  *  > readl ADDR
  *  < OK VALUE
  *
+ * .. code-block::
+ *
  *  > readq ADDR
  *  < OK VALUE
  *
+ * .. code-block::
+ *
  *  > read ADDR SIZE
  *  < OK DATA
  *
+ * .. code-block::
+ *
  *  > write ADDR SIZE DATA
  *  < OK
  *
+ * .. code-block::
+ *
  *  > b64read ADDR SIZE
  *  < OK B64_DATA
  *
+ * .. code-block::
+ *
  *  > b64write ADDR SIZE B64_DATA
  *  < OK
  *
+ * .. code-block::
+ *
  *  > memset ADDR SIZE VALUE
  *  < OK
  *
@@ -149,16 +198,21 @@  static void *qtest_server_send_opaque;
  * If the sizes do not match, the data will be truncated.
  *
  * IRQ management:
+ * """""""""""""""
+ *
+ * .. code-block::
  *
  *  > irq_intercept_in QOM-PATH
  *  < OK
  *
+ * .. code-block::
+ *
  *  > irq_intercept_out QOM-PATH
  *  < OK
  *
  * Attach to the gpio-in (resp. gpio-out) pins exported by the device at
  * QOM-PATH.  When the pin is triggered, one of the following async messages
- * will be printed to the qtest stream:
+ * will be printed to the qtest stream::
  *
  *  IRQ raise NUM
  *  IRQ lower NUM
@@ -168,12 +222,15 @@  static void *qtest_server_send_opaque;
  * NUM=0 even though it is remapped to GSI 2).
  *
  * Setting interrupt level:
+ * """"""""""""""""""""""""
+ *
+ * .. code-block::
  *
  *  > set_irq_in QOM-PATH NAME NUM LEVEL
  *  < OK
  *
- *  where NAME is the name of the irq/gpio list, NUM is an IRQ number and
- *  LEVEL is an signed integer IRQ level.
+ * where NAME is the name of the irq/gpio list, NUM is an IRQ number and
+ * LEVEL is an signed integer IRQ level.
  *
  * Forcibly set the given interrupt pin to the given level.
  *