qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nir Soffer <nsoffer@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	qemu-block <qemu-block@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Juan Quintela" <quintela@redhat.com>,
	"Yuval Shaia" <yuval.shaia.ml@gmail.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Andrea Bolognani" <abologna@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Michael Roth" <mdroth@linux.vnet.ibm.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Stefan Berger" <stefanb@linux.ibm.com>
Subject: Re: cleanups with long-term benefits (was Re: [PATCH] schemas: Add vim modeline)
Date: Mon, 3 Aug 2020 22:54:14 +0300	[thread overview]
Message-ID: <CAMRbyytzHwfEV2=bxhn3zVR3rUKK9DB0V1CCGgub=CfN0pH7jw@mail.gmail.com> (raw)
In-Reply-To: <6514f2e2-4694-6790-7663-f8a8f6a91e5a@redhat.com>

On Mon, Aug 3, 2020 at 9:19 PM John Snow <jsnow@redhat.com> wrote:
>
> On 8/3/20 2:16 PM, Paolo Bonzini wrote:
> > On 03/08/20 20:10, John Snow wrote:
> >> Heresy:
> >>
> >> Docstrings could become part of the data format so they can be parsed,
> >> analyzed and validated. Parsers largely treat comments like non-semantic
> >> information and discard it. Round-trip parsers that preserve comments in
> >> any language are extremely rare.
> >>
> >> If the docstrings are relevant to the generator and aren't discardable,
> >> they should be fully-fledged data members.
> >>
> >> In a prototype I had for a YAML format, I just promoted docstrings
> >> directly to fields, so I could allow clients to query help text for
> >> individual commands.
> >
> > This would be actually a good idea, but somebody has to write the code.
> >   Each field's docstring should be attached to the field, however---no
> > parsing needed only looking at the tree.  Take a look at what Nir posted:
> >
> >> Here is the patch adding schema convertor from qemu "json" format to
> >> standard yaml:
> >> https://github.com/oVirt/vdsm/commit/e57b69e72987c0929b20306c454835b52b5eb7ee
> >>
> >> The current version of the new yaml based schema:
> >> https://github.com/oVirt/vdsm/blob/master/lib/vdsm/api/vdsm-api.yml
> >
> >
> >      VmDiskDevice: &VmDiskDevice
> >          added: '3.1'
> >          description: Properties of a VM disk device.
> >          name: VmDiskDevice
> >          properties:
> >          -   description: Indicates if writes are prohibited for the
> >                  device
> >              name: readonly
> >              type: boolean
> >
> >          -   description: The size of the disk (in bytes)
> >              name: apparentsize
> >              type: uint
> >
> > etc.
> >
> > Paolo
> >
>
> I was working on a small prototype that used something that looked like
> this; the "*opt" format was traded for "?opt", but otherwise:
>
>
> struct:
>    name: AudiodevPerDirectionOptions
>    doc: >
>      General audio backend options that are used for both
>      playback and recording.
>    since: '4.0'
>    members:
>
>      ?mixing-engine:

This optimizes for writing instead of reading.

    optional: true

Would be nicer to read, but more important is all the tools parsing
this schema in multiple languages that will have code like:

    def is_optional(node):
        return node.name.startswith("?")

Instead of :

   if node.optional:
       ...

Or maybe better:

    if node.required:

Because it seems that more nodes are optional, so focusing on the required
items will make the schema shorter and more clear.

>        type: bool
>        default: 'true'
>        since: '4.2'
>        doc: |
>          Use QEMU's mixing engine to mix all streams inside QEMU and
>          convert audio formats when not supported by the backend.

Using | is nicer than >-. Not sure what is the difference. In vdsm we don't use
anything and I think it causes trouble when indenting text.

>          When set to off, fixed-settings must be also off.
>
>      ?fixed-settings:
>        type: bool
>        default: 'true'

Why is the default a string and not the actual type?

>        doc: >-
>          Use fixed settings for host input/output.
>          When off, frequency, channels and format must not be specified.
>
>      ?frequency:
>        type: bool
>        default: '44100'
>        doc: >-
>          frequency to use when using fixed settings.
>
>      ?channels:
>        type: 'uint32'
>        default: 2

Here you use the real type, and this is nicer.

>        doc: >-
>          Number of channels when using fixed settings.
>
>      ?voices:
>        type: 'uint32'
>        default: 1
>        doc: "Number of voices to use."
>
>      ?format:
>        type: 'AudioFormat'
>        default: 's16'
>        doc: "Sample format to use when using fixed settings."
>
>      ?buffer-length:
>        type: 'uint32'
>        doc: 'The buffer length, in microseconds.'
>
>    features:
>      my-cool-feature:
>        since: '6.0'
>        doc: 'This is, no doubt, an extremely cool feature.'
>
>      my-bad-feature:
>        doc: 'This is a very bad feature. I am sorry for making it.'
>        since: '1.0'
>        deprecated: '5.9'

Good example :-)

