From patchwork Mon Aug 7 08:53:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 109533 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2482043obb; Mon, 7 Aug 2017 01:55:57 -0700 (PDT) X-Received: by 10.36.246.5 with SMTP id u5mr199042ith.82.1502096157521; Mon, 07 Aug 2017 01:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502096157; cv=none; d=google.com; s=arc-20160816; b=R8DVY0T1HRFkAYgFq70ILimjytUy0FrewLi48dmRK5dz+Nc6m+DUX1yZdHNL0DNghq hy30safzyA52gE+zv6GjFzIjmxHe5x85qBxI+Wp7EM+eNZteiwog2efxgZg9u1wbAxJ0 tHoOBhTOPny36v9rEHnRxhztEwhXXn3qZ3NT7bGbBFjnD1MUwT873XYNTkds/3VsYU+E cdZhoL8ZmR7XA6JCfxplIDKeToIIqL3vnimu7Hkn7cwangRNiqBEdnQUxIezi+HHQLnE Id/sgKiY2qzT74ToYqv+O1tDCVyufRZn0Al2sAe5hb58NA7z1C/nEdwIR0Nu1hWPunld K2Qw== 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=+uFY/pVc8SURBInWhEretAHlX4Js5xxDKWVSHnOsbQU=; b=gQNX6xsb2B82446iTOw2NZ8uilMhJNg7s24f0SSdzr/40bnTrngrsru+FsX1GxMZpg cX01hbCZbYfdXoT6gMcaGTSw+htokwsQ5YIqK6GcEmS+8+utI/K92zTAoVq/AKTxLEbW 7mRio94HeNBQezUHoINqORmxdC2D+cS6MWO8BCvc3cjrv/0n8MGTczbT//GV+Ah6IrcS bqvSuORkBCePvgLjIlDdJNP0YB70xjTi2cbTyhdsoCUSyA83wvpkjpy8KL1kiiiOcvfL p19UqjW9EP7/Qvi2Tgt3adokL1Qdll2l8r674hYoMpZDCwv7wAHodLWuxLVJbQQdmrVB 9LGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=VBWOIu3R; 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 e41si7732711ioj.242.2017.08.07.01.55.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 01:55:57 -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.b=VBWOIu3R; 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 1dednZ-0004bo-Mn; Mon, 07 Aug 2017 08:54:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dednX-0004a0-S9 for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:03 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id E6/00-03582-BAA28895; Mon, 07 Aug 2017 08:54:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLIsWRWlGSWpSXmKPExsVyMfTABt1VWh2 RBl231Cy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyH19YzFTSIV+xYu56tgXGacBcjF4eQwExG iW9TephAHBaBecwSZ54dBXMkBPpZJTpazgI5nEBOmsS6P6/YIewqiYPbb7KA2EICWhJHT81mh RjVxiRxYf1PIIeDg03ARGJWhwRIjYiAksS9VZPBhjILzGeUaJrUywaSEBaIkFjSOw9sAYuAqs TZ/nesIDavgI/EzK9rWSCWyUncPNfJDGJzAsXPX3oDtdhb4vaxPsYJjAILGBlWMWoUpxaVpRb pGhnpJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEBhcDEOxgXDM/8BCjJAeTkihv /Iq2SCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvAmaHZFCgkWp6akVaZk5wDCHSUtw8CiJ8L5QB 0rzFhck5hZnpkOkTjFacly5su4LE8eUA9uB5KsJ/78xCbHk5eelSonz5oDMEwBpyCjNgxsHi8 VLjLJSwryMQAcK8RSkFuVmlqDKv2IU52BUEuadBDKFJzOvBG7rK6CDmIAOepPYCnJQSSJCSgo Y3X9Tpt6KleTxYPNedmHnin+R5mtn6q2IeV4ornz8++Fu8+VsB3dvfq8VyvMhN8Iyv0iGpzZc RPxCuSN3kM9V3jlTLedN4aw/Fn2koG230L59Ov62kYznK6tTZxXF24qdffq++45krdcbZlFPk eSgotUTvY3WXD3yI/W4ZM25+CtrnW4GinQosRRnJBpqMRcVJwIAi6MkZ8ACAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-27.messagelabs.com!1502096041!109840954!1 X-Originating-IP: [209.85.192.176] 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 41796 invoked from network); 7 Aug 2017 08:54:02 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-4.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:02 -0000 Received: by mail-pf0-f176.google.com with SMTP id o86so31431064pfj.1 for ; Mon, 07 Aug 2017 01:54:02 -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=CK3WW8RxUoVEpZ5UMzdRikYESdsFXDtL/nQkFOdJcGQ=; b=VBWOIu3RT6fe8WFaMiPll+qbLxVCHpC3ft+EM1Q6bqJx7s8BZHwktW5xmudQjgcz4Z 3aHg3TJJFt9LL4f+PVUuL1jNxgWtqzIoc4MY1IkOzpPVd1R1JYWjwNR6CGLlcXBnJ1Qr bb6s61IZ3L1koHLjB/gai0jimfjtZYdkigMwo= 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=CK3WW8RxUoVEpZ5UMzdRikYESdsFXDtL/nQkFOdJcGQ=; b=Xdta8Zdqkwf3xIGOLs5ItizYMv8XWB4swHieN5oXv4gVi58YIEyGCjuZZU8+QQdwmc NTAo2Of+jhlV6KGhF2HOxXY9bP9zmM538d+xp3+oHFLOT2eBmWOqE+464OweT7uN1eqJ h3xQ7iqL+zcmv6ozOcFTqViBNzjqpfbQZ25h6hZkkzbNiUiTWZ43iSrP4pCNHRKTWRMK MMF85Xc9LEx6OkFzLLZowk3fywz2esM/XFidABfuhcZ5BB5QwUyZWFYp4/Smg/GYryuF 7Zw2Wy6dLU73n750TgwLeMh6XFpPUmfBiJ4oKsgevHkmmlBjF5Ud/fpmhXrttzt3UPOH WjHQ== X-Gm-Message-State: AIVw111vLBKxpCsmucXKuH6q2z0WO/LJCqQCjbh9aaA7gx6x5CwZLeWQ itD7Fqr9i/l+/CC59ZJL7A== X-Received: by 10.99.181.29 with SMTP id y29mr10825393pge.135.1502096040742; Mon, 07 Aug 2017 01:54:00 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.53.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:00 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:03 +0530 Message-Id: <1502095997-31219-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/25 v7] 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; }