qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christophe de Dinechin <dinechin@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	"Denis V. Lunev" <den@virtuozzo.com>,
	"Stefan Hajnoczi" <stefanha@gmail.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"John Snow" <jsnow@redhat.com>,
	"Dominik Csapak" <d.csapak@proxmox.com>
Subject: Re: Making QEMU easier for management tools and applications
Date: Tue, 14 Jan 2020 18:31:11 +0100	[thread overview]
Message-ID: <1B253197-5592-472A-AA26-E0614A13C91A@redhat.com> (raw)
In-Reply-To: <87d0bmchq0.fsf@dusky.pond.sub.org>

I started cutting some stuff out.

> On 14 Jan 2020, at 14:04, Markus Armbruster <armbru@redhat.com> wrote:
> 
> Prior art:
> 
>    Presentation
>    KVM Forum 2017: Towards a More Expressive and Introspectable QEMU
>    Command Line
>    https://www.youtube.com/watch?v=gtpOLQgnwug
>    https://www.linux-kvm.org/images/f/f2/Armbru-qapi-cmdline_1.pdf
> 
>    RFC patches
>    https://lists.nongnu.org/archive/html/qemu-devel/2017-10/msg00209.html
>    Message-Id: <20171002152552.27999-1-armbru@redhat.com>
>    https://repo.or.cz/qemu/armbru.git/shortlog/refs/heads/qapi-cmdline

Very useful, thanks.

> 
>> Compatibility is much harder, which is not the least because the
>> existing command line options are bad (primarily: using inconsistent
>> syntax).
> 
> Semantics are just as problematic.

Yes, but often you can leverage something (e.g. JSON, XML, etc)

We could decide that the new QAPI language is a custom implementation
of Python ;-) Or more seriously, we could have some part of the JSON
schema that are “escapes” to C code that we put in some generated file.
I used {{ }} below for this escape, in which case the semantics would be
that of C plus some specific macros we insert in it.

