[PATCH 0/6] qemu-storage-daemon: QAPIfy --chardev

Kevin Wolf posted 6 patches 5 years ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201023101222.250147-1-kwolf@redhat.com
Maintainers: Igor Mammedov <imammedo@redhat.com>, David Hildenbrand <david@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Markus Armbruster <armbru@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Fam Zheng <fam@euphon.net>, "Daniel P. Berrangé" <berrange@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Eric Blake <eblake@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Anthony Perard <anthony.perard@citrix.com>, Eduardo Habkost <ehabkost@redhat.com>, Paul Durrant <paul@xen.org>, Stefan Berger <stefanb@linux.vnet.ibm.com>, Michael Roth <mdroth@linux.vnet.ibm.com>, Max Reitz <mreitz@redhat.com>, Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
There is a newer version of this series
qapi/char.json                                |  6 +-
docs/devel/qapi-code-gen.txt                  | 43 +++++++---
include/chardev/char.h                        |  1 +
include/qapi/visitor-impl.h                   |  3 +
include/qapi/visitor.h                        | 10 +++
backends/tpm/tpm_emulator.c                   |  3 +-
backends/tpm/tpm_passthrough.c                |  4 +-
block/crypto.c                                |  3 +-
block/qcow2.c                                 |  9 +-
block/vmdk.c                                  | 14 ++--
blockdev.c                                    | 36 ++++----
chardev/char-file.c                           |  5 +-
chardev/char-mux.c                            |  5 +-
chardev/char-parallel.c                       |  5 +-
chardev/char-pipe.c                           |  7 +-
chardev/char-ringbuf.c                        |  5 +-
chardev/char-serial.c                         |  5 +-
chardev/char-socket.c                         | 13 ++-
chardev/char-stdio.c                          |  9 +-
chardev/char-udp.c                            | 11 +--
chardev/char.c                                | 27 +++---
chardev/msmouse.c                             |  4 +-
chardev/wctablet.c                            |  4 +-
hw/core/numa.c                                |  6 +-
hw/display/xenfb.c                            |  8 +-
hw/input/hid.c                                |  8 +-
hw/input/ps2.c                                |  6 +-
hw/input/virtio-input-hid.c                   |  8 +-
hw/mem/pc-dimm.c                              | 18 ++--
hw/virtio/virtio-mem-pci.c                    |  3 +-
hw/virtio/virtio-pmem-pci.c                   |  3 +-
monitor/hmp-cmds.c                            | 14 ++--
qapi/qapi-visit-core.c                        | 10 +++
qemu-keymap.c                                 |  2 +-
replay/replay-input.c                         | 46 +++++-----
storage-daemon/qemu-storage-daemon.c          | 47 +++++++++--
tests/test-char.c                             | 12 ++-
tests/test-clone-visitor.c                    | 14 ++--
tests/test-qmp-cmds.c                         |  2 +-
tests/test-qobject-input-visitor.c            | 24 +++---
tests/test-qobject-output-visitor.c           | 24 +++---
ui/console.c                                  |  5 +-
ui/input-keymap.c                             | 12 +--
ui/input-legacy.c                             | 12 +--
ui/input.c                                    | 43 +++++-----
util/qemu-sockets.c                           |  8 +-
scripts/qapi/expr.py                          |  7 +-
scripts/qapi/introspect.py                    |  7 +-
scripts/qapi/schema.py                        | 63 +++++++++++---
scripts/qapi/visit.py                         | 36 ++++++++
tests/qapi-schema/doc-good.out                |  8 +-
tests/qapi-schema/flat-union-allow-flat.err   |  2 +
tests/qapi-schema/flat-union-allow-flat.json  | 10 +++
tests/qapi-schema/flat-union-allow-flat.out   |  0
tests/qapi-schema/meson.build                 |  4 +
tests/qapi-schema/qapi-schema-test.json       | 10 +++
tests/qapi-schema/qapi-schema-test.out        | 84 +++++++------------
tests/qapi-schema/union-allow-flat-bad.err    |  2 +
tests/qapi-schema/union-allow-flat-bad.json   |  5 ++
tests/qapi-schema/union-allow-flat-bad.out    |  0
.../union-allow-flat-builtin-type.err         |  2 +
.../union-allow-flat-builtin-type.json        |  5 ++
.../union-allow-flat-builtin-type.out         |  0
tests/qapi-schema/union-clash-member.err      |  2 +
tests/qapi-schema/union-clash-member.json     |  6 ++
tests/qapi-schema/union-clash-member.out      |  0
66 files changed, 484 insertions(+), 336 deletions(-)
create mode 100644 tests/qapi-schema/flat-union-allow-flat.err
create mode 100644 tests/qapi-schema/flat-union-allow-flat.json
create mode 100644 tests/qapi-schema/flat-union-allow-flat.out
create mode 100644 tests/qapi-schema/union-allow-flat-bad.err
create mode 100644 tests/qapi-schema/union-allow-flat-bad.json
create mode 100644 tests/qapi-schema/union-allow-flat-bad.out
create mode 100644 tests/qapi-schema/union-allow-flat-builtin-type.err
create mode 100644 tests/qapi-schema/union-allow-flat-builtin-type.json
create mode 100644 tests/qapi-schema/union-allow-flat-builtin-type.out
create mode 100644 tests/qapi-schema/union-clash-member.err
create mode 100644 tests/qapi-schema/union-clash-member.json
create mode 100644 tests/qapi-schema/union-clash-member.out
[PATCH 0/6] qemu-storage-daemon: QAPIfy --chardev
Posted by Kevin Wolf 5 years ago
While the qemu-storage-daemon command line is still considered unstable,
let's change --chardev from the old QemuOpts-based parser to QAPI, so
that it becomes a simple mapping of chardev-add to the command line and
will fit in a future fully QAPIfied command line without later
incompatible changes or additional compatibility glue.

