From: Eric Blake <eblake@redhat.com>
To: "Daniel P. Berrange" <berrange@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 08:41:05 -0700 [thread overview]
Message-ID: <567AC091.8010709@redhat.com> (raw)
In-Reply-To: <20151223112454.GG20028@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3977 bytes --]
On 12/23/2015 04:24 AM, Daniel P. Berrange wrote:
> 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]
>>
>>
>> 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.
Or in C terms, your proposal is:
struct ChardevCommon {
char *logname; ...
};
struct ChardevFile {
/* inherited fields from ChardevCommon */
char *logname; ...
/* own fields */
char *out; ...
};
struct ChardevBackend {
ChardevBackendKind type;
union {
ChardevFile *file; ...
} u;
};
Each branch of ChardevBackend.u then has an upcast function
qapi_ChardevFile_base() that gets you to a ChardevCommon pointer.
>
>> 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]):
>>
>>
>> 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' } } }
In C terms, this one would be:
struct ChardevCommon {
char *logname; ...
};
struct ChardevFile {
char *out; ...
};
struct ChardevBackend {
/* inherited fields from ChardevCommon */
char *logname; ...
/* own fields */
ChardevBackendKind type;
union {
ChardevFile *file; ...
} u;
};
Here, you can pass ChardevBackend* directly (and access
backend->logname, regardless of which union branch is in use).
>> 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.
Yep - the decision is up to you whether to add it to each struct used as
a branch of ChardevBackend (and each caller then upcasts and passes a
ChardevCommon* to the common code), or whether to add it directly to
ChardevBackend (and each caller merely passes a ChardevBackend*).
>
> So from that POV, I'd be against, pushing the 'logfile' field up
> either 1 or 2 levels.
>
> Regards,
> Daniel
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-12-23 15:41 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
2015-12-23 15:41 ` Eric Blake [this message]
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=567AC091.8010709@redhat.com \
--to=eblake@redhat.com \
--cc=berrange@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.