From: Paolo Bonzini <pbonzini@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: armbru@redhat.com, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 01/17] chardev: Properly initialize ChardevCommon components
Date: Mon, 22 Feb 2016 11:18:35 +0100 [thread overview]
Message-ID: <56CAE07B.9090108@redhat.com> (raw)
In-Reply-To: <1455927587-28033-2-git-send-email-eblake@redhat.com>
On 20/02/2016 01:19, Eric Blake wrote:
> Commit d0d7708b forgot to parse logging for spice chardevs and
> virtual consoles. This requires making qemu_chr_parse_common()
> non-static. While at it, use a temporary variable to make the
> code shorter, as well as reduce the churn when a later patch
> alters the layout of simple unions.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> CC: Daniel P. Berrange <berrange@redhat.com>
> ---
> include/sysemu/char.h | 10 ++++++++++
> qemu-char.c | 2 +-
> spice-qemu-char.c | 12 ++++++++----
> ui/console.c | 20 +++++++++++---------
> 4 files changed, 30 insertions(+), 14 deletions(-)
>
> diff --git a/include/sysemu/char.h b/include/sysemu/char.h
> index e035d1c..e46884f 100644
> --- a/include/sysemu/char.h
> +++ b/include/sysemu/char.h
> @@ -115,6 +115,16 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
> Error **errp);
>
> /**
> + * @qemu_chr_parse_common:
> + *
> + * Parse the common options available to all character backends.
> + *
> + * @opts the options that still need parsing
> + * @backend a new backend
> + */
> +void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend);
> +
> +/**
> * @qemu_chr_new:
> *
> * Create a new character backend from a URI.
> diff --git a/qemu-char.c b/qemu-char.c
> index ad11b75..fc8ffda 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -3490,7 +3490,7 @@ fail:
> return NULL;
> }
>
> -static void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend)
> +void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend)
> {
> const char *logfile = qemu_opt_get(opts, "logfile");
>
> diff --git a/spice-qemu-char.c b/spice-qemu-char.c
> index 7c1f438..21885c5 100644
> --- a/spice-qemu-char.c
> +++ b/spice-qemu-char.c
> @@ -366,26 +366,30 @@ static void qemu_chr_parse_spice_vmc(QemuOpts *opts, ChardevBackend *backend,
> Error **errp)
> {
> const char *name = qemu_opt_get(opts, "name");
> + ChardevSpiceChannel *spicevmc;
>
> if (name == NULL) {
> error_setg(errp, "chardev: spice channel: no name given");
> return;
> }
> - backend->u.spicevmc = g_new0(ChardevSpiceChannel, 1);
> - backend->u.spicevmc->type = g_strdup(name);
> + spicevmc = backend->u.spicevmc = g_new0(ChardevSpiceChannel, 1);
> + qemu_chr_parse_common(opts, qapi_ChardevSpiceChannel_base(spicevmc));
> + spicevmc->type = g_strdup(name);
> }
>
> static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend,
> Error **errp)
> {
> const char *name = qemu_opt_get(opts, "name");
> + ChardevSpicePort *spiceport;
>
> if (name == NULL) {
> error_setg(errp, "chardev: spice port: no name given");
> return;
> }
> - backend->u.spiceport = g_new0(ChardevSpicePort, 1);
> - backend->u.spiceport->fqdn = g_strdup(name);
> + spiceport = backend->u.spiceport = g_new0(ChardevSpicePort, 1);
> + qemu_chr_parse_common(opts, qapi_ChardevSpicePort_base(spiceport));
> + spiceport->fqdn = g_strdup(name);
> }
>
> static void register_types(void)
> diff --git a/ui/console.c b/ui/console.c
> index b739ae9..7db0fd2 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -2060,31 +2060,33 @@ static void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend,
> Error **errp)
> {
> int val;
> + ChardevVC *vc;
>
> - backend->u.vc = g_new0(ChardevVC, 1);
> + vc = backend->u.vc = g_new0(ChardevVC, 1);
> + qemu_chr_parse_common(opts, qapi_ChardevVC_base(vc));
>
> val = qemu_opt_get_number(opts, "width", 0);
> if (val != 0) {
> - backend->u.vc->has_width = true;
> - backend->u.vc->width = val;
> + vc->has_width = true;
> + vc->width = val;
> }
>
> val = qemu_opt_get_number(opts, "height", 0);
> if (val != 0) {
> - backend->u.vc->has_height = true;
> - backend->u.vc->height = val;
> + vc->has_height = true;
> + vc->height = val;
> }
>
> val = qemu_opt_get_number(opts, "cols", 0);
> if (val != 0) {
> - backend->u.vc->has_cols = true;
> - backend->u.vc->cols = val;
> + vc->has_cols = true;
> + vc->cols = val;
> }
>
> val = qemu_opt_get_number(opts, "rows", 0);
> if (val != 0) {
> - backend->u.vc->has_rows = true;
> - backend->u.vc->rows = val;
> + vc->has_rows = true;
> + vc->rows = val;
> }
> }
>
I've picked up this patch and will send a pull request ASAP.
Paolo
next prev parent reply other threads:[~2016-02-22 10:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-20 0:19 [Qemu-devel] [PATCH 00/17] qapi implicit types (continuing the qapi cleanup theme) Eric Blake
2016-02-20 0:19 ` [Qemu-devel] [PATCH 01/17] chardev: Properly initialize ChardevCommon components Eric Blake
2016-02-22 10:13 ` Daniel P. Berrange
2016-02-22 10:18 ` Paolo Bonzini [this message]
2016-02-20 0:19 ` [Qemu-devel] [PATCH 02/17] chardev: Shorten references into ChardevBackend Eric Blake
2016-02-22 10:16 ` Daniel P. Berrange
2016-02-20 0:19 ` [Qemu-devel] [PATCH 03/17] util: Shorten references into SocketAddress Eric Blake
2016-02-22 10:18 ` Daniel P. Berrange
2016-02-20 0:19 ` [Qemu-devel] [PATCH 04/17] ui: Shorten references into InputEvent Eric Blake
2016-02-22 10:27 ` Daniel P. Berrange
2016-02-20 0:19 ` [Qemu-devel] [PATCH 05/17] qapi: Avoid use of 'data' member of qapi unions Eric Blake
2016-02-22 10:34 ` Daniel P. Berrange
2016-02-20 0:19 ` [Qemu-devel] [PATCH 06/17] chardev: Drop useless ChardevDummy type Eric Blake
2016-02-22 10:36 ` Daniel P. Berrange
2016-02-20 0:19 ` [Qemu-devel] [PATCH 07/17] qapi: Drop useless 'data' member of unions Eric Blake
2016-02-22 10:39 ` Daniel P. Berrange
2016-02-20 0:19 ` [Qemu-devel] [PATCH 08/17] qapi-visit: Factor out gen_visit_fields_call() Eric Blake
2016-02-20 0:19 ` [Qemu-devel] [PATCH 09/17] qapi: Add type.is_empty() helper Eric Blake
2016-02-20 0:19 ` [Qemu-devel] [PATCH 10/17] qapi: Fix command with named empty argument type Eric Blake
2016-02-20 0:19 ` [Qemu-devel] [PATCH 11/17] qapi-visit: Simplify visit of empty branch in union Eric Blake
2016-02-20 0:19 ` [Qemu-devel] [PATCH 12/17] qapi: Don't special-case simple union wrappers Eric Blake
2016-02-22 10:48 ` Daniel P. Berrange
2016-02-20 0:19 ` [Qemu-devel] [PATCH 13/17] qapi-visit: Move error check into gen_visit_fields_call() Eric Blake
2016-02-20 0:19 ` [Qemu-devel] [PATCH 14/17] qapi: Allow anonymous base for flat union Eric Blake
2016-02-20 0:19 ` [Qemu-devel] [PATCH 15/17] qapi: Use anonymous base in SchemaInfo Eric Blake
2016-02-20 0:19 ` [Qemu-devel] [PATCH 16/17] qapi: Use anonymous base in CpuInfo Eric Blake
2016-02-20 0:19 ` [Qemu-devel] [PATCH 17/17] qapi: Make c_type() more OO-like Eric Blake
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=56CAE07B.9090108@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kraxel@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.