Kevin Wolf (6):
  char/stdio: Fix QMP default for 'signal'
  char: Factor out qemu_chr_print_types()
  qapi: Remove wrapper struct for simple unions
  qapi: Optionally parse simple unions as flat
  tests/qapi-schema: Flat representation of simple unions
  qemu-storage-daemon: Use qmp_chardev_add() for --chardev

 qapi/char.json                                |  6 +-
 docs/devel/qapi-code-gen.txt                  | 43 +++++++---
 include/chardev/char.h                        |  1 +
 include/qapi/visitor-impl.h                   |  3 +
 include/qapi/visitor.h                        | 10 +++
 backends/tpm/tpm_emulator.c                   |  3 +-
 backends/tpm/tpm_passthrough.c                |  4 +-
 block/crypto.c                                |  3 +-
 block/qcow2.c                                 |  9 +-
 block/vmdk.c                                  | 14 ++--
 blockdev.c                                    | 36 ++++----
 chardev/char-file.c                           |  5 +-
 chardev/char-mux.c                            |  5 +-
 chardev/char-parallel.c                       |  5 +-
 chardev/char-pipe.c                           |  7 +-
 chardev/char-ringbuf.c                        |  5 +-
 chardev/char-serial.c                         |  5 +-
 chardev/char-socket.c                         | 13 ++-
 chardev/char-stdio.c                          |  9 +-
 chardev/char-udp.c                            | 11 +--
 chardev/char.c                                | 27 +++---
 chardev/msmouse.c                             |  4 +-
 chardev/wctablet.c                            |  4 +-
 hw/core/numa.c                                |  6 +-
 hw/display/xenfb.c                            |  8 +-
 hw/input/hid.c                                |  8 +-
 hw/input/ps2.c                                |  6 +-
 hw/input/virtio-input-hid.c                   |  8 +-
 hw/mem/pc-dimm.c                              | 18 ++--
 hw/virtio/virtio-mem-pci.c                    |  3 +-
 hw/virtio/virtio-pmem-pci.c                   |  3 +-
 monitor/hmp-cmds.c                            | 14 ++--
 qapi/qapi-visit-core.c                        | 10 +++
 qemu-keymap.c                                 |  2 +-
 replay/replay-input.c                         | 46 +++++-----
 storage-daemon/qemu-storage-daemon.c          | 47 +++++++++--
 tests/test-char.c                             | 12 ++-
 tests/test-clone-visitor.c                    | 14 ++--
 tests/test-qmp-cmds.c                         |  2 +-
 tests/test-qobject-input-visitor.c            | 24 +++---
 tests/test-qobject-output-visitor.c           | 24 +++---
 ui/console.c                                  |  5 +-
 ui/input-keymap.c                             | 12 +--
 ui/input-legacy.c                             | 12 +--
 ui/input.c                                    | 43 +++++-----
 util/qemu-sockets.c                           |  8 +-
 scripts/qapi/expr.py                          |  7 +-
 scripts/qapi/introspect.py                    |  7 +-
 scripts/qapi/schema.py                        | 63 +++++++++++---
 scripts/qapi/visit.py                         | 36 ++++++++
 tests/qapi-schema/doc-good.out                |  8 +-
 tests/qapi-schema/flat-union-allow-flat.err   |  2 +
 tests/qapi-schema/flat-union-allow-flat.json  | 10 +++
 tests/qapi-schema/flat-union-allow-flat.out   |  0
 tests/qapi-schema/meson.build                 |  4 +
 tests/qapi-schema/qapi-schema-test.json       | 10 +++
 tests/qapi-schema/qapi-schema-test.out        | 84 +++++++------------
 tests/qapi-schema/union-allow-flat-bad.err    |  2 +
 tests/qapi-schema/union-allow-flat-bad.json   |  5 ++
 tests/qapi-schema/union-allow-flat-bad.out    |  0
 .../union-allow-flat-builtin-type.err         |  2 +
 .../union-allow-flat-builtin-type.json        |  5 ++
 .../union-allow-flat-builtin-type.out         |  0
 tests/qapi-schema/union-clash-member.err      |  2 +
 tests/qapi-schema/union-clash-member.json     |  6 ++
 tests/qapi-schema/union-clash-member.out      |  0
 66 files changed, 484 insertions(+), 336 deletions(-)
 create mode 100644 tests/qapi-schema/flat-union-allow-flat.err
 create mode 100644 tests/qapi-schema/flat-union-allow-flat.json
 create mode 100644 tests/qapi-schema/flat-union-allow-flat.out
 create mode 100644 tests/qapi-schema/union-allow-flat-bad.err
 create mode 100644 tests/qapi-schema/union-allow-flat-bad.json
 create mode 100644 tests/qapi-schema/union-allow-flat-bad.out
 create mode 100644 tests/qapi-schema/union-allow-flat-builtin-type.err
 create mode 100644 tests/qapi-schema/union-allow-flat-builtin-type.json
 create mode 100644 tests/qapi-schema/union-allow-flat-builtin-type.out
 create mode 100644 tests/qapi-schema/union-clash-member.err
 create mode 100644 tests/qapi-schema/union-clash-member.json
 create mode 100644 tests/qapi-schema/union-clash-member.out

