All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] qemu-char: add logfile facility to all chardev backends
Date: Wed, 23 Dec 2015 11:24:54 +0000	[thread overview]
Message-ID: <20151223112454.GG20028@redhat.com> (raw)
In-Reply-To: <56799A59.90709@redhat.com>

On Tue, Dec 22, 2015 at 11:45:45AM -0700, Eric Blake wrote:
> On 12/22/2015 11:17 AM, Daniel P. Berrange wrote:
> > Typically a UNIX guest OS will log boot messages to a serial
> > port in addition to any graphical console. An admin user
> > may also wish to use the serial port for an interactive
> > console. A virtualization management system may wish to
> > collect system boot messages by logging the serial port,
> > but also wish to allow admins interactive access.
> 
> [meta-review of JUST qapi decisions; code review in a separate message]
> 
> > 
> > Currently providing such a feature forces the mgmt app
> > to either provide 2 separate serial ports, one for
> > logging boot messages and one for interactive console
> > login, or to proxy all output via a separate service
> > that can multiplex the two needs onto one serial port.
> > While both are valid approaches, they each have their
> > own downsides. The former causes confusion and extra
> > setup work for VM admins creating disk images. The latter
> > places an extra burden to re-implement much of the QEMU
> > chardev backends logic in libvirt or even higher level
> > mgmt apps and adds extra hops in the data transfer path.
> > 
> > A simpler approach that is satisfactory for many use
> > cases is to allow the QEMU chardev backends to have a
> > "logfile" property associated with them.
> > 
> >  $QEMU -chardev socket,host=localhost,port=9000,\
> >                 server=on,nowait,id-charserial0,\
> > 		logfile=/var/log/libvirt/qemu/test-serial0.log
> >        -device isa-serial,chardev=charserial0,id=serial0
> > 
> > This patch introduces a 'ChardevCommon' struct which
> > is setup as a base for all the ChardevBackend types.
> > Ideally this would be registered directly as a base
> > against ChardevBackend, rather than each type, but
> > the QAPI generator doesn't allow that since the
> > ChardevBackend is a non-discriminated union.
> 
> It is possible to convert ChardevBackend into a discriminated union
> while still keeping the same QMP semantics.
> 
> But where it gets interesting is what the QMP semantics should be.
> 
> Right now, we have (simplifying to just two branches, for less typing):
> { 'union': 'ChardevBackend',
>   'data': { 'file': 'ChardevFile',
>             'serial': 'ChardevHostdev' } }
> 
> which means we support:
> 
> { "execute": "chardev-add", "arguments": {
>     "id": "foo", "backend": { "type": "file",
>        "data": { "out": "filename" } } } }
> 
> With your addition, ChardevFile now inherits from ChardevCommon, so we gain:
> 
> { "execute": "chardev-add", "arguments": {
>     "id": "foo", "backend": { "type": "file",
>       "data": { "logfile": "logname", "out": "filename" } } } }

Ok good that matches what I intended - namely that 'logfile'
should appear at the same dict as the rest of the backend
fields, to mirror the the fact that the C struct had all
the common fields in the same struct too.

> Re-writing the existing ChardevBackend to a semantically-identical flat
> union would be (using my shorthand syntax for anonymous base [1] and
> anonymous branch wrappers [2]):
> 
> { 'enum': 'ChardevType', 'data': [ 'file', 'serial' ] }
> { 'union': 'ChardevBackend',
>   'base': { 'type': 'ChardevType' }, 'discriminator': 'type',
>   'data': { 'file': { 'data': 'ChardevFile' },
>             'serial': { 'data': 'ChardevHostdev' } } }
> 
> [1] http://repo.or.cz/qemu/ericb.git/commitdiff/dbb8680b1
> [2] not yet posted to list or my git repo
> 
> Note that in my conversion, 'file' is no longer directly a
> 'ChardevFile', but an anonymous type with one field named 'data' where
> _that_ field is a ChardevFile; necessary to keep the existing QMP
> nesting the same.
> 
> Your proposal, then, is that the new 'logging' fields in your
> ChardevCommon should be made part of the base type of the
> 'ChardevBackend' union; which would be spelled as:
> 
> { 'enum': 'ChardevType', 'data': [ 'file', 'serial' ] }
> { 'struct': 'ChardevCommon', 'data': {
>   'type': 'ChardevType', '*logfile': 'str', '*logappend': bool } }
> { 'union': 'ChardevBackend',
>   'base': 'ChardevCommon', 'discriminator': 'type',
>   'data': { 'file': { 'data': 'ChardevFile' },
>             'serial': { 'data': 'ChardevHostdev' } } }
> 
> But done that way, the QMP wire form would be:
> 
> { "execute": "chardev-add", "arguments": {
>     "id": "foo", "backend": { "type": "file",
>       "logfile": "logname", "data": { "out": "filename" } } } }
> 
> Note the difference: "logfile" changes from being a child of "data" to
> being a sibling.

Ok, so that's still backwards compatible, but the 'logfile' is
appearing in an expected place IMHO.

> Hmm - now that I've typed all that, I wonder if it would make more sense
> to instead just make these parameters be siblings of "backend", by
> instead modifying:
> 
> { 'command': 'chardev-add', 'data': {
>     'id': 'str', 'backend': 'ChardevBackend',
>     '*logfile': 'str', '*logappend': bool } }
> 
> where the QMP command would be:
> 
> { "execute": "chardev-add", "arguments": {
>     "id": "foo", "logfile": "logname", "backend": { "type": "file",
>       "data": { "out": "filename" } } } }
> 
> But while that would certainly be less invasive to the qapi, it may make
> life harder for the C implementation (it's no longer associated with the
> ChardevBackend struct, but has to be tracked separately).

Yeah, that would require a bit of refactoring, since many of the
codepaths I'm changing only get passed in the 'ChardevBackend'
struct, not its parent owner.

> So, depending on which of those three places we want to stick the new
> parameters determines which approach we should use for exposing them in
> qapi.

>From the QMP representation POV, my preference is for the current
design since I think the 'logfile' attribute is really just another
one of the backend config attributes. The choice to have a ChardevCommon
struct was just a mechanism to avoid having to repeat the 'logfile'
parameter in every single Chardev* backend type. This naturally
matches the C-struct, where the ChardevCommon fields get directly
added to the ChardevFile, ChardevSocket, etc structs.

So from that POV, I'd be against, pushing the 'logfile' field up
either 1 or 2 levels.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2015-12-23 11:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 18:17 [Qemu-devel] [PATCH v2] qemu-char: add logfile facility to all chardev backends Daniel P. Berrange
2015-12-22 18:45 ` Eric Blake
2015-12-23 11:24   ` Daniel P. Berrange [this message]
2015-12-23 15:41     ` Eric Blake
2015-12-22 19:07 ` Eric Blake
2015-12-23 11:32   ` Daniel P. Berrange
2015-12-23 15:45     ` Eric Blake
2015-12-23 11:34 ` Paolo Bonzini
2015-12-23 11:43   ` Daniel P. Berrange

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=20151223112454.GG20028@redhat.com \
    --to=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.