From patchwork Mon Sep 18 10:31:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 9956381 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 0D30860568 for ; Mon, 18 Sep 2017 10:35:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0D7528C09 for ; Mon, 18 Sep 2017 10:35:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5BD128C17; Mon, 18 Sep 2017 10:35:28 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 8BCC328C24 for ; Mon, 18 Sep 2017 10:35:28 +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 1dttMH-0001zr-OY; Mon, 18 Sep 2017 10:32:57 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dttMG-0001y5-8V for xen-devel@lists.xenproject.org; Mon, 18 Sep 2017 10:32:56 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id A8/0D-03616-7D0AFB95; Mon, 18 Sep 2017 10:32:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsVyMfTAWt1rC/Z HGjwpsvi+ZTKTA6PH4Q9XWAIYo1gz85LyKxJYMxr2dDAWrBCvOHrmBHMD4y7hLkZODiGBaYwS J6+YdzFycbAIzGOWuLX0CAuIIyHQzypx6uMnZpAqCYE0ic/rulhh7GuX9gEVcQDZNRK7WlkgB mlJHD01mxWkV0hgB5PE/YnLGEFq2ARMJGZ1SIDUiAgoSdxbNZkJpIZZYD6jRNOkXjaQGmGBCI mFrxJBalgEVCXerJkNNpNXwEdi+/rZ7BBr5SRunusEO4cTKH5+/QNWiL3eEvN+XWGcwCi4gJF hFaN6cWpRWWqRrqVeUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkZgqDEAwQ7Gu5sC DjFKcjApifKKRu6PFOJLyk+pzEgszogvKs1JLT7EKMPBoSTB+24+UE6wKDU9tSItMwcY9DBpC Q4eJRHedSBp3uKCxNzizHSI1ClGS44Ldy79YeI4sOcWkOy4efcPkxBLXn5eqpQ4xDwBkIaM0j y4cbDIvMQoKyXMywh0oBBPQWpRbmYJqvwrRnEORiVh3kcgU3gy80rgtr4COogJ6KCWHXtADip JREhJNTCq5H63XPsisOjIpqZCXm1b7pkRHEa6Sx983e3x/Qfbo0cOHz7/dZ+odLNzmefkB6az cg2+THz6ofJwQN653gb91CPvDh042vP3U8rhBfJOobxXks2l9LZdbpHWTtugtrlg+5LTf+sF/ zbZn1N9ebhudVzYxbZyySTF0I42H5kexlMhtd+mvzBSYinOSDTUYi4qTgQATsmgD8cCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-27.messagelabs.com!1505730772!85447993!1 X-Originating-IP: [209.85.192.173] 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 5918 invoked from network); 18 Sep 2017 10:32:53 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-11.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Sep 2017 10:32:53 -0000 Received: by mail-pf0-f173.google.com with SMTP id p87so27608pfj.9 for ; Mon, 18 Sep 2017 03:32:53 -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=UCapcZKvYLGylzbNemCSTQkummga6UP2Np3Ltn/iT1Ddj+ql1f6o9yM/pCapJVnMEt xy70oZs3yJ3fGCpZWvnxDKs8sE0EDA8tIMgsJ9jfECUAYqfWL5pwkKnw42erIfQIp1NE jK0ur23xv1ID93y2gHXLArGeUVcH4MYrIKjsI= 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=L/oxwPaAcp2C1Itng8UjF4S76D49ZuQLaTq3muP8Y0sEeTt8JFFt3cxdxCI8TK3cRZ c/Q7HvpAFP6oROx5MIW7MJfuwQNNCPPMVmA27+KfFU1czxyk7xDS+IbAv/uWXLZEEecE XDI5wxLhguSw+qNUmq6tdTYhwRhSOj0/x24deUM1OgSK+53E0mqvL+M5AxAQPJSWyIiB CU5YS0NX1rKHti7kjGG3uH3IjNPT/j44UXPVYiWcChACDxvhmQBePS9cczh+fZ7TotLW fya8he0EULqefr/71DrO1guTM0GMpdsXdfCXrSjj5+ptH92Xx8BACM07mraE0lEQlmDJ DBHg== X-Gm-Message-State: AHPjjUj3mN11yj4byCJzYngfY2SC5d7divg8ZfM1C7/jhSosuNXMfw8u DdsKOcLRF29bgyswzjbUEA== X-Google-Smtp-Source: AOwi7QDPb1uLX6+ZKIc7YkTbTk0pLZv6q6nHEIH8YOS8axPCVklVjqiTooeqYk6/aBUXZ8GpiF7Bgg== X-Received: by 10.98.210.138 with SMTP id c132mr17911558pfg.331.1505730772274; Mon, 18 Sep 2017 03:32:52 -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 b7sm12937845pge.79.2017.09.18.03.32.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Sep 2017 03:32:51 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 18 Sep 2017 16:01:55 +0530 Message-Id: <1505730731-10947-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505730731-10947-1-git-send-email-bhupinder.thakur@linaro.org> References: <1505730731-10947-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/27 v9] 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; }