From patchwork Mon Jul 17 13:06:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 9844921 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 F19306037F for ; Mon, 17 Jul 2017 13:09:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E41CC26E4A for ; Mon, 17 Jul 2017 13:09:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8D5428505; Mon, 17 Jul 2017 13:09:41 +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=-2.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, RCVD_IN_SORBS_WEB, 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 7EC9426E4A for ; Mon, 17 Jul 2017 13:09:41 +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 1dX5kS-0004QO-Al; Mon, 17 Jul 2017 13:07:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kQ-0004Ox-Su for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:38 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 62/D5-27137-A96BC695; Mon, 17 Jul 2017 13:07:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXiVRusoztzW06 kwapDYhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aHbQ/ZCtrEKxYumMnSwLhYuIuRi0NIYDqj xKQ3ZxhBHBaBecwS3S1nwRwJgX5WiSs7rrB3MXICOWkS2/YsYoSwKyR2nmsEiwsJaEkcPTWbF WJUK5PE3rmzgBwODjYBE4lZHRIgNSICShL3Vk1mAqlhFpjPKNE0qZcNJCEsECGxvmkT2FAWAV WJpYf+s4DYvAI+Eqf79kAtk5O4ea6TGcTmBIqf2bCaCWKxt8TNIxOZJjAKLGBkWMWoUZxaVJZ apGtkqJdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERhcDECwg/HPsoBDjJIcTEqi vBfZsiOF+JLyUyozEosz4otKc1KLDzHKcHAoSfC6b82JFBIsSk1PrUjLzAGGOUxagoNHSYS3G iTNW1yQmFucmQ6ROsVozDHpwPYvTByvJvz/xiTEkpeflyolzqsHUioAUppRmgc3CBZ/lxhlpY R5GYFOE+IpSC3KzSxBlX/FKM7BqCTMuxxkCk9mXgncvldApzABnSLsC3ZKSSJCSqqB0UXihfe +UwfP7i86GJSk/au6V+mQu3H16sdxs/e6F0Wa6D/70XWJ22xPpmldTXNnVMd/gUk1U9buCC9/ 8m39//jlkzw2vle6d+JsH2/Yn4hWyf74rL9qx3fpJk3IErTOOFF80+h/fhlDhQe7aMuPtXObC xlNI4Tv/Mv02HLrfdCuLUJXDwSlKLEUZyQaajEXFScCAADrWFS6AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1500296856!107623548!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30171 invoked from network); 17 Jul 2017 13:07:37 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:37 -0000 Received: by mail-pg0-f44.google.com with SMTP id 123so6568556pgj.1 for ; Mon, 17 Jul 2017 06:07:37 -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=6B3hwzMdVFS42UPpfp85EMbOcIpuHsakwVd0ckhk56Q=; b=a2+XmI5J+Ak/a3O+OYPAb9xg+BGxKhMVcNvNMzZO2HBLhFE4xiEYj1oaOvuz9cQSnE cd4Qh8u45U/hwG65gGq0+YfpA/0zcFxY7FXq1oDblR6CR7/qvN++Dj7LKa0a2s3nYWM/ Zi7z3O89Npu9ZqDHmq4osMmzIbzoQQvObr2WA= 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=6B3hwzMdVFS42UPpfp85EMbOcIpuHsakwVd0ckhk56Q=; b=SL7MZXG8CSyuXWt0f6uLaGMw7SjS1c/O+Kg2zawIZWrs8edn5UiasoTpP+kYOtLdV3 veJqIzNRMNFDrls3wDTkbEjSyp6LgWcbd/otVs4ZIta2j2EXyvVgIMYxb6FBEPLyUb8E r4+1xiPQB+N8gmBRWnCfja5KeMh9NehMBNbudhOM7mtvxOuoYFhxFZ+5jy24zHBMgvl1 bQ9igR3fyrlcif/dGyLmqsDBLMv7RJDrGDKaWlfYipAkAZCj1au+7sQv+UZTlfo8dOTV piBAoXi8ghdX5j8CaMg9lYiEYfhauv1gdncExKBQTHJDT7kIJf+bnRjJDErY6YJiWBdq 7A0Q== X-Gm-Message-State: AIVw110DIt6NeeAAVEUCj87/5fgxFmFsmios6wM5plLu+hMpTMEL46x2 7RmGY0rHtsMdRq1Qeo64xQ== X-Received: by 10.99.177.6 with SMTP id r6mr18880492pgf.106.1500296855756; Mon, 17 Jul 2017 06:07:35 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:35 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:41 +0530 Message-Id: <1500296815-10243-12-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 11/25 v6] 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 --- 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 | 64 +++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a2a3496..9e92097 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -655,13 +655,10 @@ 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; 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", @@ -669,6 +666,41 @@ static struct domain *create_domain(int domid) return NULL; } + 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; + char *s; + struct console *con; + dom = calloc(1, sizeof *dom); if (dom == NULL) { dolog(LOG_ERR, "Out of memory %s:%s():L%d", @@ -677,28 +709,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 +724,7 @@ static struct domain *create_domain(int domid) return dom; out: - free(con->xspath); + console_free(con); free(dom); return NULL; }