qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 20/20] chardev: qom-ify
Date: Mon, 9 Jan 2017 12:02:49 -0600	[thread overview]
Message-ID: <7b1f56d5-adfd-f57b-312d-ec7e2383bbf5@redhat.com> (raw)
In-Reply-To: <20170105165329.17227-21-marcandre.lureau@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2772 bytes --]

On 01/05/2017 10:53 AM, Marc-André Lureau wrote:
> Turn Chardev into Object.
> 
> qemu_chr_alloc() is replaced by the qemu_chardev_new() constructor. It
> will call qemu_char_open() to open/intialize the chardev with the
> ChardevCommon *backend settings.
> 
> The CharDriver::create() callback is turned into a ChardevClass::open()
> which is called from the newly introduced qemu_chardev_open().
> 
> "chardev-gdb" and "chardev-hci" are internal chardev and aren't
> creatable directly with -chardev. Use a new internal flag to disable
> them. We may want to use TYPE_USER_CREATABLE interface instead, or
> perhaps allow -chardev usage.
> 
> Although in general we keep typename and macros private, unless the type
> is being used by some other file, in this patch, all types and common
> helper macros for qemu-char.c are in char.h. This is to help transition
> now (some types must be declared early, while some aren't shared) and
> when splitting in several units. This is to be improved later.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---

> +++ b/qemu-char.c

> @@ -466,7 +433,8 @@ int qemu_chr_fe_get_msgfds(CharBackend *be, int *fds, int len)
>          return -1;
>      }
>  
> -    return s->driver->get_msgfds ? s->driver->get_msgfds(s, fds, len) : -1;
> +    return CHARDEV_GET_CLASS(s)->get_msgfds ?
> +        CHARDEV_GET_CLASS(s)->get_msgfds(s, fds, len) : -1;

I'm not familiar enough with the Object hierarchy to know if there is
any significant runtime cost to CHARDEV_GET_CLASS() that would warrant
capturing the output in a temporary variable, or if it is simple enough
that a compiler can already figure out that it is a reusable value
rather than computing it twice.  Probably not worrying about, though,
unless it actually shows up in a hot spot on a trace.


> @@ -4957,47 +4994,96 @@ void qemu_chr_set_feature(Chardev *chr,
>      return set_bit(feature, chr->features);
>  }
>  
> -ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
> -                               Error **errp)
> +static const ChardevClass *char_get_class(const char *driver, Error **errp)
> +{
> +    ObjectClass *oc;
> +    const ChardevClass *cc;
> +    char *typename = g_strdup_printf("chardev-%s", driver);
> +
> +    oc = object_class_by_name(typename);
> +    g_free(typename);

char_get_class("tty", NULL) will fail, because that's merely an alias
name rather than the canonical "serial" name. Will that matter to any of
the code? I didn't spot anything, so I'm not letting it stop my review.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
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 --]

      reply	other threads:[~2017-01-09 18:02 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05 16:53 [Qemu-devel] [PATCH 00/20] chardev: qom-ify Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 01/20] tests: fix linking test-char on win32 Marc-André Lureau
2017-01-06 16:45   ` Eric Blake
2017-01-06 19:50     ` Marc-André Lureau
2017-01-06 20:26       ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 02/20] qemu-options: stdio is available " Marc-André Lureau
2017-01-06 16:51   ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 03/20] char: add qemu_chr_fe_add_watch() Returns description Marc-André Lureau
2017-01-06 16:54   ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 04/20] doc: fix spelling Marc-André Lureau
2017-01-06 16:55   ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 05/20] char: use a const CharDriver Marc-André Lureau
2017-01-06 18:01   ` Eric Blake
2017-01-06 22:43     ` Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 06/20] char: use a static array for backends Marc-André Lureau
2017-01-06 19:24   ` Eric Blake
2017-01-06 23:22     ` Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 07/20] char: move callbacks in CharDriver Marc-André Lureau
2017-01-06 21:36   ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 08/20] char: fold single-user functions in caller Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 09/20] char: introduce generic qemu_chr_get_kind() Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 10/20] char: use a feature bit for replay Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 11/20] char: allocate CharDriverState as a single object Marc-André Lureau
2017-01-06 21:43   ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 12/20] bt: use qemu_chr_alloc() Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 13/20] char: rename CharDriverState Chardev Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 14/20] char: rename TCPChardev and NetChardev Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 15/20] spice-char: improve error reporting Marc-André Lureau
2017-01-06 22:22   ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 16/20] char: use error_report() Marc-André Lureau
2017-01-05 16:53 ` [Qemu-devel] [PATCH 17/20] gtk: overwrite the console.c char driver Marc-André Lureau
2017-01-06 22:24   ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 18/20] baum: use a common prefix for chr callbacks Marc-André Lureau
2017-01-06 22:25   ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 19/20] vc: " Marc-André Lureau
2017-01-06 22:26   ` Eric Blake
2017-01-05 16:53 ` [Qemu-devel] [PATCH 20/20] chardev: qom-ify Marc-André Lureau
2017-01-09 18:02   ` Eric Blake [this message]

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=7b1f56d5-adfd-f57b-312d-ec7e2383bbf5@redhat.com \
    --to=eblake@redhat.com \
    --cc=marcandre.lureau@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 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).