{ 'option': '--add-fd',
 'data': { 'fd': 'int', 'set': 'int', '*opaque': 'str' },
 'help': [
"-add-fd fd=fd,set=set[,opaque=opaque]",
"                Add 'fd' to fd 'set'”] 
 ‘validate’ : {{
    error_if(QOPT.fd < 0, “fd option cannot be negative”);
    error_if(QOPT.fd <= STDERR_FILENO, “fd cannot be a standard I/O stream”);
 }},
 ‘exec’ : {{
    if (do_add_fd(QOPT.fd, QOPT.fset, QOPT.opaque) < 0) {
        exit(1);
    }
 }},

I’m not necessarily saying this is a good idea, mind you.

> 
> You mean the qemu-options.hx.  qemu-options.def is generated from it.

Oh, I had missed that, thanks.

>>> or build configuration (there is a hint of the connection between
>>> the two in the option ‘if’ member in the .json files).
> 
> I'm not sure what exactly you have in mind for build configuration.

I meant what you pointed out wrt. options, that this “language” needs to
know about the qemu configuration. There is ‘if’ today, you pointed
out arch-specific for options. But the configuration itself is yet
another “language” with its own semantics… which JSON knows
nothing about.

> 
>>> In other words, the language I have in mind would be something
>>> that I could auto-generate from, say, the current qapi-schema.json
>>> and the qemu-options.def. Maybe in the end, that would be simply
>>> by having qemu-options.def being used to build qemu-options.json,
>>> and then add the relevant entries in qemu-options.json. Maybe
>>> there is a better way.
>> 
>> I would rather say that .def should go away and its content should
>> be converted to a JSON schema that becomes the new source format rather
>> than an intermediate generated file. There is nothing in .def files that
>> couldn't be represented in the schema.
> 
> Yes.

Agreed too. The meta-schema would need to be extended.

>> 
>> To a certain degree, QAPI does just that, by supporting different data
>> types for options. If necessary, I'm sure the type system could be
>> extended, but it's not clear to me to which degree we actually need
>> this.
> 
> QAPI is much more expressive than qemu-options.hx.  All the latter can
> do is "has option argument" and "option is arch-specific".  QAPI lets
> you specify an option argument's structure, and supports compile-time
> conditionals.  It can't do things like "must specify either argument A
> or B", or "numeric argument C must not exceed argument D", or "multiple
> options combine vs. last one wins".  Mostly because "it’s already
> complicated enough as is".

Understood.


>> 
>> We could. But is it actually worth inventing a new programming language?
>> I think this is something that should be done in C code even in the
>> future. I think what we're looking for is a way to describe interfaces,
>> not implementations.
> 
> Sane sugar can be described declaratively as macro expansion.
> 
> Less than sane sugar takes code.
> 
> Desugaring in code promotes (accidental) abandonment of sanity.
> 
> That said, we have to keep things simple to succeed.  Declarative
> desugaring seems beyond our reach.

Well, “keeping things simple” is a complicated thing.

> 
>> Even just for adding more sophisticated constraints, like in the example
>> above that maxmem >= size, it's questionable whether doing this in the
>> schema provides enough value for actually implementing it there.
> 
> Yes.

If we do it, yes. If we delegate to an existing language (I showed C above),
maybe it adds clarity without too much of an additional cost.

> 
>>>> I think the only thing in this list that can't obviously be covered
>>>> easily by QAPI is QOM. Or rather, it's covered by passing through
>>>> key=value lists without describing their structure
>>> 
>>> That’s close enough to me. (In my mind, that part was already “done”
>>> by QAPI, even if in the convoluted way you describe)
>> 
>> That's not really close enough. If you are happy with this level of
>> abstraction, you can define any command line option to be either a flag
>> or take a string as its argument and be done. This is obviously not very
>> helpful because it says nothing about the structure of that string.
> 
> Similar to all QMP commands taking a single 'any' argument.

Hmmm, I guess I have not understood what you meant by
"QOM could not be covered easily by QAPI" then.

We don’t want the QAPI to let arbitrary fields of a QOM object
be modified, do we?

As for the “public” aspects of a QOM object, that is static if it
comes from QAPI, so why couldn’t we define it there?


> 
>>                                                                    In
>> the same way, QAPI can't say anything about the structure of a QOM
>> object, and I think that's a problem.
>> 
>>>> - which, as far as I
>>>> understand, is mainly because QOM properties aren't necessarily static,
>>>> so we can't provide a statically defined interface for them. Probably
>>>> solvable in QEMU, but not without a major effort.
>>> 
>>> Or maybe extend the language so that it’s internal semantics
>>> knows about this aspect of QOM?
>> 
>> My point is that for example you can't generate a C struct (which is
>> statically defined) from something that has a dynamic structure. The
>> best you could do is fall back to key=value even in the C source, both
>> key and value being strings. But then you still have to parse these
>> strings manually, so it doesn't actually help much compared to a state
>> without C bindings.

I really don’t understand that point. To me, all these operations
seem relatively simple to generate.

I think that what confuses me is when you write “something that has a
dynamic structure”. I understand that as referring to the structure
defined in the schema. But the schema itself is static. So you can
generate static code from it, and it’s already done today.

Another hypothesis on my side is that we don’t want, ever, to
have the API provide for example the option to create its own
arbitrary QOM classes, or to tag arbitrary properties to an object,
where by “arbitrary” I mean not explicitly mentioned somewhere in
something like the schema.

So I suspect you are talking about something else.


> 
> QOM and QAPI sabotage each other.  Ironic, considering they were dreamed
> up by the same guy :)
> 
> QAPI is compile-time static by design.
> 
> QOM is run-time dynamic by design.  Some support for static definitions
> has been grafted on since.
> 
> We use QAPI type system escapes for QOM.  Defeats QAPI introspection and
> doc generation.  We provide separate QOM introspection instead, which is
> clumsier and less expressive.  QOM documentation doesn't exist.

But back to the original discussion about management tools,
do we let upper layers tag their own arbitrary stuff in QOM objects?


> 
>> Maybe what could be done is covering at least the static properties and
>> then having key=value for the dynamic part (which should be the
>> exception).
> 
> To make this worthwhile, we'd have to replace dynamic QOM properties by
> static ones when possible.  Monumental task.

I’m sure you are right, but it’s hard for me to evaluate, given how
many ways there are to access an object. Naively, grepping for
set_prop and for new_with_prop does not give me that many hits.