-- 
2.28.0


Re: [PATCH 0/6] qemu-storage-daemon: QAPIfy --chardev
Posted by Daniel P. Berrangé 5 years ago
On Fri, Oct 23, 2020 at 12:12:16PM +0200, Kevin Wolf wrote:
> While the qemu-storage-daemon command line is still considered unstable,
> let's change --chardev from the old QemuOpts-based parser to QAPI, so
> that it becomes a simple mapping of chardev-add to the command line and
> will fit in a future fully QAPIfied command line without later
> incompatible changes or additional compatibility glue.

NB, I am *not* objecting to this series in what I'm about to write,
but I want to point out that I don't think we should assume that
this proposed QAPIified CLI is neccessarily the long term end point.
Below I outline potential incompatible changes that would end up
turning -chardev into legacy / deprecated syntax.


The chardev QAPI-ification is a good example of the gap between QOM
and QAPI.

The chardev backends are QOM classes, but they lack the "user creatable"
interface.

Thus instead of configuring them using -object / object_add, we have a
QAPI model, custom args/commands -chardev / chardev_add, and then code
that populates the object instance properties from the QAPI model. Except
we've not really exposed them as object instance properties - they are
mostly just struct fields directly accessed.


The benefit of the chardev approach is that we have an introspectable
QAPI model. The downside is that we have a bunch of conversion code
for QAPI to QOM mapping.