>
>



  reply	other threads:[~2020-08-03 19:55 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 18:50 [PATCH] schemas: Add vim modeline Andrea Bolognani
2020-07-30  9:07 ` Markus Armbruster
2020-07-30  9:37   ` Daniel P. Berrangé
2020-07-30 11:51     ` Markus Armbruster
2020-07-30 13:24       ` Daniel P. Berrangé
2020-07-31  6:45         ` John Snow
2020-07-31  9:21           ` Markus Armbruster
2020-07-31  9:32             ` Daniel P. Berrangé
2020-07-31 12:55         ` Markus Armbruster
2020-07-31 15:07           ` Daniel P. Berrangé
2020-07-31 15:26             ` John Snow
2020-07-31 15:44               ` Daniel P. Berrangé
2020-08-03  7:28                 ` Markus Armbruster
2020-08-03  8:41                 ` Paolo Bonzini
2020-08-03 11:24                   ` Markus Armbruster
2020-08-03 11:36                   ` Daniel P. Berrangé
2020-08-03 12:16                     ` Paolo Bonzini
2020-08-03 12:23                       ` Daniel P. Berrangé
2020-08-03 12:33                         ` Paolo Bonzini
2020-08-03 12:43                           ` Daniel P. Berrangé
2020-08-03 15:48                         ` Markus Armbruster
2020-08-03 21:02                         ` Nir Soffer
2020-07-31 16:35               ` Paolo Bonzini
2020-07-31 16:41                 ` Dr. David Alan Gilbert
2020-07-31 17:20                 ` Daniel P. Berrangé
2020-07-31 17:47                   ` Paolo Bonzini
2020-08-03  9:44                     ` Daniel P. Berrangé
2020-07-31 17:53                 ` John Snow
2020-07-31 18:01                   ` Paolo Bonzini
2020-08-03  7:45                     ` Markus Armbruster
2020-07-31 16:28             ` cleanups with long-term benefits (was Re: [PATCH] schemas: Add vim modeline) Paolo Bonzini
2020-07-31 17:05               ` Daniel P. Berrangé
2020-07-31 17:16                 ` Paolo Bonzini
2020-07-31 17:27                   ` Daniel P. Berrangé
2020-07-31 17:42                     ` Paolo Bonzini
2020-08-03  9:27                       ` Daniel P. Berrangé
2020-08-03  8:18               ` Markus Armbruster
2020-08-03  8:42                 ` Paolo Bonzini
2020-08-03 11:28                   ` Markus Armbruster
2020-08-03 12:01                     ` Paolo Bonzini
2020-08-03 16:03                       ` Markus Armbruster
2020-08-03 16:36                         ` Kevin Wolf
2020-08-04  7:28                           ` Markus Armbruster
2020-08-03 17:19                         ` Paolo Bonzini
2020-08-04  8:03                           ` Markus Armbruster
2020-08-04 18:24                             ` John Snow
2020-08-05  7:36                               ` Markus Armbruster
2020-08-05  8:25                                 ` Paolo Bonzini
2020-08-05  8:39                                   ` Dr. David Alan Gilbert
2020-08-05  8:49                                     ` Paolo Bonzini
2020-08-05  9:05                                       ` Daniel P. Berrangé
2020-08-05  9:11                                         ` cleanups with long-term benefits Cornelia Huck
2020-08-05 10:08                                           ` Daniel P. Berrangé
2020-08-05 10:24                                             ` Cornelia Huck
2020-08-05 16:23                                             ` Kevin Wolf
2020-08-05 16:46                                               ` Eduardo Habkost
2020-08-06  5:44                                                 ` Markus Armbruster
2020-08-05  8:47                                   ` Cornelia Huck
2020-08-05  8:56                                   ` cleanups with long-term benefits (was Re: [PATCH] schemas: Add vim modeline) Markus Armbruster
2020-08-05 10:15                                     ` Alex Bennée
2020-08-05 16:04                                 ` John Snow
2020-08-06  4:58                                   ` Markus Armbruster
2020-08-05  8:42                         ` Markus Armbruster
2020-08-03 18:10                       ` John Snow
2020-08-03 18:16                         ` Paolo Bonzini
2020-08-03 18:19                           ` John Snow
2020-08-03 19:54                             ` Nir Soffer [this message]
2020-08-03 20:48                               ` John Snow
2020-08-03  9:50                 ` Daniel P. Berrangé
2020-08-03 11:32                   ` Markus Armbruster
2020-07-31 16:39             ` [PATCH] schemas: Add vim modeline Kevin Wolf
2020-07-30 15:11       ` Eric Blake
2020-07-30 20:53         ` John Snow
2020-07-30 20:56         ` John Snow
2020-07-31  7:15         ` Kevin Wolf
2020-07-31  8:48           ` Daniel P. Berrangé
2020-07-31  9:01           ` Markus Armbruster
2020-07-31 11:26             ` Kevin Wolf
2020-08-03  8:51               ` Markus Armbruster
2020-07-31 23:12     ` Nir Soffer
2020-08-03 12:16       ` Paolo Bonzini
2020-08-04  7:28         ` Markus Armbruster
2020-08-04  8:29     ` Alex Bennée
2020-09-07 13:54   ` Markus Armbruster
2020-07-30 13:14 ` Markus Armbruster

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='CAMRbyytzHwfEV2=bxhn3zVR3rUKK9DB0V1CCGgub=CfN0pH7jw@mail.gmail.com' \
    --to=nsoffer@redhat.com \
    --cc=abologna@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanb@linux.ibm.com \
    --cc=yuval.shaia.ml@gmail.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).