From patchwork Sat Feb 20 00:19:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8365161 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 94E819F314 for ; Sat, 20 Feb 2016 00:20:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB8FC20570 for ; Sat, 20 Feb 2016 00:20:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B90F2056E for ; Sat, 20 Feb 2016 00:20:22 +0000 (UTC) Received: from localhost ([::1]:56505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWvHZ-0004u6-Bi for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Feb 2016 19:20:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWvH9-0004bM-Im for qemu-devel@nongnu.org; Fri, 19 Feb 2016 19:19:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWvH6-0003rm-Cf for qemu-devel@nongnu.org; Fri, 19 Feb 2016 19:19:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWvH6-0003rC-4e for qemu-devel@nongnu.org; Fri, 19 Feb 2016 19:19:52 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 0F5F3A84 for ; Sat, 20 Feb 2016 00:19:50 +0000 (UTC) Received: from red.redhat.com (ovpn-113-75.phx2.redhat.com [10.3.113.75]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1K0Jn6I025514; Fri, 19 Feb 2016 19:19:50 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 19 Feb 2016 17:19:31 -0700 Message-Id: <1455927587-28033-2-git-send-email-eblake@redhat.com> In-Reply-To: <1455927587-28033-1-git-send-email-eblake@redhat.com> References: <1455927587-28033-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , armbru@redhat.com, Gerd Hoffmann Subject: [Qemu-devel] [PATCH 01/17] chardev: Properly initialize ChardevCommon components X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 CC: Daniel P. Berrange Reviewed-by: Daniel P. Berrange --- 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; } }