The benefit of the user creatable object approach is that we dont
have to add custom CLI args for different types of object, nor write
code to populate QOM from QAPI. The downside is that we're divorced
from the QAPI schema, so loose introspection, and have a different
type of tedious boilerplate code to write.


The fact that we have this custom -chardev arg, instead of just using
-object is related to the ordering problems we have in main() in the
system emulators.

We have some -object types that need creating before the chardev
types, and some -object types that need creating after the chardevs.

If -chardev didn't exist, and we used -object for chardev creation,
then the ordering problem would trivially not exist, as we would
simply be processing all -object args in order that we receive them.


IOW, if we're considering our ideal long term configuration goals
for QEMU, then I think we should be looking at a solution to bridge
the gap, so that we can get the best of both worlds, and have a single
way todo things.

IMHO, ideally none of -netdev, -chardev, -device, etc would exist
in any "modern" CLI, they would just be considered legacy syntax.
Essentially everything would be created using the same -object arg
and object_add  commands.


What I think this means is that we need to use QAPI to represent
the properties of an object, and auto-generate the QOM code to
register properties, provider setters/getters, constructors, etc.

For existing user creatable objects this would largely involve
deleting lots of existing code and defining some simple QAPI
schemas. This is probably quite easy, if tedious.

For the chardev/netdev/etc objects we already have the QAPI schema,
but would need to add code genration parts to turn them into full
user creatable object classes. This is likely harder more involved
work, especially to keep backcompat working well.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PATCH 0/6] qemu-storage-daemon: QAPIfy --chardev
Posted by Paolo Bonzini 5 years ago
On 23/10/20 12:36, Daniel P. Berrangé wrote:
> IOW, if we're considering our ideal long term configuration goals
> for QEMU, then I think we should be looking at a solution to bridge
> the gap, so that we can get the best of both worlds, and have a single
> way todo things.
> 
> IMHO, ideally none of -netdev, -chardev, -device, etc would exist
> in any "modern" CLI, they would just be considered legacy syntax.
> Essentially everything would be created using the same -object arg
> and object_add  commands.

I agree, especially for -chardev which should be the easiest of the
three to make user-creatable.  Devices have magic bus properties and
netdevs aren't QOM objects at all, but character devices have neither of
these issues.

On the other hand, chardevs do not yet have properties, which means the
transition to -object is not going to be trivial.  But it is surely at
least worth trying to see what the issues it introduces (perhaps QOM
properties with struct and union types?), how they could be solved and
whether it's worth it.

Thanks,

Paolo


Re: [PATCH 0/6] qemu-storage-daemon: QAPIfy --chardev
Posted by Kevin Wolf 5 years ago
Am 23.10.2020 um 12:36 hat Daniel P. Berrangé geschrieben:
> On Fri, Oct 23, 2020 at 12:12:16PM +0200, Kevin Wolf wrote:
> > While the qemu-storage-daemon command line is still considered unstable,
> > let's change --chardev from the old QemuOpts-based parser to QAPI, so
> > that it becomes a simple mapping of chardev-add to the command line and
> > will fit in a future fully QAPIfied command line without later
> > incompatible changes or additional compatibility glue.
> 
> NB, I am *not* objecting to this series in what I'm about to write,
> but I want to point out that I don't think we should assume that
> this proposed QAPIified CLI is neccessarily the long term end point.
> Below I outline potential incompatible changes that would end up
> turning -chardev into legacy / deprecated syntax.