> 
>>>>> - Relations, e.g. how we represent “contains”, “derives from”, “needs”,
>>>>> “one of”, “one or several”, “attaches to”…
>>>>> - States, e.g. how do we represent the machine configuration,
>>>>> or the desired new disk setting
>>>>> - Verbs, e.g. how we represent “add”, “connect”, “remove”, “find”,
>>>>> “start”, “notify”, etc. and how we describe the kind of input they need.
>>>>> - Possibly more subtle things like support for transactions, commit/rollback,
>>>>> i.e. “I want to add connect a virtual nic to some host vf, but if anything
>>>>> along the way fails, I’d like all the cleanup to happen automatically)
>>>> 
>>>> This sounds like a different approach from our current QAPI command set
>>> 
>>> Well, except for purposefully trying to use a different wording to avoid
>>> the risk of getting your mind stuck in one of the particular existing
>>> meta-languages in QEMU, the approach is not very different.
>> 
>> I didn't necessarily mean relations/state/verbs, which obviously exist,
>> but the examples that seemed to express things in a deliberately
>> different way from what we have today.
>> 
>>> - Transactions do not exist today that I know of, although we see
>>> signs of them in discussions about the fact that this options destroys
>>> that back end but that option does not.
>> 
>> We have a 'transaction' QMP command, but they are not an integral part
>> of the language. Considering the trouble to implement transactional
>> commands, I suppose we don't even want it to be a fundamental part of
>> the language.
>> 
>>>> Does it actually provide more functionality, though?
>>> 
>>> It’s not intended to provide more, but to require less to do the same thing.
>> 
>> Though we always need to keep in mind that if requiring less for future
>> additions requires a huge effort now, the investment may pay off only in
>> a very distant future (if the abstraction we build even survives until
>> then).
> 
> Worse is better.
> 
> http://dreamsongs.com/RiseOfWorseIsBetter.html

You know that I positively hate this ;-)

Well, I guess we can expand the schema. #ILoveJSON.


Thanks
Christophe




  reply	other threads:[~2020-01-14 17:32 UTC|newest]

