From patchwork Wed Sep 27 06:13:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 9973129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 720BA6037F for ; Wed, 27 Sep 2017 06:17:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65717223B3 for ; Wed, 27 Sep 2017 06:17:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A5E323B24; Wed, 27 Sep 2017 06:17:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F0CC5223B3 for ; Wed, 27 Sep 2017 06:17:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx5bc-0002fi-08; Wed, 27 Sep 2017 06:14:00 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx5ba-0002b2-Cv for xen-devel@lists.xenproject.org; Wed, 27 Sep 2017 06:13:58 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id FA/2A-03454-6A14BC95; Wed, 27 Sep 2017 06:13:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsXiVRusr7vY8XS kwebd4hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bDng7GghXiFUfPnGBuYNwl3MXIxSEkMJNR onP2YjYQh0VgHrPE/s2TGUEcCYF+Voktk+6zdjFyAjl5Ek1bLjFC2GkSx9cugbLLJa6cOscGY gsJaEkcPTWbFWLsCiaJU6397F2MHBxsAiYSszokQGpEBJQk7q2azARSwywwn1GiaVIvWLOwQK TEgtU7mEBsFgFVib77l8HivAI+EhMbP7FDLJOTuHmukxnE5gSKn+6/DbXYW+LSyn7WCYyCCxg ZVjGqF6cWlaUW6VrqJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEhhwDEOxgvLsp 4BCjJAeTkihvzf9TkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeOc5nI4UEixKTU+tSMvMAQY/T FqCg0dJhPcaSJq3uCAxtzgzHSJ1itGS40vvjT9MHPv23AKSHTfv/mESYsnLz0uVEuetAmkQAG nIKM2DGweL0EuMslLCvIxABwrxFKQW5WaWoMq/YhTnYFQS5l0IMoUnM68EbusroIOYgA7qnXo C5KCSRISUVANjYkrVx6DSeQ5KwodvvfNdbppVw617Zebf7D291lw/G8+7p6pqLgnS+iC96Pzv hkMVHjW+PAxi2YWaxxk5NR2cmLoeHjy/JuLei5sbvKvM+KavfydjWZR1g3PL0QPm1xdlVVx/G CiT3Ta784ixbJ5adpCENmdCh+6uQGHHuKnWn29Y28T8tVRiKc5INNRiLipOBAC2VxI4ywIAAA == X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-8.tower-21.messagelabs.com!1506492834!84672494!1 X-Originating-IP: [74.125.83.47] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28061 invoked from network); 27 Sep 2017 06:13:55 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-8.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 27 Sep 2017 06:13:55 -0000 Received: by mail-pg0-f47.google.com with SMTP id c137so7216449pga.11 for ; Tue, 26 Sep 2017 23:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EtvhJzM3HTL/NgQ6915SS3H5bdB2TB/oZeG6xtku1W0=; b=ACgZigtReMLZNLNAD6D7Z9BSSbnYrGDPUa8YkQuvdbz2dd9e86ZlpGAxahGdaa4Flw Z6jm9hoSZmYGJfhvjhRz3V/MavfYamx5gxAeUyFKjVLNdeKKlDZkR6tq6L8wQWXelQu1 FrKyRR9w3Mqthu0k6RZJNjnrihnPsFcsxoM2s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EtvhJzM3HTL/NgQ6915SS3H5bdB2TB/oZeG6xtku1W0=; b=FXoE+Atm/P0IGNVeSOVE7QVPg9eSzY9T64GBA2T4hu2Mvcoc2TuBJysLxtckwuO96y qr7MoSpZJx6aa4HcJtjWsfU0K4jn60pXNo7nNUVMZhibTpvL0Qwc6JQTSCKnTuqzY6Ic zXJ+jlUGXkNLTxHx0eiXYe/zvkiaW1tDws0+/hriJDFIv1pJydrfCK2BeReu6sO+vqcp btWKgcw9l9p3nCMY6pjTCs01iDJ9enCeVHAYBjg7V9Fz/L8DYMeKHyH66Z1SyIZUvBsi lqzFWJVgMyMl6c07G4L9MMFbkEUFljnoqM2RVMswa53z/dn+UTK74Rn2cT4X9HQwJza+ I4vg== X-Gm-Message-State: AHPjjUi6xi4hUTX8kWpK6azJdHnW6GrPQ4gPk1n5IPstDBTlTcfYWSjT WMubisG6rEbSpZIvbCvbQDTXnNEosLo= X-Google-Smtp-Source: AOwi7QC1GF2V1kWRwmEdi5Dr+JvZAjzVDrM9VM+G5CGCsZnvp95w00eOqBenWiFbW7f9DWvBY2351A== X-Received: by 10.159.252.5 with SMTP id n5mr324029pls.360.1506492833344; Tue, 26 Sep 2017 23:13:53 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id s187sm18013485pgb.82.2017.09.26.23.13.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 23:13:52 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Wed, 27 Sep 2017 11:43:20 +0530 Message-Id: <1506492816-25954-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> References: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/27 v11] xen/arm: vpl011: Add a new console_init function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces a new console_init function. This function initializes the console structure. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 65 ++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a2a3496..1da08d7 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -655,20 +655,51 @@ static bool watch_domain(struct domain *dom, bool watch) return success; } - -static struct domain *create_domain(int domid) +static int console_init(struct console *con, struct domain *dom) { - struct domain *dom; char *s; + int err = -1; struct timespec ts; - struct console *con; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { dolog(LOG_ERR, "Cannot get time of day %s:%s:L%d", __FILE__, __FUNCTION__, __LINE__); - return NULL; + return err; } + con->master_fd = -1; + con->master_pollfd_idx = -1; + con->slave_fd = -1; + con->log_fd = -1; + con->ring_ref = -1; + con->local_port = -1; + con->remote_port = -1; + con->xce_pollfd_idx = -1; + con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; + con->d = dom; + con->xspath = xs_get_domain_path(xs, dom->domid); + s = realloc(con->xspath, strlen(con->xspath) + + strlen("/console") + 1); + if (s) { + con->xspath = s; + strcat(con->xspath, "/console"); + err = 0; + } + + return err; +} + +static void console_free(struct console *con) +{ + if (con->xspath) + free(con->xspath); +} + +static struct domain *create_domain(int domid) +{ + struct domain *dom; + struct console *con; + dom = calloc(1, sizeof *dom); if (dom == NULL) { dolog(LOG_ERR, "Out of memory %s:%s():L%d", @@ -677,28 +708,10 @@ static struct domain *create_domain(int domid) } dom->domid = domid; - con = &dom->console; - con->xspath = xs_get_domain_path(xs, dom->domid); - s = realloc(con->xspath, strlen(con->xspath) + - strlen("/console") + 1); - if (s == NULL) - goto out; - con->xspath = s; - strcat(con->xspath, "/console"); - - con->master_fd = -1; - con->master_pollfd_idx = -1; - con->slave_fd = -1; - con->log_fd = -1; - con->xce_pollfd_idx = -1; - con->d = dom; - - con->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 1000000) + RATE_LIMIT_PERIOD; - con->ring_ref = -1; - con->local_port = -1; - con->remote_port = -1; + if (console_init(con, dom)) + goto out; if (!watch_domain(dom, true)) goto out; @@ -710,7 +723,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->xspath); + console_free(con); free(dom); return NULL; }