Well, when do we have an end point for anything anyway? Things will
always evolve.

> The chardev QAPI-ification is a good example of the gap between QOM
> and QAPI.
> 
> The chardev backends are QOM classes, but they lack the "user
> creatable" interface.

They aren't really proper QOM classes at this point. Technically they
are, but they are pretty boring QOM classes that don't have any
properties. Instead, they use ChardevBackend QAPI objects in the custom
ChardevClass.open method.

So they are in some weird in-between state.

> IOW, if we're considering our ideal long term configuration goals
> for QEMU, then I think we should be looking at a solution to bridge
> the gap, so that we can get the best of both worlds, and have a single
> way todo things.
> 
> IMHO, ideally none of -netdev, -chardev, -device, etc would exist
> in any "modern" CLI, they would just be considered legacy syntax.
> Essentially everything would be created using the same -object arg
> and object_add  commands.

I think we need to distinguish legacy options and convenience options
(and this applies much more broadly than just here, and it's probably
more important in other places).

Even if we eventually make -object capable of configuring chardev and
netdev backends, -chardev could still be more convenient to use for a
human user.

This equation of "legacy" and "convenience" is also on of the problems I
have with the suggestion of having two binaries for "legacy" and
"modern" interfaces. Humans are not legacy, and having a command line
that is unfriendly for human users doesn't make it modern.

We have a lot of legacy stuff in the command line, and the goal for it
is to get rid of it and replace it with something modern (the goal is
_not_ keeping it around for human users because compatibility with this
legacy stuff often blocks us from moving forward).

But convenience options for human users aren't bad at all, as long as
they are based on a modern model of how things work. We'll always want
to have some.

Sorry for going on a tangent... Back to chardev: In the end, the
preferred command line interface doesn't matter that much. The required
structure will be the same.

> What I think this means is that we need to use QAPI to represent
> the properties of an object, and auto-generate the QOM code to
> register properties, provider setters/getters, constructors, etc.

Yes, I agree with this one.

I expect we'll discuss this more when I send the first step for
object-add (which is QMP, so for everything, not just
qemu-storage-daemon), which will duplicate the QOM properties in the
QAPI schema for user creatable objects. Generating QOM code from the
schema should be the next step then.

> For existing user creatable objects this would largely involve
> deleting lots of existing code and defining some simple QAPI
> schemas. This is probably quite easy, if tedious.
> 
> For the chardev/netdev/etc objects we already have the QAPI schema,
> but would need to add code genration parts to turn them into full
> user creatable object classes. This is likely harder more involved
> work, especially to keep backcompat working well.

The challenging part is probably not keeping compatibility (there's no
reason to break it if it represents everything well), but that these are
union types in the QAPI schema that map to different QOM classes.

It's not entirely obvious to me yet how we would deal with this, but the
good thing is that this is all about internal interfaces which we can
change relatively freely.

Kevin


Re: [PATCH 0/6] qemu-storage-daemon: QAPIfy --chardev
Posted by Markus Armbruster 5 years ago
Daniel P. Berrangé <berrange@redhat.com> writes:

> On Fri, Oct 23, 2020 at 12:12:16PM +0200, Kevin Wolf wrote:
>> While the qemu-storage-daemon command line is still considered unstable,
>> let's change --chardev from the old QemuOpts-based parser to QAPI, so
>> that it becomes a simple mapping of chardev-add to the command line and
>> will fit in a future fully QAPIfied command line without later
>> incompatible changes or additional compatibility glue.
>
> NB, I am *not* objecting to this series in what I'm about to write,
> but I want to point out that I don't think we should assume that
> this proposed QAPIified CLI is neccessarily the long term end point.
> Below I outline potential incompatible changes that would end up
> turning -chardev into legacy / deprecated syntax.
>
>
> The chardev QAPI-ification is a good example of the gap between QOM
> and QAPI.
>
> The chardev backends are QOM classes, but they lack the "user creatable"
> interface.
>
> Thus instead of configuring them using -object / object_add, we have a
> QAPI model, custom args/commands -chardev / chardev_add, and then code
> that populates the object instance properties from the QAPI model. Except
> we've not really exposed them as object instance properties - they are
> mostly just struct fields directly accessed.
>
>
> The benefit of the chardev approach is that we have an introspectable
> QAPI model. The downside is that we have a bunch of conversion code
> for QAPI to QOM mapping.
>
> The benefit of the user creatable object approach is that we dont
> have to add custom CLI args for different types of object, nor write
> code to populate QOM from QAPI. The downside is that we're divorced
> from the QAPI schema, so loose introspection, and have a different
> type of tedious boilerplate code to write.

Loss of QAPI introspection is the killer.

We have QOM introspection, but it's far too weak to serve as
replacement.  Besides, two introspection facilities is one too many.

> The fact that we have this custom -chardev arg, instead of just using
> -object is related to the ordering problems we have in main() in the
> system emulators.
>
> We have some -object types that need creating before the chardev
> types, and some -object types that need creating after the chardevs.
>
> If -chardev didn't exist, and we used -object for chardev creation,
> then the ordering problem would trivially not exist, as we would
> simply be processing all -object args in order that we receive them.
>
>
> IOW, if we're considering our ideal long term configuration goals
> for QEMU, then I think we should be looking at a solution to bridge
> the gap, so that we can get the best of both worlds, and have a single
> way todo things.
>
> IMHO, ideally none of -netdev, -chardev, -device, etc would exist
> in any "modern" CLI, they would just be considered legacy syntax.
> Essentially everything would be created using the same -object arg
> and object_add  commands.
>
>
> What I think this means is that we need to use QAPI to represent
> the properties of an object, and auto-generate the QOM code to
> register properties, provider setters/getters, constructors, etc.

Use of a QAPI schema rather than code to define user-facing QOM
properties provides QAPI introspection for QOM.  Having that would be
lovely.

Bonus: in QOM, documenting types takes effort.  Consequently,
user-facing QOM is mostly undocumented.  In a QAPI schema, *not*
documenting stuff takes effort: the QAPI generator insists on
documentation.

Eduardo (cc'ed) mentioned he'd like to work towards defining properties
in a QAPI schema.

> For existing user creatable objects this would largely involve
> deleting lots of existing code and defining some simple QAPI
> schemas. This is probably quite easy, if tedious.
>
> For the chardev/netdev/etc objects we already have the QAPI schema,
> but would need to add code genration parts to turn them into full
> user creatable object classes. This is likely harder more involved
> work, especially to keep backcompat working well.

I sympathize with this long term vision.

Nevertheless, we need Kevin's work now to get a decent storage daemon
CLI while that's still easy to do.  We'll have to promise stability
soon, and then changes get much harder.


Re: [PATCH 0/6] qemu-storage-daemon: QAPIfy --chardev
Posted by Paolo Bonzini 5 years ago
On 23/10/20 15:40, Markus Armbruster wrote:
>>
>> The benefit of the user creatable object approach is that we dont
>> have to add custom CLI args for different types of object, nor write
>> code to populate QOM from QAPI. The downside is that we're divorced
>> from the QAPI schema, so loose introspection, and have a different
>> type of tedious boilerplate code to write.
> Loss of QAPI introspection is the killer.
> 
> We have QOM introspection, but it's far too weak to serve as
> replacement.  Besides, two introspection facilities is one too many.

Wouldn't Eduardo+Kevin's work on object-add provide that too?

> Nevertheless, we need Kevin's work now to get a decent storage daemon
> CLI while that's still easy to do.  We'll have to promise stability
> soon, and then changes get much harder.

I think we haven't answered the question of whether qsd needs a CLI at all.

I looked recently at qemu_init and it struck me that, in principle, the
only _really_ necessary command line options for QEMU are -sandbox,
-name and possibly -trace (only to be able to trace the monitor).  For
everything else, one could use LISTEN_FDS socket activation mechanism,
or if there's no LISTEN_FDS environment variable open a QMP socket on
stdin/stdout.

For qemu-standard-daemon, that would be _really_ true and not just in
principle I understand that having a command-line can be useful to
developers as it's less unwieldy than JSON, but why does it have to be
stable?  Could we default to only 2-3 command-line options in the same
fashion, and only accept --blockdev and friends if the user starts the
command line with "qemu-storage-daemon --i-am-not-a-script"?

Paolo


Re: [PATCH 0/6] qemu-storage-daemon: QAPIfy --chardev
Posted by Markus Armbruster 5 years ago
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 23/10/20 15:40, Markus Armbruster wrote:
>>>
>>> The benefit of the user creatable object approach is that we dont
>>> have to add custom CLI args for different types of object, nor write
>>> code to populate QOM from QAPI. The downside is that we're divorced
>>> from the QAPI schema, so loose introspection, and have a different
>>> type of tedious boilerplate code to write.
>>
>> Loss of QAPI introspection is the killer.
>> 
>> We have QOM introspection, but it's far too weak to serve as
>> replacement.  Besides, two introspection facilities is one too many.
>
> Wouldn't Eduardo+Kevin's work on object-add provide that too?

Yes, the issue "replacing chardev-add by object-add loses QAPI
introspection" evaporates when object-add becomes QAPI-introspectable.

>> Nevertheless, we need Kevin's work now to get a decent storage daemon
>> CLI while that's still easy to do.  We'll have to promise stability
>> soon, and then changes get much harder.
>
> I think we haven't answered the question of whether qsd needs a CLI at all.
>
> I looked recently at qemu_init and it struck me that, in principle, the
> only _really_ necessary command line options for QEMU are -sandbox,
> -name and possibly -trace (only to be able to trace the monitor).  For
> everything else, one could use LISTEN_FDS socket activation mechanism,
> or if there's no LISTEN_FDS environment variable open a QMP socket on
> stdin/stdout.

Nobody argues this can't be done.  Some of us argue it should not be
done :)

> For qemu-standard-daemon, that would be _really_ true and not just in
> principle I understand that having a command-line can be useful to
> developers as it's less unwieldy than JSON, but why does it have to be
> stable?

Let me split this into multiple questions:

1. Does qsd need a CLI beyond whatever is needed to provide QMP?

2. If yes, does it need to be stable?

3. Does it need to be machine-friendly?

4. Does it need to be human-friendly?

5. What does it mean to be human-friendly?

I'd expect Kevin to answer question 1. and 4. with an emphatic yes.  I
concur, because without a usable CLI, ad hoc usability is awful.  My
idea of "usable" is probably less demanding than Kevin's, but that's
question 5 already.

The step from a QMP command that returns nothing to machine-friendly CLI
option is almost trivial: -blockdev with a JSON argument proves it.
This makes me answer 3. with "why not?", and 2. with "this
machine-friendly interface is stable by construction".

We already paid for the step from machine-friendly CLI to a slightly
more human-friendly CLI: -blockdev with a dotted keys argument proves
it.  This makes me answer 4. with "why not / why override the qsd
maintainer?"

Question 5. is open-ended.  I think a truly human-friendly CLI will take
extra work, similar to how HMP does.  I believe it can be done with less
overhead than HMP has today.  I don't plan to sink a lot of time into it
myself, at least not in the immediate future.

>          Could we default to only 2-3 command-line options in the same
> fashion, and only accept --blockdev and friends if the user starts the
> command line with "qemu-storage-daemon --i-am-not-a-script"?

Making people type --i-am-not-a-script is begging for getting pelted
with vegetables at the next non-virtual KVM Forum.

I think what you're trying to accomplish is to tell a program off when
it uses a part of the CLI programs should not use.  My "Configurable
policy for handling deprecated interfaces" series can grow to do exactly
that, but it's opt-in (because I don't fancy getting pelted with
vegetables).