Thread overview: 183+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 16:13 Making QEMU easier for management tools and applications Stefan Hajnoczi
2019-12-20 21:07 ` Richard W.M. Jones
2020-01-02 11:26   ` Stefan Hajnoczi
2019-12-21  9:02 ` Markus Armbruster
2019-12-23 15:04   ` Michal Prívozník
2020-01-07  9:36     ` Kevin Wolf
2020-01-07 10:55       ` Michal Privoznik
2020-01-07 12:57         ` Kevin Wolf
2020-01-07 17:53           ` Christophe de Dinechin
2019-12-24 13:41   ` Daniel P. Berrangé
2020-01-22 22:28     ` John Snow
2020-01-23  7:19       ` Markus Armbruster
2020-01-23 17:58         ` John Snow
2020-01-23 19:01           ` Daniel P. Berrangé
2020-01-23 21:07             ` John Snow
2020-01-24  7:59               ` Markus Armbruster
2020-01-24 10:27                 ` Daniel P. Berrangé
2020-01-24 14:38                   ` Kevin Wolf
2020-01-24 18:23                     ` John Snow
2020-01-24 18:30                       ` Dr. David Alan Gilbert
2020-01-24 18:48                         ` John Snow
2020-01-24 18:52                           ` Dr. David Alan Gilbert
2020-01-24 18:58                             ` John Snow
2020-01-25 10:18                     ` Markus Armbruster
2020-01-27 10:18                       ` Daniel P. Berrangé
2020-01-27 12:48                         ` Markus Armbruster
2020-01-27 11:56                       ` Kevin Wolf
2020-01-27 12:04                         ` Peter Maydell
2020-01-27 20:11                         ` John Snow
2020-01-27 22:38                           ` Paolo Bonzini
2020-01-28  0:37                             ` John Snow
2020-01-28 10:16                             ` Daniel P. Berrangé
2020-01-28 10:39                               ` Kevin Wolf
2020-01-28 15:36                                 ` Markus Armbruster
2020-01-31 12:25                                   ` Eric Blake
2020-01-28 10:28                           ` Kevin Wolf
2020-01-28 12:36                             ` Markus Armbruster
2020-01-28 12:54                               ` Kevin Wolf
2020-01-28 13:45                                 ` Gerd Hoffmann
2020-01-31  6:50                                 ` Markus Armbruster
2020-01-31  7:48                                   ` Paolo Bonzini
2020-01-31  8:09                                     ` Markus Armbruster
2020-02-03 20:07                                   ` Andrea Bolognani
2020-02-04  9:58                                     ` Markus Armbruster
2020-01-31 12:27                                 ` Eric Blake
2020-02-02  9:21                                   ` Kevin Wolf
2020-02-02 10:44                                     ` Paolo Bonzini
2020-02-03  6:20                                       ` Markus Armbruster
2020-02-03  8:48                                         ` Markus Armbruster
2020-01-27 20:12                         ` Dr. David Alan Gilbert
2020-01-24 20:34                 ` John Snow
2020-01-27  8:35                   ` Gerd Hoffmann
2020-01-27 12:13                     ` Kevin Wolf
2020-01-27 16:18                       ` Gerd Hoffmann
2020-01-24  9:50               ` Daniel P. Berrangé
2020-01-25 11:52                 ` Paolo Bonzini
2020-01-27 10:05                   ` Daniel P. Berrangé
2020-01-27  8:25                 ` Tooling to help humans use JSON (was: Making QEMU easier for management tools and applications) Markus Armbruster
2020-01-27  9:06                 ` Making QEMU easier for management tools and applications Markus Armbruster
2020-01-27 10:00                   ` Daniel P. Berrangé
2020-01-27 14:35                 ` Kevin Wolf
2020-01-27 20:29                   ` Dr. David Alan Gilbert
2020-01-28 10:59                     ` Kevin Wolf
2020-02-05 13:09                       ` Kevin Wolf
2020-02-05 19:09                         ` qmp-shell for GSoC/Outreachy? (Was: Re: Making QEMU easier for management tools and applications) John Snow
2020-02-05 19:49                           ` Dr. David Alan Gilbert
2020-02-06  9:40                             ` qmp-shell for GSoC/Outreachy? Markus Armbruster
2020-02-06 10:09                               ` Daniel P. Berrangé
2020-02-06 12:11                                 ` Markus Armbruster
2020-02-06 12:15                                   ` Daniel P. Berrangé
2020-02-06 18:02                                     ` Dr. David Alan Gilbert
2020-02-07 21:03                                   ` John Snow
2020-02-08  7:17                                     ` Markus Armbruster
2020-02-06 14:21                               ` Kevin Wolf
2020-02-06 18:26                                 ` Dr. David Alan Gilbert
2020-02-07 10:49                                   ` Kevin Wolf
2020-02-07 21:23                                 ` John Snow
2020-02-08  7:25                                   ` Markus Armbruster
2020-02-10 11:59                                     ` Kevin Wolf
2020-02-10 12:26                                   ` Kevin Wolf
2020-02-06 18:18                               ` Dr. David Alan Gilbert
2020-02-07  7:47                                 ` Markus Armbruster
2020-02-07 21:31                                 ` Eric Blake
2020-02-08  7:34                                   ` Markus Armbruster
2020-02-07 21:56                                 ` John Snow
2020-02-07 20:56                               ` John Snow
2020-01-27 20:59                   ` Making QEMU easier for management tools and applications John Snow
2020-01-28 10:16                     ` Markus Armbruster
2020-01-28 19:21                       ` John Snow
2020-01-24  6:38           ` Markus Armbruster
2020-01-25 22:34           ` Christophe de Dinechin
2020-01-25 11:55     ` Paolo Bonzini
2020-01-02 14:47   ` Stefan Hajnoczi
2020-01-16 11:03     ` Kashyap Chamarthy
2020-01-20  9:55       ` Stefan Hajnoczi
2020-01-20 13:57         ` Kashyap Chamarthy
2020-01-25 11:41         ` Paolo Bonzini
2020-01-27 19:41           ` John Snow
2020-01-02 15:05   ` Dr. David Alan Gilbert
2020-01-13 13:44     ` Markus Armbruster
2019-12-24 13:00 ` Daniel P. Berrangé
2020-01-02 14:22   ` Stefan Hajnoczi
2020-01-22 22:42   ` John Snow
2020-01-23  7:21     ` Markus Armbruster
2020-01-23 10:27     ` Daniel P. Berrangé
2020-01-23 18:13       ` John Snow
2020-01-23 19:12         ` Daniel P. Berrangé
2020-01-02 15:10 ` Dr. David Alan Gilbert
2020-01-07 17:11 ` Christophe de Dinechin
2020-01-08 10:43   ` Kevin Wolf
2020-01-08 11:40     ` Christophe de Dinechin
2020-01-08 13:38       ` Kevin Wolf
2020-01-14 13:04         ` Markus Armbruster
2020-01-14 17:31           ` Christophe de Dinechin [this message]
2020-01-15  9:20             ` Markus Armbruster
2020-01-15  9:34               ` Christophe de Dinechin
2020-01-15 12:15                 ` Markus Armbruster
2020-01-15 12:19                   ` Daniel P. Berrangé
2020-01-15 14:02                     ` Markus Armbruster
2020-01-30 21:09                       ` Improving QOM documentation [Was: Re: Making QEMU easier for management tools and applications] Kashyap Chamarthy
2020-01-31  6:11                         ` Markus Armbruster
2020-01-31  7:46                           ` Paolo Bonzini
2020-01-31 15:37                             ` Christophe de Dinechin
2020-01-31 16:28                               ` Paolo Bonzini
2020-01-31  9:50                           ` Kashyap Chamarthy
2020-01-31 10:35                           ` Peter Maydell
2020-01-31 11:02                             ` Paolo Bonzini
2020-01-31 15:22                               ` Kashyap Chamarthy
2020-01-31 17:23                                 ` Markus Armbruster
2020-02-03  8:56                                   ` Paolo Bonzini
2020-02-03  9:54                                     ` Markus Armbruster
2020-02-03 15:21                                       ` Paolo Bonzini
2020-02-04  8:42                                         ` Markus Armbruster
2020-01-31 16:39                               ` Markus Armbruster
2020-01-20 10:08                   ` Making QEMU easier for management tools and applications Stefan Hajnoczi
2020-01-21  5:42                     ` Markus Armbruster
2020-01-21 11:32                       ` Stefan Hajnoczi
2020-01-21 12:03                         ` Marc-André Lureau
2020-01-21 13:36                           ` Integrating QOM into QAPI (was: Making QEMU easier for management tools and applications) Markus Armbruster
2020-01-21 14:36                             ` Daniel P. Berrangé
2020-01-21 15:01                               ` Integrating QOM into QAPI Markus Armbruster
2020-01-21 15:11                                 ` Marc-André Lureau
2020-01-21 16:21                                   ` Peter Maydell
2020-01-22  5:16                                     ` Getting whole-tree patches reviewed and merged (was: Integrating QOM into QAPI) Markus Armbruster
2020-02-07 21:53                                       ` Getting whole-tree patches reviewed and merged Eric Blake
2020-02-10 11:26                                         ` Paolo Bonzini
2020-02-10 16:04                                           ` Markus Armbruster
2020-02-10 16:12                                             ` Peter Maydell
2020-01-22 10:50                                   ` Integrating QOM into QAPI Alex Bennée
2020-01-22 12:24                                     ` Markus Armbruster
2020-01-22 12:42                                       ` Marc-André Lureau
2020-01-22 13:28                                         ` Peter Maydell
2020-01-22 13:32                                           ` Marc-André Lureau
2020-01-23  7:37                                         ` Markus Armbruster
2020-01-24 18:32                                         ` Paolo Bonzini
2020-01-25  4:44                                           ` Marc-André Lureau
2020-01-25  9:28                                             ` Paolo Bonzini
2020-01-25 21:25                                               ` Peter Maydell
2020-01-26  8:09                                   ` Christophe de Dinechin
2020-01-26  9:11                                     ` Marc-André Lureau
2020-01-26 16:47                                       ` Paolo Bonzini
2020-01-27 19:05                                         ` Christophe de Dinechin
2020-01-27 19:05                                       ` Christophe de Dinechin
2020-01-26 15:04                                     ` Peter Maydell
2020-01-27 19:05                                       ` Christophe de Dinechin
2020-01-28  8:00                                         ` Markus Armbruster
2020-01-28 10:03                                         ` Daniel P. Berrangé
2020-01-29 12:42                                           ` Christophe de Dinechin
2020-01-15  9:35               ` Making QEMU easier for management tools and applications Marc-André Lureau
2020-01-15 12:25                 ` Markus Armbruster
2020-01-25 17:18               ` Paolo Bonzini
2020-01-27  9:30                 ` Markus Armbruster
2020-01-13 16:30   ` Stefan Hajnoczi
2020-02-04 15:54 ` Summary of " Markus Armbruster
2020-02-05  6:38   ` Markus Armbruster
2020-02-10 10:56   ` Stefan Hajnoczi
2020-02-10 11:01     ` Peter Maydell
2020-02-10 11:08       ` Daniel P. Berrangé
2020-02-10 11:29         ` Peter Maydell
2020-02-10 11:04     ` Paolo Bonzini
2020-02-10 16:43     ` Markus Armbruster
2020-02-12 13:54       ` Stefan Hajnoczi
2020-02-12 14:03         ` Daniel P. Berrangé

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=1B253197-5592-472A-AA26-E0614A13C91A@redhat.com \
    --to=dinechin@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=d.csapak@proxmox.com \
    --cc=den@virtuozzo.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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).