From patchwork Fri Aug 8 17:07:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 35149 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f69.google.com (mail-qg0-f69.google.com [209.85.192.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 97FB52118A for ; Fri, 8 Aug 2014 17:10:26 +0000 (UTC) Received: by mail-qg0-f69.google.com with SMTP id a108sf16346803qge.0 for ; Fri, 08 Aug 2014 10:10:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=EkChmQEpgi/dWX+Sfk9aN6IYD3qnz5Q3N5NG4usEGf4=; b=bDClNEr0uAjEF+aKd2AnYRSxGQU8y0iWCd2viDuBwZoLlYRNjP2VllVvK1otpC4+0Y r3m8jsuhU8iIgBJGSgcbaxbmMzWL5Yxbn12Ty+n/jTi9BL/W5B19YgyYrhI2qyQmq3Di 06kGqZ53ofRuuVakgNzQ8gVoleJjHOWs30vfmnTRw29xJ0keHfykZnSTtW5N8g2q8qWy quu+a/2oWchb7Ip0p/+esxp1nQf74EzioM7zvTo0wQjAYpuTUSk1cGXDd5RJjXyTaoUq wZLTsxt3yqnOiLvsqjwi+OnG9jC7hOtdYU45mRoFLH5TeaWQe6aMHAAfSf2+rVCQIkVW aKnw== X-Gm-Message-State: ALoCoQm70Ep5tdJ0u8A9pyOkUBUjUShlyhMZIsiSCxAqfPKDhkybSOoWWiTtOaOcQe/KPMVvpSp4 X-Received: by 10.236.31.68 with SMTP id l44mr5313299yha.29.1407517826466; Fri, 08 Aug 2014 10:10:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.176 with SMTP id t45ls613862qgt.60.gmail; Fri, 08 Aug 2014 10:10:26 -0700 (PDT) X-Received: by 10.52.234.228 with SMTP id uh4mr7663377vdc.34.1407517826314; Fri, 08 Aug 2014 10:10:26 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id ag1si3097845vec.32.2014.08.08.10.10.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 10:10:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id im17so8800711vcb.3 for ; Fri, 08 Aug 2014 10:10:26 -0700 (PDT) X-Received: by 10.52.61.136 with SMTP id p8mr7602527vdr.15.1407517826247; Fri, 08 Aug 2014 10:10:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp140046vcb; Fri, 8 Aug 2014 10:10:25 -0700 (PDT) X-Received: by 10.224.38.10 with SMTP id z10mr28150008qad.52.1407517825581; Fri, 08 Aug 2014 10:10:25 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b30si2823857qgd.62.2014.08.08.10.10.25 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 08 Aug 2014 10:10:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:52057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFngP-0005H2-2D for patch@linaro.org; Fri, 08 Aug 2014 13:10:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFnfb-0004WY-Ee for qemu-devel@nongnu.org; Fri, 08 Aug 2014 13:09:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFnfZ-0004PT-5q for qemu-devel@nongnu.org; Fri, 08 Aug 2014 13:09:35 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:48943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFnfY-0004P9-U1 for qemu-devel@nongnu.org; Fri, 08 Aug 2014 13:09:33 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1XFndZ-0002wI-L5; Fri, 08 Aug 2014 18:07:29 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 8 Aug 2014 18:07:29 +0100 Message-Id: <1407517649-11257-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1407517649-11257-1-git-send-email-peter.maydell@linaro.org> References: <1407517649-11257-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: Paolo Bonzini , Gerd Hoffmann , Markus Armbruster Subject: [Qemu-devel] [PATCH 4/4] qemu-char: Remove register_char_driver() machinery 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Now that all the char backends have been converted to the QAPI framework we can remove the machinery for handling old style backends. Signed-off-by: Peter Maydell --- include/sysemu/char.h | 1 - qemu-char.c | 126 +++++++++++++++----------------------------------- 2 files changed, 38 insertions(+), 89 deletions(-) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 98cd4c9..dbfd4e6 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -344,7 +344,6 @@ bool chr_is_ringbuf(const CharDriverState *chr); QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); -void register_char_driver(const char *name, CharDriverState *(*open)(QemuOpts *)); void register_char_driver_qapi(const char *name, ChardevBackendKind kind, void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp)); diff --git a/qemu-char.c b/qemu-char.c index a01ccdc..2ffab1a 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3489,26 +3489,12 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend, typedef struct CharDriver { const char *name; - /* old, pre qapi */ - CharDriverState *(*open)(QemuOpts *opts); - /* new, qapi-based */ ChardevBackendKind kind; void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp); } CharDriver; static GSList *backends; -void register_char_driver(const char *name, CharDriverState *(*open)(QemuOpts *)) -{ - CharDriver *s; - - s = g_malloc0(sizeof(*s)); - s->name = g_strdup(name); - s->open = open; - - backends = g_slist_append(backends, s); -} - void register_char_driver_qapi(const char *name, ChardevBackendKind kind, void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp)) { @@ -3530,8 +3516,12 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, CharDriver *cd; CharDriverState *chr; GSList *i; + ChardevReturn *ret = NULL; + ChardevBackend *backend; + const char *id = qemu_opts_id(opts); + char *bid = NULL; - if (qemu_opts_id(opts) == NULL) { + if (id == NULL) { error_setg(errp, "chardev: no id specified"); goto err; } @@ -3554,89 +3544,49 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, goto err; } - if (!cd->open) { - /* using new, qapi init */ - ChardevBackend *backend = g_new0(ChardevBackend, 1); - ChardevReturn *ret = NULL; - const char *id = qemu_opts_id(opts); - char *bid = NULL; + backend = g_new0(ChardevBackend, 1); - if (qemu_opt_get_bool(opts, "mux", 0)) { - bid = g_strdup_printf("%s-base", id); - } + if (qemu_opt_get_bool(opts, "mux", 0)) { + bid = g_strdup_printf("%s-base", id); + } - chr = NULL; - backend->kind = cd->kind; - if (cd->parse) { - cd->parse(opts, backend, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto qapi_out; - } - } - ret = qmp_chardev_add(bid ? bid : id, backend, errp); - if (!ret) { + chr = NULL; + backend->kind = cd->kind; + if (cd->parse) { + cd->parse(opts, backend, &local_err); + if (local_err) { + error_propagate(errp, local_err); goto qapi_out; } - - if (bid) { - qapi_free_ChardevBackend(backend); - qapi_free_ChardevReturn(ret); - backend = g_new0(ChardevBackend, 1); - backend->mux = g_new0(ChardevMux, 1); - backend->kind = CHARDEV_BACKEND_KIND_MUX; - backend->mux->chardev = g_strdup(bid); - ret = qmp_chardev_add(id, backend, errp); - if (!ret) { - chr = qemu_chr_find(bid); - qemu_chr_delete(chr); - chr = NULL; - goto qapi_out; - } - } - - chr = qemu_chr_find(id); - chr->opts = opts; - - qapi_out: - qapi_free_ChardevBackend(backend); - qapi_free_ChardevReturn(ret); - g_free(bid); - return chr; } - - chr = cd->open(opts); - if (!chr) { - error_setg(errp, "chardev: opening backend \"%s\" failed", - qemu_opt_get(opts, "backend")); - goto err; + ret = qmp_chardev_add(bid ? bid : id, backend, errp); + if (!ret) { + goto qapi_out; } - if (!chr->filename) - chr->filename = g_strdup(qemu_opt_get(opts, "backend")); - chr->init = init; - /* if we didn't create the chardev via qmp_chardev_add, we - * need to send the OPENED event here - */ - if (!chr->explicit_be_open) { - qemu_chr_be_event(chr, CHR_EVENT_OPENED); + if (bid) { + qapi_free_ChardevBackend(backend); + qapi_free_ChardevReturn(ret); + backend = g_new0(ChardevBackend, 1); + backend->mux = g_new0(ChardevMux, 1); + backend->kind = CHARDEV_BACKEND_KIND_MUX; + backend->mux->chardev = g_strdup(bid); + ret = qmp_chardev_add(id, backend, errp); + if (!ret) { + chr = qemu_chr_find(bid); + qemu_chr_delete(chr); + chr = NULL; + goto qapi_out; + } } - QTAILQ_INSERT_TAIL(&chardevs, chr, next); - if (qemu_opt_get_bool(opts, "mux", 0)) { - CharDriverState *base = chr; - int len = strlen(qemu_opts_id(opts)) + 6; - base->label = g_malloc(len); - snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); - chr = qemu_chr_open_mux(base); - chr->filename = base->filename; - chr->avail_connections = MAX_MUX; - QTAILQ_INSERT_TAIL(&chardevs, chr, next); - } else { - chr->avail_connections = 1; - } - chr->label = g_strdup(qemu_opts_id(opts)); + chr = qemu_chr_find(id); chr->opts = opts; + +qapi_out: + qapi_free_ChardevBackend(backend); + qapi_free_ChardevReturn(ret); + g_free(bid); return chr; err: