From patchwork Fri Sep 22 08:23:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 113985 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3011223qgf; Fri, 22 Sep 2017 01:26:10 -0700 (PDT) X-Received: by 10.36.127.146 with SMTP id r140mr4867114itc.79.1506068769936; Fri, 22 Sep 2017 01:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506068769; cv=none; d=google.com; s=arc-20160816; b=slGtURyV3kEMmt0AFoPElo5exIRq6SQ79i4b9b5j7wRtYQEocKy9HMJGyRXTjjLfyw aVjez8hM1+juaZibGm8tTxo2xisayJWBeqLayNq3NWvnRuwHC/fKdcgwuIPeDs42kRgk rnvR4UNigvuEIUn14s9ZnsmL6i48rF9iAvqwDhNkQ4Knd8/ikv/LbIl5/Tz3/R8pKRNx 9W9jJM8yQ4JTw8cJMWgnIvS56TFruraZeELcczDz/Qd+I4wcjzGDQ79kY5zjBl29W4mF Aea96vOMhnsuqhLyMhVLCodVRZiGW29sYe+bbnwS9AWsnSXuld5QcDW0ewcZxlyJB13+ HfEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=HCv3UlhcoI7MIaid0Q2Iq9o17QQmhXdFQEnxbwICUws=; b=vVpLNgnYJZYG/EePF9xymrPT8KaBcohSQRJs5BC/9NyNHfmZ2Dr2UspF0IBSULvVek AqgiTibQwot/tsxH0kaz4xYmLLKjLzfzNtWTgTU/8/+ocNNGOEch9OA05GZSSnRAhFGw cMXPj/PnFFo9nh1+Ji387q73gchDOPaSlUScHoOiJGF/t/dfPfDJh9C6rCDMzKnpkOhJ e163LemW8IBBvP+aMn/lj04E8ijC/t7krqtwKAZ3nqIIFkCe5a5Y29jsCjzSOmtrOpYV adUXZoHqvZrvexIctu/3wC9fl/8UeLku2ZOrajqX6wq7+eZSkz6NqqqH3AmSkL405023 I9ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hGpYig5u; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id j13si3136322ioi.99.2017.09.22.01.26.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 01:26:09 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hGpYig5u; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvJFr-0003x8-QU; Fri, 22 Sep 2017 08:24:11 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvJFq-0003w3-Tu for xen-devel@lists.xenproject.org; Fri, 22 Sep 2017 08:24:11 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 09/5D-02224-AA8C4C95; Fri, 22 Sep 2017 08:24:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVyMfTAJt2VJ45 EGuw8r2bxfctkJgdGj8MfrrAEMEaxZuYl5VcksGY07OlgLFghXnH0zAnmBsZdwl2MXBxCAtMZ Je6f2cAI4rAIzGOWuHtlNjOIIyHQzyrxcecpli5GTiAnT6Lv7i1GCDtNYt+b/cwQdqXEvJUbw GwhAS2Jo6dms0KM3cEksf3PJPYuRg4ONgETiVkdEiA1IgJKEvdWTWYCqWEWmM8o0TSplw0kIS wQKdH/8QfYMhYBVYm2j4dYQXp5BXwk+p+lQeySk7h5rhNsFydQeO3/DSwQe70ltt64yjKBUXA BI8MqRo3i1KKy1CJdQ0u9pKLM9IyS3MTMHF1DA2O93NTi4sT01JzEpGK95PzcTYzAkKtnYGDc wfj7uN8hRkkOJiVR3sdHjkQK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuC1Pw6UEyxKTU+tSMvMA QY/TFqCg0dJhDccJM1bXJCYW5yZDpE6xWjJceHOpT9MHAf23AKSHTfv/mESYsnLz0uVEucNAG kQAGnIKM2DGweL0EuMslLCvIwMDAxCPAWpRbmZJajyrxjFORiVhHkVQabwZOaVwG19BXQQE9B B5avBDipJREhJNTBWpU5fsZ2bd417PCv34ZWXjtyZHmBjG/A8PrXu5a1Oro/79i9fclkjKji2 NE3jme38tO1zYn05O7fyKW+ZwGT16c5xjVNWbpdPvJrbVVe/+J5D0McvEbWzu2WL7rL9iueen 9vwyLvijobas+d831hCnxx8eX65feh5FwMxSaEYu7g/Ar1HpnIqsRRnJBpqMRcVJwIAC+HjsM sCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-3.tower-31.messagelabs.com!1506068648!116012731!1 X-Originating-IP: [209.85.192.178] 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 33812 invoked from network); 22 Sep 2017 08:24:09 -0000 Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by server-3.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Sep 2017 08:24:09 -0000 Received: by mail-pf0-f178.google.com with SMTP id n24so238844pfk.5 for ; Fri, 22 Sep 2017 01:24:09 -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=hGpYig5u1U10wWa4RaO29Ohi47u4ZUih7hZQuS7pyW7OOGPu9kYms1V+GD19xRQmiy egY8GRIhRNpn6Pwfd6rIIvCqSuQlhX48xc6HbRMFa1IdnmwsEHUqZQrpavjyNPq7JF1i K+dTB3dBihFyEOZ9PrC0Ao8Np4FQhFdaFsNsc= 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=M5kg6w+VofQKjyW/86leNSMSP9ZtiucfST4wsjmpxRDQV1c4q6/PCk5/lx3wFGeWX+ RRbwcGJSdjYAC4vvvHwcr3mem56Ub3664QNd8tdvmW/oJXJ7irPA6y1Z0iyR2cgLS18Y 4HiGMT7sM2+oxBiEwhAYC3ghKvrrr1abMylvYbP2DesiKvGQMyysI5fV7qBAaEVBYqqQ AKb28Ivo+IZXjxeCTHfRf6kxZrQ8hjz9G6cekFa13Gtl41Sw/qqpUsI8AGzNV0kMWdT4 tkHLe+pcaVih/Cqp0hJCC2xsL5cS8gj5V5TgCCvbp3VhBfo65yJz0YEP3QSTPfKvnUBJ jk6g== X-Gm-Message-State: AHPjjUgGqcfuVp0btaEW73u8D873K+nahl4/wfYln0sKxiP0kFL/++AV ruaIuoqpOItuxnnpjTsmj4XpfKl9Oc4= X-Google-Smtp-Source: AOwi7QCrNH54Cab4XP9e4v8ANCSSEWsMjWRtiaEci9AlQ1xtO66v1Gpi6bYohkxEM+F/xBXfCSURNQ== X-Received: by 10.84.209.135 with SMTP id y7mr8261403plh.439.1506068647800; Fri, 22 Sep 2017 01:24:07 -0700 (PDT) Received: from blr-ubuntu-linaro.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id f74sm5569284pfa.36.2017.09.22.01.24.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Sep 2017 01:24:07 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Fri, 22 Sep 2017 13:53:10 +0530 Message-Id: <1506068606-17066-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506068606-17066-1-git-send-email-bhupinder.thakur@linaro.org> References: <1506068606-17066-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/27 v10] 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" 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; }