From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: blauwirbel@gmail.com, aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 16/20] qidl: Add documentation
Date: Tue, 14 Aug 2012 17:15:37 -0500 [thread overview]
Message-ID: <20120814221537.GH16157@illuin> (raw)
In-Reply-To: <CAFEAcA-fxhKFRcMeb2M_qCXcPZ7Ecf7nzTiMHe+nEmXeQHKD3g@mail.gmail.com>
On Tue, Aug 14, 2012 at 08:41:56PM +0100, Peter Maydell wrote:
> On 14 August 2012 17:27, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> >
> > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> > ---
> > docs/qidl.txt | 343 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 343 insertions(+)
> > create mode 100644 docs/qidl.txt
> >
> > diff --git a/docs/qidl.txt b/docs/qidl.txt
> > new file mode 100644
> > index 0000000..19976d9
> > --- /dev/null
> > +++ b/docs/qidl.txt
> > @@ -0,0 +1,343 @@
> > +How to Serialize Device State with QIDL
> > +======================================
> > +
> > +This document describes how to implement save/restore of a device in QEMU using
> > +the QIDL compiler. The QIDL compiler makes it easier to support live
> > +migration in devices by converging the serialization description with the
> > +device type declaration. It has the following features:
> > +
> > + 1. Single description of device state and how to serialize
> > +
> > + 2. Fully inclusive serialization description--fields that aren't serialized
> > + are explicitly marked as such including the reason why.
> > +
> > + 3. Optimized for the common case. Even without any special annotations,
> > + many devices will Just Work out of the box.
> > +
> > + 4. Build time schema definition. Since QIDL runs at build time, we have full
> > + access to the schema during the build which means we can fail the build if
> > + the schema breaks.
> > +
> > +For the rest, of the document, the following simple device will be used as an
> > +example.
> > +
> > + typedef struct SerialDevice {
> > + SysBusDevice parent;
> > +
> > + uint8_t thr; // transmit holding register
> > + uint8_t lsr; // line status register
> > + uint8_t ier; // interrupt enable register
> > +
> > + int int_pending; // whether we have a pending queued interrupt
> > + CharDriverState *chr; // backend
> > + } SerialDevice;
>
> "//" style comments are a breach of the QEMU coding style so we shouldn't
> be using them in documentation examples...
>
> > +
> > +In our *SerialDevice* example, the *CharDriverState* pointer reflects the host
> > +backend that we use to send serial output to the user. This is only assigned
> > +during device construction and never changes. This means we can add an
> > +**immutable** marker to it:
> > +
> > + QIDL_START(SerialDevice, state)
> > + typedef struct SerialDevice {
> > + SysBusDevice parent;
> > +
> > + uint8_t thr; // transmit holding register
> > + uint8_t lsr; // line status register
> > + uint8_t ier; // interrupt enable register
> > +
> > + int int_pending; // whether we have a pending queued interrupt
> > + CharDriverState *chr QIDL(immutable);
> > + } SerialDevice;
> > + QIDL_END(SerialDevice)
>
> I think it would be nicer to have a QIDL input format from which the structure
> is generated as one of the outputs; that would avoid having to have some of
> this ugly QIDL() markup.
Some kind of inline/embedded input format, or external (like QAPI
schemas)?
In terms of the ugliness of things, Anthony suggested we re-introduce
the simpler form of the annotations by doing something like:
#define _immutable QIDL(immutable)
as syntactic sugar for the more commonly used annotations/macros. This
can all be done in qidl.h, transparently to the parser (thanks to the
fact that we pass the code through the preprocessor prior to parsing).
There's also a few things we can do to replace the QIDL_START/QIDL_END
pairs with a single indicator.
>
> We could also use this to autogenerate a lot of the QOM required boilerplate,
> qdev Property arrays, etc etc.
QIDL handles properties, and could possibly be used to generate some QOM
boilerplate. We can get as creative as need be really, it's just that
properties/serialization were the primary/initial use-cases.
>
> -- PMM
>
next prev parent reply other threads:[~2012-08-14 22:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-14 16:27 [Qemu-devel] Add infrastructure for supporting QIDL annotations Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 01/20] qapi: qapi-visit.py -> qapi_visit.py so we can import Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 02/20] qapi: qapi-types.py -> qapi_types.py Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 03/20] qapi: qapi-commands.py -> qapi_commands.py Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 04/20] qapi: qapi_visit.py, make code useable as module Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 05/20] qapi: qapi_visit.py, support arrays and complex qapi definitions Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 06/20] qapi: add visitor interfaces for C arrays Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 07/20] qapi: qapi_visit.py, support generating static functions Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 08/20] qapi: qapi_visit.py, support for visiting non-pointer/embedded structs Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 09/20] qapi: QmpOutputVisitor, implement array handling Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 10/20] qapi: QmpInputVisitor, " Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 11/20] qapi: qapi.py, make json parser more robust Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 12/20] qapi: add open-coded visitor for struct tm types Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 13/20] qom-fuse: workaround for truncated properties > 4096 Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 14/20] module additions for schema registration Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 15/20] qdev: move Property-related declarations to qdev-properties.h Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 16/20] qidl: Add documentation Michael Roth
2012-08-14 19:01 ` Eric Blake
2012-08-14 19:41 ` Peter Maydell
2012-08-14 22:15 ` Michael Roth [this message]
2012-08-14 22:20 ` Peter Maydell
2012-08-18 14:19 ` Blue Swirl
2012-08-14 16:27 ` [Qemu-devel] [PATCH 17/20] qidl: parser, initial import from qc.git Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 18/20] qidl: codegen, initial commit Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 19/20] qidl: qidl.h, definitions for qidl annotations Michael Roth
2012-08-14 16:27 ` [Qemu-devel] [PATCH 20/20] qidl: unit tests Michael Roth
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=20120814221537.GH16157@illuin \
--to=mdroth@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=blauwirbel@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).